-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: deposition filter banner (#1040)
#925 - deposition ID query parameter: `deposition-id` - prop `banner?: ReactNode` to render banner at the top of `<TablePageLayout />` - implements deposition banner component and renders at top of dataset or run pages ## Demos https://dev-depo-filter-banner.cryoet.dev.si.czi.technology/ ### Dataset Page <img width="1728" alt="image" src="https://github.com/user-attachments/assets/f5ab5f2f-fb44-4cbd-a67a-5a9033937eee"> ### Run Page <img width="1728" alt="image" src="https://github.com/user-attachments/assets/c6707c90-bc51-4b31-a2a1-711707bd65e8">
- Loading branch information
1 parent
427c97d
commit bb83312
Showing
21 changed files
with
327 additions
and
34 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
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.