Skip to content

Commit

Permalink
[ui] Repair asset header breadcrumbs for long key strings (#23384)
Browse files Browse the repository at this point in the history
## Summary & Motivation

Force the `Breadcrumbs` items in the asset view header to render with
`MiddleTruncate` to ensure that long keys in the path still show up.
Otherwise, we can end up using the entire width with a single key and
every breadcrumb gets pushed into the overflow menu.

Also tweaked the overflow menu to match popover behavior from our other
components.

<img width="464" alt="Screenshot 2024-08-02 at 12 55 00"
src="https://github.com/user-attachments/assets/8b6d017d-2d45-4dcf-a344-a89b4b2dd3d1">


## How I Tested These Changes

View assets with very long key elements in their paths, verify that
middle truncate behaves correctly. It's not perfect because the
middle-truncated strings have a little excess horizontal space in some
cases, but it's an improvement.
  • Loading branch information
hellendag authored Aug 2, 2024
1 parent a0fe2a8 commit 34e898b
Showing 1 changed file with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Heading,
Icon,
IconWrapper,
MiddleTruncate,
PageHeader,
Tooltip,
} from '@dagster-io/ui-components';
Expand Down Expand Up @@ -78,14 +79,24 @@ export const AssetPageHeader = ({
<Title>
<BreadcrumbsWithSlashes
items={breadcrumbs}
currentBreadcrumbRenderer={({text}) => <Heading>{text}</Heading>}
currentBreadcrumbRenderer={({text}) => (
<TruncatedHeading>
{typeof text === 'string' ? <MiddleTruncate text={text} /> : text}
</TruncatedHeading>
)}
breadcrumbRenderer={({text, href}) => (
<Heading>
<BreadcrumbLink to={href || '#'}>{text}</BreadcrumbLink>
</Heading>
<TruncatedHeading>
<BreadcrumbLink to={href || '#'}>
{typeof text === 'string' ? <MiddleTruncate text={text} /> : text}
</BreadcrumbLink>
</TruncatedHeading>
)}
$numHeaderBreadcrumbs={headerBreadcrumbs.length}
popoverProps={{popoverClassName: 'dagster-popover'}}
popoverProps={{
minimal: true,
modifiers: {offset: {enabled: true, options: {offset: [0, 8]}}},
popoverClassName: 'dagster-popover',
}}
/>
{copyableString ? (
<Tooltip placement="bottom" content="Copy asset key">
Expand All @@ -105,6 +116,11 @@ export const AssetPageHeader = ({
);
};

const TruncatedHeading = styled(Heading)`
max-width: 300px;
overflow: hidden;
`;

const CopyButton = styled.button`
border: none;
background: transparent;
Expand Down

1 comment on commit 34e898b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-c732kfoa1-elementl.vercel.app

Built with commit 34e898b.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.