-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix duplicate code location error toasts + Add status filter to code …
…locations page (#22540) ## Summary & Motivation Recent changes to the WorkspaceContext where we split fetched by location caused us show the code location error toast multiple times. Once for each code location update after we've detected an errored code location. The fix is to instead fire the effect off of the errored code locations and preserve the reference if they haven't changed. Also adding a "state" filter to the code locations page for use in the error toast so that if you have 132 locations you can easily see which ones failed. ## How I Tested These Changes Loaded an org with 132 code locations and saw a single error toast. Clicked on "view definitions" and saw it took me to the code location page with status = Failed as the filter. <img width="394" alt="Screenshot 2024-06-13 at 4 25 03 PM" src="https://github.com/dagster-io/dagster/assets/2286579/92fcadc6-f844-4cd9-a48c-100eec9aba42"> <img width="1724" alt="Screenshot 2024-06-13 at 4 24 53 PM" src="https://github.com/dagster-io/dagster/assets/2286579/fb000b48-d778-4d06-b339-8fc96816c9de">
- Loading branch information
Showing
5 changed files
with
208 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
js_modules/dagster-ui/packages/ui-core/src/instance/useCodeLocationPageFilters.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React, {useCallback, useContext, useMemo, useState} from 'react'; | ||
|
||
import {CodeLocationFilters, flattenCodeLocationRows} from './flattenCodeLocationRows'; | ||
import {useQueryPersistedState} from '../hooks/useQueryPersistedState'; | ||
import {TruncatedTextWithFullTextOnHover} from '../nav/getLeftNavItemsForOption'; | ||
import {useFilters} from '../ui/Filters'; | ||
import {useStaticSetFilter} from '../ui/Filters/useStaticSetFilter'; | ||
import {CodeLocationRowStatusType} from '../workspace/VirtualizedCodeLocationRow'; | ||
import {WorkspaceContext} from '../workspace/WorkspaceContext'; | ||
|
||
export const useCodeLocationPageFilters = () => { | ||
const {locationEntries, loading} = useContext(WorkspaceContext); | ||
|
||
const [searchValue, setSearchValue] = useState(''); | ||
|
||
const onChangeSearch = useCallback((e: React.ChangeEvent<HTMLInputElement>) => { | ||
setSearchValue(e.target.value); | ||
}, []); | ||
|
||
const queryString = searchValue.toLocaleLowerCase(); | ||
|
||
const [filters, setFilters] = useQueryPersistedState<CodeLocationFilters>({ | ||
encode: ({status}) => ({ | ||
status: status?.length ? JSON.stringify(status) : undefined, | ||
}), | ||
decode: (qs) => { | ||
return { | ||
status: qs.status ? JSON.parse(qs.status) : [], | ||
}; | ||
}, | ||
}); | ||
|
||
const {flattened, filtered} = useMemo(() => { | ||
return flattenCodeLocationRows(locationEntries, queryString, filters); | ||
}, [locationEntries, queryString, filters]); | ||
|
||
const statusFilter = useStaticSetFilter<CodeLocationRowStatusType>({ | ||
name: 'Status', | ||
icon: 'tag', | ||
allValues: useMemo( | ||
() => | ||
(['Failed', 'Loaded', 'Updating', 'Loading'] as const).map((value) => ({ | ||
key: value, | ||
value, | ||
match: [value], | ||
})), | ||
[], | ||
), | ||
menuWidth: '300px', | ||
renderLabel: ({value}) => { | ||
return <TruncatedTextWithFullTextOnHover text={value} />; | ||
}, | ||
getStringValue: (value) => value, | ||
state: filters.status, | ||
onStateChanged: (values) => { | ||
setFilters({status: Array.from(values)}); | ||
}, | ||
matchType: 'all-of', | ||
canSelectAll: false, | ||
allowMultipleSelections: true, | ||
}); | ||
|
||
const {button, activeFiltersJsx} = useFilters({filters: [statusFilter]}); | ||
|
||
return { | ||
button, | ||
activeFiltersJsx, | ||
onChangeSearch, | ||
loading, | ||
flattened, | ||
filtered, | ||
searchValue, | ||
}; | ||
}; |
Oops, something went wrong.
ababe1a
There was a problem hiding this comment.
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-9r5tru2w6-elementl.vercel.app
Built with commit ababe1a.
This pull request is being automatically deployed with vercel-action