Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4/k][ui] Hide kind tags by default from asset view #24295

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ import {
AssetComputeKindTag,
AssetStorageKindTag,
isCanonicalStorageKindTag,
isSystemTag,
} from '../graph/KindTags';
import {CodeReferencesMetadataEntry, IntMetadataEntry} from '../graphql/types';
import {useStateWithStorage} from '../hooks/useStateWithStorage';
import {useLaunchPadHooks} from '../launchpad/LaunchpadHooksContext';
import {isCanonicalRowCountMetadataEntry} from '../metadata/MetadataEntry';
import {
Expand All @@ -83,6 +85,41 @@ import {buildTagString} from '../ui/tagAsString';
import {buildRepoAddress} from '../workspace/buildRepoAddress';
import {workspacePathFromAddress} from '../workspace/workspacePath';

const SystemTagsToggle = ({tags}: {tags: Array<{key: string; value: string}>}) => {
const [shown, setShown] = useStateWithStorage('show-asset-definition-system-tags', Boolean);

if (!shown) {
return (
<Caption>
<ButtonLink onClick={() => setShown(true)}>
<Box flex={{alignItems: 'center'}}>
<span>Show system tags ({tags.length || 0})</span>
<Icon name="arrow_drop_down" style={{transform: 'rotate(0deg)'}} />
</Box>
</ButtonLink>
</Caption>
);
} else {
return (
<Box flex={{direction: 'column', gap: 8}}>
<Box>
{tags.map((tag, idx) => (
<Tag key={idx}>{buildTagString(tag)}</Tag>
))}
</Box>
<Caption>
<ButtonLink onClick={() => setShown(false)}>
<Box flex={{alignItems: 'center'}}>
<span>Hide system tags</span>
<Icon name="arrow_drop_down" style={{transform: 'rotate(180deg)'}} />
</Box>
</ButtonLink>
</Caption>
</Box>
);
}
};

export const AssetNodeOverview = ({
assetKey,
assetNode,
Expand Down Expand Up @@ -267,6 +304,10 @@ export const AssetNodeOverview = ({

const storageKindTag = assetNode.tags?.find(isCanonicalStorageKindTag);
const filteredTags = assetNode.tags?.filter((tag) => tag.key !== 'dagster/storage_kind');

const nonSystemTags = filteredTags?.filter((tag) => !isSystemTag(tag));
const systemTags = filteredTags?.filter(isSystemTag);

const relationIdentifierMetadata = assetNode.metadataEntries?.find(
isCanonicalRelationIdentifierEntry,
);
Expand Down Expand Up @@ -364,9 +405,16 @@ export const AssetNodeOverview = ({
)}
</AttributeAndValue>
<AttributeAndValue label="Tags">
{filteredTags &&
filteredTags.length > 0 &&
filteredTags.map((tag, idx) => <Tag key={idx}>{buildTagString(tag)}</Tag>)}
{filteredTags && filteredTags.length > 0 && (
<Box flex={{direction: 'column', gap: 8}}>
<Box>
{nonSystemTags.map((tag, idx) => (
<Tag key={idx}>{buildTagString(tag)}</Tag>
))}
</Box>
{systemTags.length > 0 && <SystemTagsToggle tags={systemTags} />}
</Box>
)}
</AttributeAndValue>
<AttributeAndValue label="Source code">
{codeSource &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const isCanonicalComputeKindTag = (tag: DefinitionTag) =>
export const isCanonicalStorageKindTag = (tag: DefinitionTag) => tag.key === STORAGE_KIND_TAG;

export const isKindTag = (tag: DefinitionTag) => tag.key.startsWith(KIND_TAG_PREFIX);
export const isSystemTag = isKindTag;
export const getKindFromTag = (tag: DefinitionTag) => tag.key.slice(KIND_TAG_PREFIX.length);

export const AssetComputeKindTag = ({
Expand Down