Skip to content

Commit

Permalink
Fix defaultState for Asset Filters (#21420)
Browse files Browse the repository at this point in the history
## Summary & Motivation

The default state was being fudged to avoid needing to specify every key
but this led to errors due to the type fudging. Lets just create the
proper default state.

## How I Tested These Changes

Proxied directly to prod to confirm it fixes the issue from
https://dagsterlabs.slack.com/archives/C06K1DMN81W/p1714055730157929

(cherry picked from commit 7daaee7)
  • Loading branch information
salazarm authored and jmsanders committed Apr 25, 2024
1 parent 9c28df5 commit 4ca20df
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,25 @@ type Props = {
loading: boolean;
};

const defaultState = {filters: {selectAllFilters: [] as string[]}} as Partial<AssetFilterState> & {
filters: Partial<AssetFilterState['filters']>;
const defaultState: AssetFilterState = {
filters: {
changedInBranch: [],
computeKindTags: [],
groups: [],
owners: [],
repos: [],
selectAllFilters: [],
tags: [],
},
setAssetTags: () => {},
setChangedInBranch: () => {},
setComputeKindTags: () => {},
setFilters: () => {},
setGroups: () => {},
setOwners: () => {},
setRepos: () => {},
setSelectAllFilters: () => {},
filterFn: () => true,
};

export function useAssetGraphExplorerFilters({
Expand All @@ -54,7 +71,7 @@ export function useAssetGraphExplorerFilters({
setSelectAllFilters,
} = assetFilterState || defaultState;

const reposFilter = useCodeLocationFilter(repos && setRepos ? {repos, setRepos} : undefined);
const reposFilter = useCodeLocationFilter(repos ? {repos, setRepos} : undefined);

const changedFilter = useChangedFilter({changedInBranch, setChangedInBranch});

Expand Down

0 comments on commit 4ca20df

Please sign in to comment.