-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dinika Saxena <[email protected]>
- Loading branch information
Showing
3 changed files
with
95 additions
and
38 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
src/components/VirtualLab/Bookmarks/ExperimentBookmarks.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 { useAtom } from 'jotai'; | ||
|
||
import { useEffect, useState } from 'react'; | ||
import ExploreSectionTable from '@/components/explore-section/ExploreSectionListingView/ExploreSectionTable'; | ||
import WithControlPanel from '@/components/explore-section/ExploreSectionListingView/WithControlPanel'; | ||
import { DataType } from '@/constants/explore-section/list-views'; | ||
import useExploreColumns from '@/hooks/useExploreColumns'; | ||
import { sortStateAtom } from '@/state/explore-section/list-view-atoms'; | ||
import { ExploreESHit, ExploreResource } from '@/types/explore-section/es'; | ||
import FilterControls from '@/components/explore-section/ExploreSectionListingView/FilterControls'; | ||
import ListingScrollNavControl from '@/components/explore-section/ExploreSectionListingView/ListingScrollNavControl'; | ||
import { fetchESResourceByIds } from '@/api/explore-section/resources'; | ||
import { esQueryById } from '@/queries/explore-section/data'; | ||
|
||
type Props = { | ||
dataType: DataType; | ||
resourceIds: string[]; | ||
accessToken: string; | ||
}; | ||
|
||
export default function ExperimentBookmarks({ dataType, resourceIds, accessToken }: Props) { | ||
const [sortState, setSortState] = useAtom(sortStateAtom); | ||
const [bookmarkedExperimentResources, setBookmarkedExperimentResources] = | ||
useState<ExploreESHit<ExploreResource>[]>(); | ||
const columns = useExploreColumns(setSortState, sortState, [], null, dataType); | ||
|
||
useEffect(() => { | ||
fetchESResourceByIds(accessToken, esQueryById(resourceIds)).then((experimentResources) => { | ||
setBookmarkedExperimentResources(experimentResources); | ||
}); | ||
}, [resourceIds, accessToken]); | ||
|
||
return ( | ||
<div className="h-full bg-[#d1d1d1]" data-testid="explore-section-listing-view"> | ||
<div className="grid h-full max-h-[calc(100vh-3.3rem)] w-full grid-cols-[auto_max-content] grid-rows-1 overflow-x-auto overflow-y-hidden"> | ||
<WithControlPanel dataType={dataType} brainRegionSource="selected"> | ||
{({ activeColumns, displayControlPanel, setDisplayControlPanel, filters }) => ( | ||
<> | ||
<FilterControls | ||
filters={filters} | ||
displayControlPanel={displayControlPanel} | ||
dataType={dataType} | ||
setDisplayControlPanel={setDisplayControlPanel} | ||
className="sticky top-0 !max-h-24 px-4 py-5" | ||
> | ||
<div className="text-primary-8"> | ||
Results <span className="font-bold">{bookmarkedExperimentResources?.length}</span> | ||
</div> | ||
</FilterControls> | ||
<ExploreSectionTable | ||
columns={columns.filter(({ key }) => (activeColumns || []).includes(key as string))} | ||
dataSource={bookmarkedExperimentResources} | ||
enableDownload | ||
dataType={dataType} | ||
brainRegionSource="selected" | ||
loading={false} | ||
/> | ||
<ListingScrollNavControl<HTMLDivElement> | ||
extraRightSpace={displayControlPanel ? 480 : 0} | ||
extraLeftSpace={12} | ||
show | ||
element={ | ||
typeof document !== 'undefined' | ||
? (document.querySelector('.ant-table-body') as HTMLDivElement) | ||
: undefined | ||
} | ||
/> | ||
</> | ||
)} | ||
</WithControlPanel> | ||
</div> | ||
</div> | ||
); | ||
} |