Skip to content

Commit

Permalink
[ui] Remove storage kind filter in preparation for consolidation
Browse files Browse the repository at this point in the history
  • Loading branch information
benpankow committed Aug 22, 2024
1 parent dc901b6 commit 93eab68
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,15 @@ export function useAssetGraphExplorerFilters({
loading,
clearExplorerPath,
}: Props) {
const {
filterButton,
computeKindFilter,
storageKindFilter,
groupsFilter,
activeFiltersJsx,
filterFn,
} = useAssetCatalogFiltering({
assets: nodes,
includeRepos: isGlobalGraph,
loading,
});
const {filterButton, computeKindFilter, groupsFilter, activeFiltersJsx, filterFn} =
useAssetCatalogFiltering({
assets: nodes,
includeRepos: isGlobalGraph,
loading,
});

return {
computeKindTagsFilter: computeKindFilter,
storageKindTagsFilter: storageKindFilter,
groupsFilter,
button: filterButton,
filterFn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {AssetViewType} from './useAssetView';
import {CloudOSSContext} from '../app/CloudOSSContext';
import {useUnscopedPermissions} from '../app/Permissions';
import {QueryRefreshCountdown, RefreshState} from '../app/QueryRefresh';
import {DefinitionTag} from '../graphql/types';
import {useSelectionReducer} from '../hooks/useSelectionReducer';
import {testId} from '../testing/testId';
import {StaticSetFilter} from '../ui/BaseFilters/useStaticSetFilter';
Expand All @@ -41,7 +40,6 @@ interface Props {
searchPath: string;
isFiltered: boolean;
computeKindFilter?: StaticSetFilter<string>;
storageKindFilter?: StaticSetFilter<DefinitionTag>;
}

export const AssetTable = ({
Expand All @@ -55,7 +53,6 @@ export const AssetTable = ({
isFiltered,
view,
computeKindFilter,
storageKindFilter,
}: Props) => {
const groupedByDisplayKey = useMemo(
() => groupBy(assets, (a) => JSON.stringify(displayPathForAsset(a))),
Expand Down Expand Up @@ -141,7 +138,6 @@ export const AssetTable = ({
showRepoColumn
view={view}
computeKindFilter={computeKindFilter}
storageKindFilter={storageKindFilter}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ export const AssetsCatalogTable = ({
filterButton,
activeFiltersJsx,
computeKindFilter,
storageKindFilter,
} = useAssetCatalogFiltering({assets});

const {searchPath, filterInput, filtered} = useBasicAssetSearchInput(
Expand Down Expand Up @@ -286,7 +285,6 @@ export const AssetsCatalogTable = ({
searchPath={searchPath}
displayPathForAsset={displayPathForAsset}
computeKindFilter={computeKindFilter}
storageKindFilter={storageKindFilter}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {

import {useAssetGroupSelectorsForAssets} from './AssetGroupSuggest';
import {CloudOSSContext} from '../app/CloudOSSContext';
import {isCanonicalStorageKindTag} from '../graph/KindTags';
import {ChangeReason} from '../graphql/types';
import {useFilters} from '../ui/BaseFilters';
import {FilterObject} from '../ui/BaseFilters/useFilter';
Expand All @@ -20,7 +19,6 @@ import {
useAssetKindTagsForAssets,
useComputeKindTagFilter,
} from '../ui/Filters/useComputeKindTagFilter';
import {useStorageKindFilter} from '../ui/Filters/useStorageKindFilter';
import {WorkspaceContext} from '../workspace/WorkspaceContext';
import {buildRepoAddress} from '../workspace/buildRepoAddress';

Expand Down Expand Up @@ -53,7 +51,6 @@ export function useAssetCatalogFiltering<
setGroups,
setOwners,
setCodeLocations,
setStorageKindTags,
setSelectAllFilters,
} = useAssetDefinitionFilterState({isEnabled});

Expand Down Expand Up @@ -88,24 +85,12 @@ export function useAssetCatalogFiltering<
});

const tags = useAssetTagsForAssets(assets);
const storageKindTags = useMemo(() => tags.filter(isCanonicalStorageKindTag), [tags]);
const nonStorageKindTags = useMemo(
() => tags.filter((tag) => !isCanonicalStorageKindTag(tag)),
[tags],
);

const tagsFilter = useAssetTagFilter({
allAssetTags: nonStorageKindTags,
tags: filters.selectAllFilters.includes('tags') ? nonStorageKindTags : filters.tags,
allAssetTags: tags,
tags: filters.selectAllFilters.includes('tags') ? tags : filters.tags,
setTags: setAssetTags,
});
const storageKindFilter = useStorageKindFilter({
allAssetStorageKindTags: storageKindTags,
storageKindTags: filters.selectAllFilters.includes('storageKindTags')
? storageKindTags
: filters.storageKindTags,
setStorageKindTags,
});

const {isBranchDeployment} = React.useContext(CloudOSSContext);
const {allRepos} = React.useContext(WorkspaceContext);
Expand All @@ -124,13 +109,7 @@ export function useAssetCatalogFiltering<
});

const uiFilters = React.useMemo(() => {
const uiFilters: FilterObject[] = [
groupsFilter,
computeKindFilter,
storageKindFilter,
ownersFilter,
tagsFilter,
];
const uiFilters: FilterObject[] = [groupsFilter, computeKindFilter, ownersFilter, tagsFilter];
if (isBranchDeployment) {
uiFilters.push(changedInBranchFilter);
}
Expand All @@ -147,7 +126,6 @@ export function useAssetCatalogFiltering<
isBranchDeployment,
ownersFilter,
reposFilter,
storageKindFilter,
tagsFilter,
]);
const components = useFilters({filters: uiFilters});
Expand Down Expand Up @@ -176,9 +154,8 @@ export function useAssetCatalogFiltering<

[
['owners', filters.owners, allAssetOwners] as const,
['tags', filters.tags, nonStorageKindTags] as const,
['tags', filters.tags, tags] as const,
['computeKindTags', filters.computeKindTags, allComputeKindTags] as const,
['storageKindTags', filters.storageKindTags, storageKindTags] as const,
['groups', filters.groups, allAssetGroupOptions] as const,
['changedInBranch', filters.changedInBranch, Object.values(ChangeReason)] as const,
['codeLocations', filters.codeLocations, allRepos] as const,
Expand Down Expand Up @@ -210,9 +187,8 @@ export function useAssetCatalogFiltering<
didWaitAfterLoading,
filters,
loading,
nonStorageKindTags,
tags,
setSelectAllFilters,
storageKindTags,
isEnabled,
]);

Expand All @@ -228,7 +204,6 @@ export function useAssetCatalogFiltering<
filterFn,
filtered,
computeKindFilter,
storageKindFilter,
groupsFilter,
renderFilterButton: components.renderButton,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import isEqual from 'lodash/isEqual';
import {SetStateAction, useCallback, useMemo} from 'react';

import {buildAssetGroupSelector} from './AssetGroupSuggest';
import {isCanonicalStorageKindTag} from '../graph/KindTags';
import {
AssetGroupSelector,
AssetNode,
Expand Down Expand Up @@ -32,7 +31,6 @@ export type FilterableAssetDefinition = Nullable<
export type AssetFilterBaseType = {
groups: AssetGroupSelector[];
computeKindTags: string[];
storageKindTags: DefinitionTag[];
changedInBranch: ChangeReason[];
owners: AssetOwner[];
tags: DefinitionTag[];
Expand All @@ -49,7 +47,6 @@ export const useAssetDefinitionFilterState = ({isEnabled = true}: {isEnabled?: b
? ({
groups,
computeKindTags,
storageKindTags,
changedInBranch,
owners,
tags,
Expand All @@ -58,7 +55,6 @@ export const useAssetDefinitionFilterState = ({isEnabled = true}: {isEnabled?: b
}) => ({
groups: groups?.length ? JSON.stringify(groups) : undefined,
computeKindTags: computeKindTags?.length ? JSON.stringify(computeKindTags) : undefined,
storageKindTags: storageKindTags?.length ? JSON.stringify(storageKindTags) : undefined,
changedInBranch: changedInBranch?.length ? JSON.stringify(changedInBranch) : undefined,
owners: owners?.length ? JSON.stringify(owners) : undefined,
tags: tags?.length ? JSON.stringify(tags) : undefined,
Expand All @@ -69,7 +65,6 @@ export const useAssetDefinitionFilterState = ({isEnabled = true}: {isEnabled?: b
decode: (qs) => ({
groups: qs.groups && isEnabled ? JSON.parse(qs.groups) : [],
computeKindTags: qs.computeKindTags && isEnabled ? JSON.parse(qs.computeKindTags) : [],
storageKindTags: qs.storageKindTags && isEnabled ? JSON.parse(qs.storageKindTags) : [],
changedInBranch: qs.changedInBranch && isEnabled ? JSON.parse(qs.changedInBranch) : [],
owners: qs.owners && isEnabled ? JSON.parse(qs.owners) : [],
tags: qs.tags && isEnabled ? JSON.parse(qs.tags) : [],
Expand All @@ -90,7 +85,6 @@ export const useAssetDefinitionFilterState = ({isEnabled = true}: {isEnabled?: b

const {
setComputeKindTags,
setStorageKindTags,
setGroups,
setChangedInBranch,
setOwners,
Expand All @@ -108,7 +102,6 @@ export const useAssetDefinitionFilterState = ({isEnabled = true}: {isEnabled?: b
}
return {
setComputeKindTags: makeSetter('computeKindTags'),
setStorageKindTags: makeSetter('storageKindTags'),
setGroups: makeSetter('groups'),
setChangedInBranch: makeSetter('changedInBranch'),
setOwners: makeSetter('owners'),
Expand All @@ -123,7 +116,6 @@ export const useAssetDefinitionFilterState = ({isEnabled = true}: {isEnabled?: b
setFilters,
filterFn,
setComputeKindTags,
setStorageKindTags,
setGroups,
setChangedInBranch,
setOwners,
Expand Down Expand Up @@ -196,21 +188,6 @@ export function filterAssetDefinition(
}
}

const isAllStorageKindTagsSelected = filters.selectAllFilters?.includes('storageKindTags');
const storageKindTag = definition?.tags?.find(isCanonicalStorageKindTag);
if (isAllStorageKindTagsSelected) {
if (!storageKindTag) {
return false;
}
} else if (filters.storageKindTags?.length) {
if (
!storageKindTag ||
!doesFilterArrayMatchValueArray(filters.storageKindTags, [storageKindTag])
) {
return false;
}
}

const isAllChangedInBranchSelected = filters.selectAllFilters?.includes('changedInBranch');
if (isAllChangedInBranchSelected) {
if (!definition?.changedReasons?.length) {
Expand Down

This file was deleted.

21 changes: 9 additions & 12 deletions js_modules/dagster-ui/packages/ui-core/src/ui/Filters/util.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
import {BaseConfig as AssetGroupsFilterBaseConfig} from './useAssetGroupFilter';
import {BaseConfig as AssetOwnerFilterBaseConfig} from './useAssetOwnerFilter';
import {BaseConfig as AssetTagFilterBaseConfig} from './useAssetTagFilter';
import {BaseConfig as ChangedFilterBaseConfig} from './useChangedFilter';
import {BaseConfig as CodeLocationFilterBaseConfig} from './useCodeLocationFilter';
import {BaseConfig as ComputeKindTagFilterBaseConfig} from './useComputeKindTagFilter';
import {BaseConfig as StorageKindFilterBaseConfig} from './useStorageKindFilter';
import {AssetGroupSelector, AssetOwner, ChangeReason, DefinitionTag} from '../../graphql/types';
import {RepoAddress} from '../../workspace/types';
import {StaticBaseConfig} from '../BaseFilters/useStaticSetFilter';
import { BaseConfig as AssetGroupsFilterBaseConfig } from './useAssetGroupFilter';
import { BaseConfig as AssetOwnerFilterBaseConfig } from './useAssetOwnerFilter';
import { BaseConfig as AssetTagFilterBaseConfig } from './useAssetTagFilter';
import { BaseConfig as ChangedFilterBaseConfig } from './useChangedFilter';
import { BaseConfig as CodeLocationFilterBaseConfig } from './useCodeLocationFilter';
import { BaseConfig as ComputeKindTagFilterBaseConfig } from './useComputeKindTagFilter';
import { AssetGroupSelector, AssetOwner, ChangeReason, DefinitionTag } from '../../graphql/types';
import { RepoAddress } from '../../workspace/types';
import { StaticBaseConfig } from '../BaseFilters/useStaticSetFilter';

export const STATIC_FILTER_CONFIGS: {
groups: StaticBaseConfig<AssetGroupSelector>;
computeKindTags: StaticBaseConfig<string>;
storageKindTags: StaticBaseConfig<DefinitionTag>;
changedInBranch: StaticBaseConfig<ChangeReason>;
owners: StaticBaseConfig<AssetOwner>;
tags: StaticBaseConfig<DefinitionTag>;
codeLocations: StaticBaseConfig<RepoAddress>;
} = {
groups: AssetGroupsFilterBaseConfig,
computeKindTags: ComputeKindTagFilterBaseConfig,
storageKindTags: StorageKindFilterBaseConfig,
changedInBranch: ChangedFilterBaseConfig,
owners: AssetOwnerFilterBaseConfig,
tags: AssetTagFilterBaseConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
AssetStorageKindTag,
isCanonicalStorageKindTag,
} from '../graph/KindTags';
import {AssetKeyInput, DefinitionTag} from '../graphql/types';
import {AssetKeyInput} from '../graphql/types';
import {RepositoryLink} from '../nav/RepositoryLink';
import {useBlockTraceOnQueryResult} from '../performance/TraceContext';
import {TimestampDisplay} from '../schedules/TimestampDisplay';
Expand All @@ -52,7 +52,6 @@ interface AssetRowProps {
start: number;
onRefresh: () => void;
computeKindFilter?: StaticSetFilter<string>;
storageKindFilter?: StaticSetFilter<DefinitionTag>;
}

export const VirtualizedAssetRow = (props: AssetRowProps) => {
Expand All @@ -70,7 +69,6 @@ export const VirtualizedAssetRow = (props: AssetRowProps) => {
showRepoColumn,
view = 'flat',
computeKindFilter,
storageKindFilter,
} = props;

const liveData = useLiveDataOrLatestMaterializationDebounced(path, type);
Expand Down Expand Up @@ -126,7 +124,6 @@ export const VirtualizedAssetRow = (props: AssetRowProps) => {
reduceText
storageKind={storageKindTag.value}
style={{position: 'relative'}}
currentPageFilter={storageKindFilter}
/>
)}
</Box>
Expand Down
Loading

0 comments on commit 93eab68

Please sign in to comment.