Skip to content

Commit

Permalink
[dagit] Show full asset paths on details pages, tweak filter interact…
Browse files Browse the repository at this point in the history
…ions (#6764)
  • Loading branch information
bengotow committed Feb 24, 2022
1 parent 64095bd commit 5f3966f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
39 changes: 14 additions & 25 deletions js_modules/dagit/packages/core/src/assets/AssetPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@ import styled from 'styled-components/macro';
import {RepositoryLink} from '../nav/RepositoryLink';
import {RepoAddress} from '../workspace/types';

import {useAssetView} from './useAssetView';

type Props = {assetKey: {path: string[]}; repoAddress: RepoAddress | null} & Partial<
React.ComponentProps<typeof PageHeader>
>;

export const AssetPageHeader: React.FC<Props> = ({assetKey, repoAddress, ...extra}) => {
const [view] = useAssetView();

const breadcrumbs = React.useMemo(() => {
if (assetKey.path.length === 1 || view !== 'directory') {
return null;
if (assetKey.path.length === 1) {
return [{text: assetKey.path[0], href: '/instance/assets'}];
}

const list: BreadcrumbProps[] = [];
Expand All @@ -29,29 +25,22 @@ export const AssetPageHeader: React.FC<Props> = ({assetKey, repoAddress, ...extr
}, '/instance/assets');

return list;
}, [assetKey.path, view]);
}, [assetKey.path]);

return (
<PageHeader
title={
view !== 'directory' || !breadcrumbs ? (
<Heading>{assetKey.path[assetKey.path.length - 1]}</Heading>
) : (
<Box
flex={{alignItems: 'center', gap: 4}}
style={{maxWidth: '600px', overflow: 'hidden'}}
>
<Breadcrumbs
items={breadcrumbs}
breadcrumbRenderer={({text, href}) => (
<Heading>
<BreadcrumbLink to={href || '#'}>{text}</BreadcrumbLink>
</Heading>
)}
currentBreadcrumbRenderer={({text}) => <Heading>{text}</Heading>}
/>
</Box>
)
<Box flex={{alignItems: 'center', gap: 4}} style={{maxWidth: '600px', overflow: 'hidden'}}>
<Breadcrumbs
items={breadcrumbs}
breadcrumbRenderer={({text, href}) => (
<Heading>
<BreadcrumbLink to={href || '#'}>{text}</BreadcrumbLink>
</Heading>
)}
currentBreadcrumbRenderer={({text}) => <Heading>{text}</Heading>}
/>
</Box>
}
tags={
repoAddress ? (
Expand Down
10 changes: 8 additions & 2 deletions js_modules/dagit/packages/core/src/assets/AssetsCatalogTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,19 @@ export const AssetsCatalogTable: React.FC<{prefixPath?: string[]}> = ({prefixPat

const setView = (view: 'flat' | 'graph' | 'directory') => {
_setView(view);
if (view === 'flat' && prefixPath) {
if (view === 'flat' && prefixPath.length) {
history.push('/instance/assets');
} else if (cursor) {
setCursor(undefined);
}
};

React.useEffect(() => {
if (view === 'flat' && prefixPath.length) {
_setView('directory');
}
}, [view, _setView, prefixPath]);

const assetsQuery = useQuery<AssetCatalogTableQuery>(ASSET_CATALOG_TABLE_QUERY, {
notifyOnNetworkStatusChange: true,
skip: view === 'graph',
Expand Down Expand Up @@ -112,7 +118,7 @@ export const AssetsCatalogTable: React.FC<{prefixPath?: string[]}> = ({prefixPat
<AssetViewModeSwitch view={view} setView={setView} />
<RepoFilterButton />
<TextInput
value={search}
value={search || ''}
style={{width: '30vw', minWidth: 150, maxWidth: 400}}
placeholder="Search all asset_keys..."
onChange={(e: React.ChangeEvent<any>) => setSearch(e.target.value)}
Expand Down

0 comments on commit 5f3966f

Please sign in to comment.