Skip to content

Commit

Permalink
[ui] Replace compute kind, storage kind filters + tags with generic kind
Browse files Browse the repository at this point in the history
  • Loading branch information
benpankow committed Aug 22, 2024
1 parent fac926c commit 79e7389
Show file tree
Hide file tree
Showing 27 changed files with 279 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,24 @@ export const AssetGraphExplorer = (props: Props) => {

const {explorerPath, onChangeExplorerPath} = props;

const {button, filterBar, groupsFilter, computeKindTagsFilter, filterFn} =
useAssetGraphExplorerFilters({
nodes: React.useMemo(
() => (fullAssetGraphData ? Object.values(fullAssetGraphData.nodes) : []),
[fullAssetGraphData],
),
loading: fetchResult.loading,
isGlobalGraph: !!props.isGlobalGraph,
explorerPath: explorerPath.opsQuery,
clearExplorerPath: React.useCallback(() => {
onChangeExplorerPath(
{
...explorerPath,
opsQuery: '',
},
'push',
);
}, [explorerPath, onChangeExplorerPath]),
});
const {button, filterBar, groupsFilter, kindFilter, filterFn} = useAssetGraphExplorerFilters({
nodes: React.useMemo(
() => (fullAssetGraphData ? Object.values(fullAssetGraphData.nodes) : []),
[fullAssetGraphData],
),
loading: fetchResult.loading,
isGlobalGraph: !!props.isGlobalGraph,
explorerPath: explorerPath.opsQuery,
clearExplorerPath: React.useCallback(() => {
onChangeExplorerPath(
{
...explorerPath,
opsQuery: '',
},
'push',
);
}, [explorerPath, onChangeExplorerPath]),
});

useEffect(() => {
setHideNodesMatching(() => (node: AssetNodeForGraphQueryFragment) => !filterFn(node));
Expand Down Expand Up @@ -152,7 +151,7 @@ export const AssetGraphExplorer = (props: Props) => {
graphQueryItems={graphQueryItems}
filterBar={filterBar}
filterButton={button}
computeKindTagsFilter={computeKindTagsFilter}
kindFilter={kindFilter}
groupsFilter={groupsFilter}
{...props}
/>
Expand All @@ -172,7 +171,7 @@ type WithDataProps = Props & {
filterBar: React.ReactNode;
isGlobalGraph?: boolean;

computeKindTagsFilter: StaticSetFilter<string>;
kindFilter: StaticSetFilter<string>;
groupsFilter: StaticSetFilter<AssetGroupSelector>;
};

Expand All @@ -190,7 +189,7 @@ const AssetGraphExplorerWithData = ({
filterButton,
filterBar,
isGlobalGraph = false,
computeKindTagsFilter,
kindFilter,
groupsFilter,
}: WithDataProps) => {
const findAssetLocation = useFindAssetLocation();
Expand Down Expand Up @@ -626,7 +625,7 @@ const AssetGraphExplorerWithData = ({
<AssetNode
definition={graphNode.definition}
selected={selectedGraphNodes.includes(graphNode)}
computeKindTagsFilter={computeKindTagsFilter}
kindFilter={kindFilter}
/>
</AssetNodeContextMenuWrapper>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ import {ChangedReasonsTag, MinimalNodeChangedDot} from '../assets/ChangedReasons
import {MinimalNodeStaleDot, StaleReasonsTag, isAssetStale} from '../assets/Stale';
import {AssetChecksStatusSummary} from '../assets/asset-checks/AssetChecksStatusSummary';
import {assetDetailsPathForKey} from '../assets/assetDetailsPathForKey';
import {AssetComputeKindTag} from '../graph/KindTags';
import {AssetKind} from '../graph/KindTags';
import {StaticSetFilter} from '../ui/BaseFilters/useStaticSetFilter';
import {markdownToPlaintext} from '../ui/markdownToPlaintext';

interface Props {
definition: AssetNodeFragment;
selected: boolean;
computeKindTagsFilter?: StaticSetFilter<string>;
kindFilter?: StaticSetFilter<string>;
}

export const AssetNode = React.memo(({definition, selected, computeKindTagsFilter}: Props) => {
export const AssetNode = React.memo(({definition, selected, kindFilter}: Props) => {
const {liveData} = useAssetLiveData(definition.assetKey);
return (
<AssetInsetForHoverEffect>
Expand Down Expand Up @@ -64,11 +63,14 @@ export const AssetNode = React.memo(({definition, selected, computeKindTagsFilte
)}
</AssetNodeBox>
<Box flex={{direction: 'row-reverse', gap: 8}}>
<AssetComputeKindTag
definition={definition}
style={{position: 'relative', paddingTop: 7, margin: 0}}
currentPageFilter={computeKindTagsFilter}
/>
{definition.kinds.map((kind) => (
<AssetKind
key={kind}
kind={kind}
style={{position: 'relative', paddingTop: 7, margin: 0}}
currentPageFilter={kindFilter}
/>
))}
</Box>
</AssetNodeContainer>
</AssetInsetForHoverEffect>
Expand Down Expand Up @@ -260,6 +262,7 @@ export const ASSET_NODE_FRAGMENT = gql`
key
value
}
kinds
}
fragment AssetNodeKey on AssetKey {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export function useAssetGraphExplorerFilters({
loading,
clearExplorerPath,
}: Props) {
const {filterButton, computeKindFilter, groupsFilter, activeFiltersJsx, filterFn} =
const {filterButton, groupsFilter, activeFiltersJsx, kindFilter, filterFn} =
useAssetCatalogFiltering({
assets: nodes,
includeRepos: isGlobalGraph,
loading,
});

return {
computeKindTagsFilter: computeKindFilter,
kindFilter,
groupsFilter,
button: filterButton,
filterFn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export const ASSET_NODE_DEFINITION_FRAGMENT = gql`
key
value
}
kinds
owners {
... on TeamAssetOwner {
team
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface Props {
displayPathForAsset: (asset: Asset) => string[];
searchPath: string;
isFiltered: boolean;
computeKindFilter?: StaticSetFilter<string>;
kindFilter?: StaticSetFilter<string>;
}

export const AssetTable = ({
Expand All @@ -52,7 +52,7 @@ export const AssetTable = ({
searchPath,
isFiltered,
view,
computeKindFilter,
kindFilter,
}: Props) => {
const groupedByDisplayKey = useMemo(
() => groupBy(assets, (a) => JSON.stringify(displayPathForAsset(a))),
Expand Down Expand Up @@ -137,7 +137,7 @@ export const AssetTable = ({
onRefresh={() => refreshState.refetch()}
showRepoColumn
view={view}
computeKindFilter={computeKindFilter}
kindFilter={kindFilter}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const ASSET_TABLE_DEFINITION_FRAGMENT = gql`
key
value
}
kinds
repository {
id
name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export const AssetsCatalogTable = ({
isFiltered,
filterButton,
activeFiltersJsx,
computeKindFilter,
kindFilter,
} = useAssetCatalogFiltering({assets});

const {searchPath, filterInput, filtered} = useBasicAssetSearchInput(
Expand Down Expand Up @@ -284,7 +284,7 @@ export const AssetsCatalogTable = ({
prefixPath={prefixPath || emptyArray}
searchPath={searchPath}
displayPathForAsset={displayPathForAsset}
computeKindFilter={computeKindFilter}
kindFilter={kindFilter}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,32 @@ describe('filterAssetDefinition', () => {
expect(filterAssetDefinition(filters, definition)).toBe(false);
});

it('returns false when computeKindTags filter does not match the definition', () => {
it('returns false when kinds filter does not match the definition', () => {
const filters = {
computeKindTags: ['computeKind2'],
kinds: ['computeKind2'],
};
const definition = {
computeKind: 'computeKind1',
kinds: ['computeKind1'],
};
expect(filterAssetDefinition(filters, definition)).toBe(false);
});

it('returns true when kinds filter does match the definition', () => {
const filters = {
kinds: ['computeKind1'],
};
const definition = {
kinds: ['computeKind1', 'computeKind2'],
};
expect(filterAssetDefinition(filters, definition)).toBe(true);
});

it('returns false when kinds filter overspecifies the definition', () => {
const filters = {
kinds: ['computeKind1', 'computeKind3'],
};
const definition = {
kinds: ['computeKind1'],
};
expect(filterAssetDefinition(filters, definition)).toBe(false);
});
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 79e7389

Please sign in to comment.