-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(structure): add sheet list table view. (#6647)
* feat(structure): add virtualised documentSheetList and sheetListStore * feat(core): add useEditStateList hook * feat(sheet-list): add table view * feat(sheet-list): add paginated sheet list view * feat(structure): clean files and implement paginated sheet list with filter * fix(core): remove useEditStateList hook * chore(core): refactor search elements for export and reusability * fix(structure): update documentSheetList test * chore(structure): rename useDocumentSheetListStore properties * chore(structure): rename documentSheet* to documentSheetList*
- Loading branch information
1 parent
77785ff
commit c5916d4
Showing
15 changed files
with
765 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
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
2 changes: 2 additions & 0 deletions
2
packages/sanity/src/core/studio/components/navbar/search/components/index.ts
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export * from './filters/Filters' | ||
export * from './SearchHeader' | ||
export * from './SearchPopover' | ||
export * from './searchResults' |
20 changes: 20 additions & 0 deletions
20
packages/sanity/src/structure/panes/documentList/DocumentSheetListFilter.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,20 @@ | ||
import {Flex} from '@sanity/ui' | ||
import {Filters, SearchHeader, useSearchState} from 'sanity' | ||
import {styled} from 'styled-components' | ||
|
||
const SearchContainer = styled(Flex)` | ||
flex-shrink: 0; | ||
` | ||
|
||
export function DocumentSheetListFilter() { | ||
const { | ||
state: {filtersVisible}, | ||
} = useSearchState() | ||
|
||
return ( | ||
<SearchContainer> | ||
<SearchHeader /> | ||
{filtersVisible && <Filters showTypeFilter={false} />} | ||
</SearchContainer> | ||
) | ||
} |
71 changes: 71 additions & 0 deletions
71
packages/sanity/src/structure/panes/documentList/DocumentSheetListPaginator.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,71 @@ | ||
/* eslint-disable i18next/no-literal-string */ | ||
/* eslint-disable @sanity/i18n/no-attribute-string-literals */ | ||
/* eslint-disable react/jsx-no-bind */ | ||
import { | ||
ChevronLeftIcon, | ||
ChevronRightIcon, | ||
DoubleChevronLeftIcon, | ||
DoubleChevronRightIcon, | ||
} from '@sanity/icons' | ||
import {Flex, Text} from '@sanity/ui' | ||
import {type Table} from '@tanstack/react-table' | ||
import {type SanityDocument} from 'sanity' | ||
|
||
import {Button, TooltipDelayGroupProvider} from '../../../ui-components' | ||
|
||
export function DocumentSheetListPaginator({table}: {table: Table<SanityDocument>}) { | ||
return ( | ||
<TooltipDelayGroupProvider> | ||
<Flex gap={3} align={'center'}> | ||
<Button | ||
onClick={() => table.setPageIndex(0)} | ||
disabled={!table.getCanPreviousPage()} | ||
icon={DoubleChevronLeftIcon} | ||
tooltipProps={{ | ||
content: 'Go to first page', | ||
}} | ||
/> | ||
<Button | ||
onClick={() => table.previousPage()} | ||
disabled={!table.getCanPreviousPage()} | ||
icon={ChevronLeftIcon} | ||
tooltipProps={{ | ||
content: 'Go to previous page', | ||
}} | ||
/> | ||
<Text style={{whiteSpace: 'nowrap'}}> | ||
{table.getState().pagination.pageIndex + 1} of {table.getPageCount()} | ||
</Text> | ||
|
||
<Button | ||
onClick={() => table.nextPage()} | ||
disabled={!table.getCanNextPage()} | ||
icon={ChevronRightIcon} | ||
tooltipProps={{ | ||
content: 'Go to next page', | ||
}} | ||
/> | ||
<Button | ||
onClick={() => table.setPageIndex(table.getPageCount() - 1)} | ||
disabled={!table.getCanNextPage()} | ||
icon={DoubleChevronRightIcon} | ||
tooltipProps={{ | ||
content: 'Go to last page', | ||
}} | ||
/> | ||
<select | ||
value={table.getState().pagination.pageSize} | ||
onChange={(e) => { | ||
table.setPageSize(Number(e.target.value)) | ||
}} | ||
> | ||
{[25, 50, 100].map((pageSize) => ( | ||
<option key={pageSize} value={pageSize}> | ||
{pageSize} | ||
</option> | ||
))} | ||
</select> | ||
</Flex> | ||
</TooltipDelayGroupProvider> | ||
) | ||
} |
Oops, something went wrong.