mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
add search and filters
This commit is contained in:
parent
e53baaf718
commit
65c252a20c
@ -31,6 +31,7 @@ import useToast from '../../../hooks/useToast';
|
|||||||
import { formatUnknownError } from '../../../utils/formatUnknownError';
|
import { formatUnknownError } from '../../../utils/formatUnknownError';
|
||||||
import { useSearch } from '../../../hooks/useSearch';
|
import { useSearch } from '../../../hooks/useSearch';
|
||||||
import { FeatureArchivedCell } from '../../common/Table/cells/FeatureArchivedCell/FeatureArchivedCell';
|
import { FeatureArchivedCell } from '../../common/Table/cells/FeatureArchivedCell/FeatureArchivedCell';
|
||||||
|
import { useVirtualizedRange } from '../../../hooks/useVirtualizedRange';
|
||||||
|
|
||||||
export interface IFeaturesArchiveTableProps {
|
export interface IFeaturesArchiveTableProps {
|
||||||
archivedFeatures: FeatureSchema[];
|
archivedFeatures: FeatureSchema[];
|
||||||
@ -100,7 +101,7 @@ export const ArchiveTable = ({
|
|||||||
{
|
{
|
||||||
Header: 'Feature toggle Name',
|
Header: 'Feature toggle Name',
|
||||||
accessor: 'name',
|
accessor: 'name',
|
||||||
filterName: 'name',
|
searchable: true,
|
||||||
minWidth: 100,
|
minWidth: 100,
|
||||||
Cell: ({ value, row: { original } }: any) => (
|
Cell: ({ value, row: { original } }: any) => (
|
||||||
<HighlightCell
|
<HighlightCell
|
||||||
@ -128,6 +129,8 @@ export const ArchiveTable = ({
|
|||||||
Header: 'Project ID',
|
Header: 'Project ID',
|
||||||
accessor: 'project',
|
accessor: 'project',
|
||||||
sortType: 'alphanumeric',
|
sortType: 'alphanumeric',
|
||||||
|
filterName: 'project',
|
||||||
|
searchable: true,
|
||||||
maxWidth: 150,
|
maxWidth: 150,
|
||||||
Cell: ({ value }: any) => (
|
Cell: ({ value }: any) => (
|
||||||
<LinkCell title={value} to={`/projects/${value}}`} />
|
<LinkCell title={value} to={`/projects/${value}}`} />
|
||||||
@ -139,7 +142,8 @@ export const ArchiveTable = ({
|
|||||||
Cell: FeatureStaleCell,
|
Cell: FeatureStaleCell,
|
||||||
sortType: 'boolean',
|
sortType: 'boolean',
|
||||||
maxWidth: 120,
|
maxWidth: 120,
|
||||||
disableGlobalFilter: true,
|
filterName: 'state',
|
||||||
|
filterParsing: (value: any) => (value ? 'stale' : 'active'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: 'Actions',
|
Header: 'Actions',
|
||||||
@ -155,6 +159,10 @@ export const ArchiveTable = ({
|
|||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
// Always hidden -- for search
|
||||||
|
{
|
||||||
|
accessor: 'description',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
@ -233,10 +241,20 @@ export const ArchiveTable = ({
|
|||||||
setStoredParams({ id: sortBy[0].id, desc: sortBy[0].desc || false });
|
setStoredParams({ id: sortBy[0].id, desc: sortBy[0].desc || false });
|
||||||
}, [loading, sortBy, searchValue, setSearchParams, setStoredParams]);
|
}, [loading, sortBy, searchValue, setSearchParams, setStoredParams]);
|
||||||
|
|
||||||
|
const [firstRenderedIndex, lastRenderedIndex] =
|
||||||
|
useVirtualizedRange(rowHeight);
|
||||||
|
|
||||||
const renderRows = () => {
|
const renderRows = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{rows.map(row => {
|
{rows.map((row, index) => {
|
||||||
|
const isVirtual =
|
||||||
|
index < firstRenderedIndex || index > lastRenderedIndex;
|
||||||
|
|
||||||
|
if (isVirtual) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
prepareRow(row);
|
prepareRow(row);
|
||||||
return (
|
return (
|
||||||
<TableRow hover {...row.getRowProps()}>
|
<TableRow hover {...row.getRowProps()}>
|
||||||
|
Loading…
Reference in New Issue
Block a user