Skip to content

Commit

Permalink
[ui] Fix link to tags on asset catalog (#20746)
Browse files Browse the repository at this point in the history
The asset table filters by matching `DefinitionTag` objects, this PR
adjusts the asset catalog to use `DefinitionTag` instead of a custom
type. This fixes the asset tags links.
  • Loading branch information
clairelin135 authored Mar 26, 2024
1 parent 9329b28 commit ebf073f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export const AssetNodeOverview = ({
{assetNode.tags && assetNode.tags.length > 0 && (
<Box flex={{gap: 4, alignItems: 'center', wrap: 'wrap'}}>
{assetNode.tags.map((tag, idx) => (
<Tag key={idx}>{buildTagString({key: tag.key, value: tag.value})}</Tag>
<Tag key={idx}>{buildTagString(tag)}</Tag>
))}
</Box>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {COMMON_COLLATOR} from '../app/Util';
import {AssetTableDefinitionFragment} from '../assets/types/AssetTableFragment.types';
import {Tag, buildTagString} from '../ui/tagAsString';
import {DefinitionTag} from '../graphql/types';
import {buildTagString} from '../ui/tagAsString';
import {buildRepoPathForHuman} from '../workspace/buildRepoAddress';
import {repoAddressAsHumanString} from '../workspace/repoAddressAsString';
import {repoAddressFromPath} from '../workspace/repoAddressFromPath';
Expand All @@ -17,7 +18,7 @@ type CountByComputeKind = {
};

type CountPerTag = {
tag: Tag;
tag: DefinitionTag;
assetCount: number;
};

Expand Down Expand Up @@ -74,7 +75,7 @@ export function buildAssetCountBySection(assets: AssetDefinitionMetadata[]): Ass
}

assetDefinition.tags.forEach((tag) => {
const stringifiedTag = JSON.stringify({key: tag.key, value: tag.value});
const stringifiedTag = JSON.stringify(tag);
assetCountByTag[stringifiedTag] = (assetCountByTag[stringifiedTag] || 0) + 1;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {useIndexedDBCachedQuery} from './useIndexedDBCachedQuery';
import {PYTHON_ERROR_FRAGMENT} from '../app/PythonErrorFragment';
import {displayNameForAssetKey, isHiddenAssetGroupJob} from '../asset-graph/Utils';
import {assetDetailsPathForKey} from '../assets/assetDetailsPathForKey';
import {Tag, buildTagString} from '../ui/tagAsString';
import {DefinitionTag} from '../graphql/types';
import {buildTagString} from '../ui/tagAsString';
import {buildRepoPathForHuman} from '../workspace/buildRepoAddress';
import {repoAddressAsURLString} from '../workspace/repoAddressAsString';
import {RepoAddress} from '../workspace/types';
Expand All @@ -31,7 +32,7 @@ export const linkToAssetTableWithComputeKindFilter = (computeKind: string) => {
})}`;
};

export const linkToAssetTableWithTagFilter = (tag: Tag) => {
export const linkToAssetTableWithTagFilter = (tag: DefinitionTag) => {
return `/assets?${qs.stringify({
tags: JSON.stringify([tag]),
})}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isEqual from 'lodash/isEqual';
import memoize from 'lodash/memoize';
import {useMemo} from 'react';

Expand Down Expand Up @@ -72,8 +73,9 @@ export function useAssetTagsForAssets(
export function doesFilterArrayMatchValueArray<T, V>(
filterArray: T[],
valueArray: V[],
isMatch: (value1: T, value2: V) => boolean = (val1, val2) =>
JSON.stringify(val1) === JSON.stringify(val2),
isMatch: (value1: T, value2: V) => boolean = (val1, val2) => {
return isEqual(val1, val2);
},
) {
if (filterArray.length && !valueArray.length) {
return false;
Expand Down
5 changes: 0 additions & 5 deletions js_modules/dagster-ui/packages/ui-core/src/ui/tagAsString.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
const TAG_NO_VALUE_SENTINEL = '__dagster_no_value';

export type Tag = {
key: string;
value: string;
};

export const buildTagString = ({key, value}: {key: string; value: string}) => {
if (value === TAG_NO_VALUE_SENTINEL) {
return key;
Expand Down

1 comment on commit ebf073f

@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-r42orgger-elementl.vercel.app

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

Please sign in to comment.