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

Fix PR comments

This commit is contained in:
andreas-unleash 2022-06-07 11:54:16 +03:00
parent 406c187372
commit dd9a291e09
4 changed files with 58 additions and 52 deletions

View File

@ -27,7 +27,7 @@ import { FeatureSeenCell } from '../../common/Table/cells/FeatureSeenCell/Featur
import { LinkCell } from '../../common/Table/cells/LinkCell/LinkCell'; import { LinkCell } from '../../common/Table/cells/LinkCell/LinkCell';
import { FeatureStaleCell } from '../../feature/FeatureToggleList/FeatureStaleCell/FeatureStaleCell'; import { FeatureStaleCell } from '../../feature/FeatureToggleList/FeatureStaleCell/FeatureStaleCell';
import { TimeAgoCell } from '../../common/Table/cells/TimeAgoCell/TimeAgoCell'; import { TimeAgoCell } from '../../common/Table/cells/TimeAgoCell/TimeAgoCell';
import { ReviveArchivedFeatureCell } from 'component/common/Table/cells/ReviveArchivedFeatureCell/ReviveArchivedFeatureCell'; import { ReviveArchivedFeatureCell } from 'component/archive/ArchiveTable/ReviveArchivedFeatureCell/ReviveArchivedFeatureCell';
import { useStyles } from '../../feature/FeatureToggleList/styles'; import { useStyles } from '../../feature/FeatureToggleList/styles';
import { useVirtualizedRange } from '../../../hooks/useVirtualizedRange'; import { useVirtualizedRange } from '../../../hooks/useVirtualizedRange';
import { import {
@ -68,21 +68,22 @@ export const ArchiveTable = ({
const { reviveFeature } = useFeatureArchiveApi(); const { reviveFeature } = useFeatureArchiveApi();
const onRevive = (feature: string) => { const onRevive = async (feature: string) => {
reviveFeature(feature) try {
.then(refetch) await reviveFeature(feature);
.then(() => await refetch();
setToastData({ setToastData({
type: 'success', type: 'success',
title: "And we're back!", title: "And we're back!",
text: 'The feature toggle has been revived.', text: 'The feature toggle has been revived.',
confetti: true, confetti: true,
}) });
) } catch (e: any) {
.catch(e => setToastApiError(e.toString())); setToastApiError(e.toString());
}
}; };
const columns = useColumns(onRevive); const columns = getColumns(onRevive);
const data = useMemo( const data = useMemo(
() => () =>
@ -160,6 +161,41 @@ export const ArchiveTable = ({
const [firstRenderedIndex, lastRenderedIndex] = const [firstRenderedIndex, lastRenderedIndex] =
useVirtualizedRange(rowHeight); 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 ( return (
<PageContent <PageContent
isLoading={loading} isLoading={loading}
@ -194,40 +230,7 @@ export const ArchiveTable = ({
headerGroups={headerGroups as any} headerGroups={headerGroups as any}
/> />
<TableBody {...getTableBodyProps()}> <TableBody {...getTableBodyProps()}>
{rows.map((row, index) => { {renderRows()}
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> </TableBody>
</Table> </Table>
</SearchHighlightProvider> </SearchHighlightProvider>
@ -249,7 +252,7 @@ export const ArchiveTable = ({
); );
}; };
const useColumns = (onRevive: any) => { function getColumns(onRevive: (feature: string) => Promise<void>) {
return [ return [
{ {
id: 'Seen', id: 'Seen',
@ -323,4 +326,4 @@ const useColumns = (onRevive: any) => {
), ),
}, },
]; ];
}; }

View File

@ -1,5 +1,5 @@
import { VFC } from 'react'; import { VFC } from 'react';
import { ActionCell } from '../ActionCell/ActionCell'; import { ActionCell } from '../../../common/Table/cells/ActionCell/ActionCell';
import { Undo } from '@mui/icons-material'; import { Undo } from '@mui/icons-material';
import { IconButton } from '@mui/material'; import { IconButton } from '@mui/material';

View File

@ -3,10 +3,12 @@ import { ArchiveTable } from './ArchiveTable/ArchiveTable';
import { useSearchParams } from 'react-router-dom'; import { useSearchParams } from 'react-router-dom';
import { useLocalStorage } from '../../hooks/useLocalStorage'; import { useLocalStorage } from '../../hooks/useLocalStorage';
import { SortingRule } from 'react-table'; import { SortingRule } from 'react-table';
import { usePageTitle } from '../../hooks/usePageTitle';
const defaultSort: SortingRule<string> = { id: 'createdAt', desc: true }; const defaultSort: SortingRule<string> = { id: 'createdAt', desc: true };
export const FeaturesArchiveTable = () => { export const FeaturesArchiveTable = () => {
usePageTitle('Archived');
const { const {
archivedFeatures = [], archivedFeatures = [],
loading, loading,

View File

@ -1,4 +1,5 @@
import { ProjectFeaturesArchiveTable } from '../../../archive/ProjectFeaturesArchiveTable'; import { ProjectFeaturesArchiveTable } from '../../../archive/ProjectFeaturesArchiveTable';
import { usePageTitle } from '../../../../hooks/usePageTitle';
interface IProjectFeaturesArchiveProps { interface IProjectFeaturesArchiveProps {
projectId: string; projectId: string;
@ -7,7 +8,7 @@ interface IProjectFeaturesArchiveProps {
export const ProjectFeaturesArchive = ({ export const ProjectFeaturesArchive = ({
projectId, projectId,
}: IProjectFeaturesArchiveProps) => { }: IProjectFeaturesArchiveProps) => {
// usePageTitle('Project Archived Features'); usePageTitle('Project Archived Features');
return <ProjectFeaturesArchiveTable projectId={projectId} />; return <ProjectFeaturesArchiveTable projectId={projectId} />;
}; };