1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

PR comments

This commit is contained in:
andreas-unleash 2022-06-10 15:47:42 +03:00
parent a5094b1fc0
commit fb2005a2df
5 changed files with 42 additions and 49 deletions

View File

@ -9,7 +9,7 @@ import {
TableRow,
TableSearch,
} from 'component/common/Table';
import { useFlexLayout, useSortBy, useTable } from 'react-table';
import {SortingRule, useFlexLayout, useSortBy, useTable} from 'react-table';
import { SearchHighlightProvider } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
import { useMediaQuery } from '@mui/material';
import { sortTypes } from 'utils/sortTypes';
@ -32,16 +32,17 @@ import { formatUnknownError } from 'utils/formatUnknownError';
import { useSearch } from 'hooks/useSearch';
import { FeatureArchivedCell } from '../../common/Table/cells/FeatureArchivedCell/FeatureArchivedCell';
import { useVirtualizedRange } from 'hooks/useVirtualizedRange';
import { URLSearchParamsInit } from 'react-router-dom';
export interface IFeaturesArchiveTableProps {
archivedFeatures: FeatureSchema[];
title: string;
refetch: any;
refetch: () => void;
loading: boolean;
storedParams: any;
setStoredParams: any;
searchParams: any;
setSearchParams: any;
storedParams: SortingRule<string>;
setStoredParams: (newValue: (SortingRule<string> | ((prev: SortingRule<string>) => SortingRule<string>))) => SortingRule<string>;
searchParams: URLSearchParams;
setSearchParams: (nextInit: URLSearchParamsInit, navigateOptions?: ({replace?: boolean | undefined, state?: any} | undefined)) => void;
}
export const ArchiveTable = ({
@ -74,7 +75,6 @@ export const ArchiveTable = ({
type: 'success',
title: "And we're back!",
text: 'The feature toggle has been revived.',
confetti: true,
});
} catch (e: unknown) {
setToastApiError(formatUnknownError(e));
@ -164,6 +164,7 @@ export const ArchiveTable = ({
accessor: 'description',
},
],
//eslint-disable-next-line
[]
);
@ -244,41 +245,6 @@ export const ArchiveTable = ({
const [firstRenderedIndex, lastRenderedIndex] =
useVirtualizedRange(rowHeight);
const renderRows = () => {
return (
<>
{rows.map((row, index) => {
const isVirtual =
index < firstRenderedIndex || index > lastRenderedIndex;
if (isVirtual) {
return null;
}
prepareRow(row);
return (
<TableRow hover {...row.getRowProps()}>
{row.cells.map(cell => (
<TableCell
{...cell.getCellProps({
style: {
flex: cell.column.minWidth
? '1 0 auto'
: undefined,
},
})}
className={classes.cell}
>
{cell.render('Cell')}
</TableCell>
))}
</TableRow>
);
})}
</>
);
};
return (
<PageContent
isLoading={loading}
@ -315,7 +281,34 @@ export const ArchiveTable = ({
headerGroups={headerGroups as any}
/>
<TableBody {...getTableBodyProps()}>
{renderRows()}
{rows.map((row, index) => {
const isVirtual =
index < firstRenderedIndex || index > lastRenderedIndex;
if (isVirtual) {
return null;
}
prepareRow(row);
return (
<TableRow hover {...row.getRowProps()}>
{row.cells.map(cell => (
<TableCell
{...cell.getCellProps({
style: {
flex: cell.column.minWidth
? '1 0 auto'
: undefined,
},
})}
className={classes.cell}
>
{cell.render('Cell')}
</TableCell>
))}
</TableRow>
);
})}
</TableBody>
</Table>
</SearchHighlightProvider>

View File

@ -1,8 +1,8 @@
import { SyntheticEvent, VFC } from 'react';
import { ActionCell } from '../../../common/Table/cells/ActionCell/ActionCell';
import { ActionCell } from 'component/common/Table/cells/ActionCell/ActionCell';
import { Undo } from '@mui/icons-material';
import PermissionIconButton from '../../../common/PermissionIconButton/PermissionIconButton';
import { UPDATE_FEATURE } from '../../../providers/AccessProvider/permissions';
import PermissionIconButton from 'component/common/PermissionIconButton/PermissionIconButton';
import { UPDATE_FEATURE } from 'component/providers/AccessProvider/permissions';
interface IReviveArchivedFeatureCell {
onRevive: () => void;

View File

@ -23,7 +23,7 @@ export const FeaturesArchiveTable = () => {
return (
<ArchiveTable
title={'Archived'}
title='Archived'
archivedFeatures={archivedFeatures}
loading={loading}
searchParams={searchParams}

View File

@ -27,7 +27,7 @@ export const ProjectFeaturesArchiveTable = ({
return (
<ArchiveTable
title={'Project Features Archive'}
title='Project Features Archive'
archivedFeatures={archivedFeatures}
loading={loading}
searchParams={searchParams}

View File

@ -27,7 +27,7 @@ export const FeatureArchivedCell: VFC<IFeatureArchivedCellProps> = ({
arrow
>
<Typography noWrap variant="body2" data-loading>
<TimeAgo date={new Date(archivedAt)} title={''} />
<TimeAgo date={new Date(archivedAt)} />
</Typography>
</Tooltip>
)}