From 4ca20dff9e86fc5d006f1793b46dfd9a5da32629 Mon Sep 17 00:00:00 2001 From: Marco polo Date: Thu, 25 Apr 2024 11:02:59 -0400 Subject: [PATCH] Fix defaultState for Asset Filters (#21420) ## 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 7daaee7a93e59db5de19ffeef5a29ca134c022c2) --- .../asset-graph/AssetGraphExplorerFilters.tsx | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/asset-graph/AssetGraphExplorerFilters.tsx b/js_modules/dagster-ui/packages/ui-core/src/asset-graph/AssetGraphExplorerFilters.tsx index 20173f91049cc..39b0a6bde6632 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/asset-graph/AssetGraphExplorerFilters.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/asset-graph/AssetGraphExplorerFilters.tsx @@ -27,8 +27,25 @@ type Props = { loading: boolean; }; -const defaultState = {filters: {selectAllFilters: [] as string[]}} as Partial & { - filters: Partial; +const defaultState: AssetFilterState = { + filters: { + changedInBranch: [], + computeKindTags: [], + groups: [], + owners: [], + repos: [], + selectAllFilters: [], + tags: [], + }, + setAssetTags: () => {}, + setChangedInBranch: () => {}, + setComputeKindTags: () => {}, + setFilters: () => {}, + setGroups: () => {}, + setOwners: () => {}, + setRepos: () => {}, + setSelectAllFilters: () => {}, + filterFn: () => true, }; export function useAssetGraphExplorerFilters({ @@ -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});