From 21de5cc2d7203e8ad3e7a2c5ba42bf8b3ce207fd Mon Sep 17 00:00:00 2001 From: benpankow Date: Fri, 6 Sep 2024 11:26:21 -0700 Subject: [PATCH] [4/k][ui] Hide kind tags by default from asset view --- .../ui-core/src/assets/AssetNodeOverview.tsx | 54 +++++++++++++++++-- .../packages/ui-core/src/graph/KindTags.tsx | 1 + 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/assets/AssetNodeOverview.tsx b/js_modules/dagster-ui/packages/ui-core/src/assets/AssetNodeOverview.tsx index b2e91eb03f5b5..e69d083aab2ba 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/assets/AssetNodeOverview.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/assets/AssetNodeOverview.tsx @@ -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 { @@ -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 ( + + setShown(true)}> + + Show system tags ({tags.length || 0}) + + + + + ); + } else { + return ( + + + {tags.map((tag, idx) => ( + {buildTagString(tag)} + ))} + + + setShown(false)}> + + Hide system tags + + + + + + ); + } +}; + export const AssetNodeOverview = ({ assetKey, assetNode, @@ -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, ); @@ -364,9 +405,16 @@ export const AssetNodeOverview = ({ )} - {filteredTags && - filteredTags.length > 0 && - filteredTags.map((tag, idx) => {buildTagString(tag)})} + {filteredTags && filteredTags.length > 0 && ( + + + {nonSystemTags.map((tag, idx) => ( + {buildTagString(tag)} + ))} + + {systemTags.length > 0 && } + + )} {codeSource && diff --git a/js_modules/dagster-ui/packages/ui-core/src/graph/KindTags.tsx b/js_modules/dagster-ui/packages/ui-core/src/graph/KindTags.tsx index f88ca4854fd94..55da6bfc29278 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/graph/KindTags.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/graph/KindTags.tsx @@ -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 = ({