From 29bd636273bc34f3cd0245a0227f422603db5498 Mon Sep 17 00:00:00 2001
From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com>
Date: Thu, 14 Dec 2023 09:04:56 +0100
Subject: [PATCH] Feat: row actions (#5635)
- add table placeholder back
- add row actions column
- refactor actions into hook
- batch actions
---
.../ExperimentalProjectTable.tsx | 124 ++++++++----------
.../TablePlaceholder/TablePlaceholder.tsx | 43 ++++++
.../hooks/useRowActions.tsx | 45 +++++++
frontend/src/utils/withTableState.test.tsx | 38 ++++++
frontend/src/utils/withTableState.ts | 6 +
5 files changed, 188 insertions(+), 68 deletions(-)
create mode 100644 frontend/src/component/project/Project/ExperimentalProjectFeatures/ExperimentalProjectTable/TablePlaceholder/TablePlaceholder.tsx
create mode 100644 frontend/src/component/project/Project/ExperimentalProjectFeatures/ExperimentalProjectTable/hooks/useRowActions.tsx
diff --git a/frontend/src/component/project/Project/ExperimentalProjectFeatures/ExperimentalProjectTable/ExperimentalProjectTable.tsx b/frontend/src/component/project/Project/ExperimentalProjectFeatures/ExperimentalProjectTable/ExperimentalProjectTable.tsx
index 0e6a5f3d7d..cb9f3c9d7b 100644
--- a/frontend/src/component/project/Project/ExperimentalProjectFeatures/ExperimentalProjectTable/ExperimentalProjectTable.tsx
+++ b/frontend/src/component/project/Project/ExperimentalProjectFeatures/ExperimentalProjectTable/ExperimentalProjectTable.tsx
@@ -35,11 +35,7 @@ import { LinkCell } from 'component/common/Table/cells/LinkCell/LinkCell';
import { FeatureSeenCell } from 'component/common/Table/cells/FeatureSeenCell/FeatureSeenCell';
import { FeatureTypeCell } from 'component/common/Table/cells/FeatureTypeCell/FeatureTypeCell';
import { IProject } from 'interfaces/project';
-import {
- PaginatedTable,
- TablePlaceholder,
- VirtualizedTable,
-} from 'component/common/Table';
+import { PaginatedTable, VirtualizedTable } from 'component/common/Table';
import { SearchHighlightProvider } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
import { FeatureStaleDialog } from 'component/common/FeatureStaleDialog/FeatureStaleDialog';
import { FeatureArchiveDialog } from 'component/common/FeatureArchiveDialog/FeatureArchiveDialog';
@@ -92,6 +88,9 @@ import { FeatureNameCell } from 'component/common/Table/cells/FeatureNameCell/Fe
import { FeatureToggleCell } from './FeatureToggleCell/FeatureToggleCell';
import { ProjectOverviewFilters } from './ProjectOverviewFilters';
import { useDefaultColumnVisibility } from './hooks/useDefaultColumnVisibility';
+import { Placeholder } from './TablePlaceholder/TablePlaceholder';
+import { useRowActions } from './hooks/useRowActions';
+import { useUiFlag } from 'hooks/useUiFlag';
interface IExperimentalProjectFeatureTogglesProps {
environments: IProject['environments'];
@@ -111,6 +110,8 @@ export const ExperimentalProjectFeatureToggles = ({
}: IExperimentalProjectFeatureTogglesProps) => {
const projectId = useRequiredPathParam('projectId');
+ const featuresExportImport = useUiFlag('featuresExportImport');
+
const stateConfig = {
offset: withDefault(NumberParam, 0),
limit: withDefault(NumberParam, DEFAULT_PAGE_LIMIT),
@@ -160,7 +161,13 @@ export const ExperimentalProjectFeatureToggles = ({
const { isChangeRequestConfigured } = useChangeRequestsEnabled(projectId);
const { onToggle: onFeatureToggle, modals: featureToggleModals } =
useFeatureToggleSwitch(projectId);
- const bodyLoadingRef = useLoading(loading);
+ const {
+ rowActionsDialogs,
+ setFeatureArchiveState,
+ setFeatureStaleDialogState,
+ } = useRowActions(refetch, projectId);
+ const [showExportDialog, setShowExportDialog] = useState(false);
+
const columns = useMemo(
() => [
columnHelper.display({
@@ -181,6 +188,9 @@ export const ExperimentalProjectFeatureToggles = ({
onChange={row?.getToggleSelectedHandler()}
/>
),
+ meta: {
+ width: '1%',
+ },
}),
columnHelper.accessor('favorite', {
id: 'favorite',
@@ -203,6 +213,7 @@ export const ExperimentalProjectFeatureToggles = ({
enableSorting: false,
meta: {
align: 'center',
+ width: '1%',
},
}),
columnHelper.accessor('lastSeenAt', {
@@ -217,6 +228,7 @@ export const ExperimentalProjectFeatureToggles = ({
size: 50,
meta: {
align: 'center',
+ width: '1%',
},
}),
columnHelper.accessor('type', {
@@ -225,12 +237,14 @@ export const ExperimentalProjectFeatureToggles = ({
cell: FeatureTypeCell,
meta: {
align: 'center',
+ width: '1%',
},
}),
columnHelper.accessor('name', {
id: 'name',
header: 'Name',
cell: FeatureNameCell,
+ enableHiding: false,
meta: {
width: '50%',
},
@@ -266,6 +280,7 @@ export const ExperimentalProjectFeatureToggles = ({
header: name,
meta: {
align: 'center',
+ width: '1%',
},
cell: ({ getValue }) => {
const {
@@ -296,6 +311,24 @@ export const ExperimentalProjectFeatureToggles = ({
);
},
),
+ columnHelper.display({
+ id: 'actions',
+ header: '',
+ cell: ({ row }) => (
+