-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: deposition filter banner #1040
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4752a10
I18n dash component
codemonkey800 8d04c6d
i18n
codemonkey800 6fa0dc9
deposition id query param
codemonkey800 a9306c7
prop to render banner in TablePageLayout
codemonkey800 4060fce
util to maybe add deposition id filter
codemonkey800 0e5decb
deposition filter banner component
codemonkey800 ccd5363
update queries to get deposition by id
codemonkey800 918c6b7
add deposition id param to urls
codemonkey800 3cfc831
render deposition banner if filter is enabled
codemonkey800 d0b7a6d
refactor carry over util
codemonkey800 570e109
extract dash class names to util
codemonkey800 e06edba
use dash util class names
codemonkey800 07d3971
use query function default
codemonkey800 a888eac
fix banner height
codemonkey800 b70429f
change to url
codemonkey800 1fe8625
fix remove button not working
codemonkey800 26db8ab
deposition filters array
codemonkey800 0167051
carry back behavior
codemonkey800 02b04c3
fix carry over deposition id filter
codemonkey800 847f91d
add deposition id to breadcrumbs link
codemonkey800 f6c5e54
remove deposition id from history if clearing filter
codemonkey800 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
63 changes: 63 additions & 0 deletions
63
frontend/packages/data-portal/app/components/DepositionFilterBanner.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,63 @@ | ||
import { Button, Callout } from '@czi-sds/components' | ||
|
||
import { I18n } from 'app/components/I18n' | ||
import { QueryParams } from 'app/constants/query' | ||
import { useQueryParam } from 'app/hooks/useQueryParam' | ||
import { | ||
useDepositionHistory, | ||
useSingleDatasetFilterHistory, | ||
} from 'app/state/filterHistory' | ||
import { I18nKeys } from 'app/types/i18n' | ||
|
||
interface Deposition { | ||
id: number | ||
title: string | ||
} | ||
|
||
export function DepositionFilterBanner({ | ||
deposition, | ||
labelI18n, | ||
}: { | ||
deposition: Deposition | ||
labelI18n: I18nKeys | ||
}) { | ||
const { singleDatasetHistory, setSingleDatasetHistory } = | ||
useSingleDatasetFilterHistory() | ||
const { previousSingleDepositionParams } = useDepositionHistory() | ||
const [, setDepositionId] = useQueryParam<string>(QueryParams.DepositionId) | ||
|
||
return ( | ||
<Callout | ||
className="!w-full !mx-sds-xl" | ||
classes={{ message: 'w-full' }} | ||
intent="info" | ||
> | ||
<div className="flex w-full items-center justify-between"> | ||
<p className="text-sds-body-xs leading-sds-body-xs"> | ||
<I18n | ||
i18nKey={labelI18n} | ||
values={{ | ||
...deposition, | ||
url: `/depositions/${deposition.id}${previousSingleDepositionParams}`, | ||
}} | ||
tOptions={{ interpolation: { escapeValue: false } }} | ||
/> | ||
</p> | ||
|
||
<Button | ||
onClick={() => { | ||
setDepositionId(null) | ||
|
||
const nextHistory = new Map(singleDatasetHistory) | ||
nextHistory.delete(QueryParams.DepositionId) | ||
setSingleDatasetHistory(nextHistory) | ||
}} | ||
sdsStyle="minimal" | ||
sdsType="secondary" | ||
> | ||
Remove Filter | ||
</Button> | ||
</div> | ||
</Callout> | ||
) | ||
} |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit - since we're only using the path and the query params, do we need
createUrl()
? what ifcarryOverFilterParams()
just returned a newURLSearchParams
and we didreturn `/runs/${id}\` + urlSearchParams.toString()
?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.
I tend to prefer modifying the
URL
andURLSearchParams
objects directly to avoid direct string concatenation, socreateUrl()
is helpful here since we're only using the pathname and params