From 30a753b93f0353228753dab4cad899e44a5c987f Mon Sep 17 00:00:00 2001
From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com>
Date: Tue, 14 Mar 2023 09:56:03 +0100
Subject: [PATCH] UI/bulk select (#3267)
Select multiple toggles on project overview.
---
.../ServiceAccountTokens.tsx | 128 +++++++++--------
.../SortableTableHeader.tsx | 15 +-
.../VirtualizedTable/VirtualizedTable.tsx | 16 +--
.../FeatureToggleList/ExportDialog.tsx | 18 +--
.../ProjectFeatureToggles.tsx | 92 +++++++++----
.../RowSelectCell/RowSelectCell.tsx | 24 ++++
.../SelectionActionsBar.tsx | 120 ++++++++++++++++
.../PersonalAPITokensTab.tsx | 130 ++++++++++--------
.../usePersonalAPITokens.ts | 16 +--
.../useServiceAccountTokens.ts | 12 +-
.../useServiceAccounts/useServiceAccounts.ts | 2 +-
frontend/src/hooks/useSearch.ts | 45 +++---
src/server-dev.ts | 1 +
13 files changed, 406 insertions(+), 213 deletions(-)
create mode 100644 frontend/src/component/project/Project/ProjectFeatureToggles/RowSelectCell/RowSelectCell.tsx
create mode 100644 frontend/src/component/project/Project/ProjectFeatureToggles/SelectionActionsBar/SelectionActionsBar.tsx
diff --git a/frontend/src/component/admin/serviceAccounts/ServiceAccountsTable/ServiceAccountModal/ServiceAccountTokens/ServiceAccountTokens.tsx b/frontend/src/component/admin/serviceAccounts/ServiceAccountsTable/ServiceAccountModal/ServiceAccountTokens/ServiceAccountTokens.tsx
index 3468ef469f..5ecdcce773 100644
--- a/frontend/src/component/admin/serviceAccounts/ServiceAccountsTable/ServiceAccountModal/ServiceAccountTokens/ServiceAccountTokens.tsx
+++ b/frontend/src/component/admin/serviceAccounts/ServiceAccountsTable/ServiceAccountModal/ServiceAccountTokens/ServiceAccountTokens.tsx
@@ -23,7 +23,13 @@ import {
IPersonalAPIToken,
} from 'interfaces/personalAPIToken';
import { useMemo, useState } from 'react';
-import { useTable, SortingRule, useSortBy, useFlexLayout } from 'react-table';
+import {
+ useTable,
+ SortingRule,
+ useSortBy,
+ useFlexLayout,
+ Column,
+} from 'react-table';
import { sortTypes } from 'utils/sortTypes';
import { ServiceAccountCreateTokenDialog } from './ServiceAccountCreateTokenDialog/ServiceAccountCreateTokenDialog';
import { ServiceAccountTokenDialog } from 'component/admin/serviceAccounts/ServiceAccountsTable/ServiceAccountTokenDialog/ServiceAccountTokenDialog';
@@ -151,65 +157,69 @@ export const ServiceAccountTokens = ({
};
const columns = useMemo(
- () => [
- {
- Header: 'Description',
- accessor: 'description',
- Cell: HighlightCell,
- minWidth: 100,
- searchable: true,
- },
- {
- Header: 'Expires',
- accessor: 'expiresAt',
- Cell: ({ value }: { value: string }) => {
- const date = new Date(value);
- if (date.getFullYear() > new Date().getFullYear() + 100) {
- return Never;
- }
- return ;
+ () =>
+ [
+ {
+ Header: 'Description',
+ accessor: 'description',
+ Cell: HighlightCell,
+ minWidth: 100,
+ searchable: true,
},
- sortType: 'date',
- maxWidth: 150,
- },
- {
- Header: 'Created',
- accessor: 'createdAt',
- Cell: DateCell,
- sortType: 'date',
- maxWidth: 150,
- },
- {
- Header: 'Last seen',
- accessor: 'seenAt',
- Cell: TimeAgoCell,
- sortType: 'date',
- maxWidth: 150,
- },
- {
- Header: 'Actions',
- id: 'Actions',
- align: 'center',
- Cell: ({ row: { original: rowToken } }: any) => (
-
-
-
- {
- setSelectedToken(rowToken);
- setDeleteOpen(true);
- }}
- >
-
-
-
-
-
- ),
- maxWidth: 100,
- disableSortBy: true,
- },
- ],
+ {
+ Header: 'Expires',
+ accessor: 'expiresAt',
+ Cell: ({ value }: { value: string }) => {
+ const date = new Date(value);
+ if (
+ date.getFullYear() >
+ new Date().getFullYear() + 100
+ ) {
+ return Never;
+ }
+ return ;
+ },
+ sortType: 'date',
+ maxWidth: 150,
+ },
+ {
+ Header: 'Created',
+ accessor: 'createdAt',
+ Cell: DateCell,
+ sortType: 'date',
+ maxWidth: 150,
+ },
+ {
+ Header: 'Last seen',
+ accessor: 'seenAt',
+ Cell: TimeAgoCell,
+ sortType: 'date',
+ maxWidth: 150,
+ },
+ {
+ Header: 'Actions',
+ id: 'Actions',
+ align: 'center',
+ Cell: ({ row: { original: rowToken } }: any) => (
+
+
+
+ {
+ setSelectedToken(rowToken);
+ setDeleteOpen(true);
+ }}
+ >
+
+
+
+
+
+ ),
+ maxWidth: 100,
+ disableSortBy: true,
+ },
+ ] as Column[],
[setSelectedToken, setDeleteOpen]
);
diff --git a/frontend/src/component/common/Table/SortableTableHeader/SortableTableHeader.tsx b/frontend/src/component/common/Table/SortableTableHeader/SortableTableHeader.tsx
index c120624e15..499f708d98 100644
--- a/frontend/src/component/common/Table/SortableTableHeader/SortableTableHeader.tsx
+++ b/frontend/src/component/common/Table/SortableTableHeader/SortableTableHeader.tsx
@@ -1,23 +1,20 @@
-import { VFC } from 'react';
import { TableHead, TableRow } from '@mui/material';
import { HeaderGroup } from 'react-table';
import { CellSortable } from './CellSortable/CellSortable';
-interface ISortableTableHeaderProps {
- headerGroups: HeaderGroup