From a80cc61ebe6bf8e98d68c8b96c6fa4cabcc33f3e Mon Sep 17 00:00:00 2001 From: farodin91 Date: Mon, 2 Dec 2024 23:05:20 +0100 Subject: [PATCH 1/2] frontend: Allow ReactNode as description for ConfirmDialogs Signed-off-by: farodin91 --- frontend/src/components/common/ConfirmDialog.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/common/ConfirmDialog.tsx b/frontend/src/components/common/ConfirmDialog.tsx index a503fd43d9..3ba49b0571 100644 --- a/frontend/src/components/common/ConfirmDialog.tsx +++ b/frontend/src/components/common/ConfirmDialog.tsx @@ -3,13 +3,13 @@ import MuiDialog, { DialogProps as MuiDialogProps } from '@mui/material/Dialog'; import DialogActions from '@mui/material/DialogActions'; import DialogContent from '@mui/material/DialogContent'; import DialogContentText from '@mui/material/DialogContentText'; -import React from 'react'; +import React, { ReactNode } from 'react'; import { useTranslation } from 'react-i18next'; import { DialogTitle } from './Dialog'; export interface ConfirmDialogProps extends MuiDialogProps { title: string; - description: string; + description: ReactNode; onConfirm: () => void; handleClose: () => void; } From 9f374bc4e664c8f5c2968571578d2c2733429b41 Mon Sep 17 00:00:00 2001 From: farodin91 Date: Mon, 2 Dec 2024 23:06:31 +0100 Subject: [PATCH 2/2] frontend: Allow multiple deletes on ResourceTable * allow row selection * externalize logic Signed-off-by: farodin91 --- .../common/Resource/DeleteMultipleButton.tsx | 109 +++++++ .../common/Resource/ResourceListView.tsx | 2 +- .../common/Resource/ResourceTable.tsx | 24 +- .../Resource/ResourceTableMultiActions.tsx | 27 ++ ...ListView.OneHiddenColumn.stories.storyshot | 201 +++++++++++- .../components/common/Resource/index.test.ts | 2 + .../List.Items.stories.storyshot | 111 ++++++- ...sourceDefinition.Details.stories.storyshot | 111 ++++++- ...mResourceDefinition.List.stories.storyshot | 81 ++++- .../CustomResourceList.List.stories.storyshot | 111 ++++++- .../List.DaemonSets.stories.storyshot | 81 ++++- .../EndpointList.Items.stories.storyshot | 81 ++++- .../HPAList.Items.stories.storyshot | 81 ++++- .../ClassList.Items.stories.storyshot | 111 ++++++- .../List.Items.stories.storyshot | 111 ++++++- .../JobList.Items.stories.storyshot | 171 +++++++++- .../List.Items.stories.storyshot | 81 ++++- .../List.Items.stories.storyshot | 81 ++++- .../NamespaceList.Regular.stories.storyshot | 81 ++++- .../List.Nodes.stories.storyshot | 111 ++++++- .../PodList.Items.stories.storyshot | 291 +++++++++++++++++- .../pdbList.Items.stories.storyshot | 81 ++++- .../priorityClassList.Items.stories.storyshot | 81 ++++- .../List.ReplicaSets.stories.storyshot | 111 ++++++- .../resourceQuotaList.Items.stories.storyshot | 81 ++++- .../List.Items.stories.storyshot | 81 ++++- .../List.Items.stories.storyshot | 111 ++++++- .../ClaimList.Items.stories.storyshot | 141 ++++++++- .../ClassList.Items.stories.storyshot | 81 ++++- .../VolumeList.Items.stories.storyshot | 81 ++++- .../VPAList.List.stories.storyshot | 81 ++++- ...gWebhookConfigList.Items.stories.storyshot | 231 +++++++++++++- ...gWebhookConfigList.Items.stories.storyshot | 231 +++++++++++++- frontend/src/i18n/locales/de/translation.json | 6 + frontend/src/i18n/locales/en/translation.json | 6 + frontend/src/i18n/locales/es/translation.json | 6 + frontend/src/i18n/locales/fr/translation.json | 6 + frontend/src/i18n/locales/pt/translation.json | 6 + .../plugin/__snapshots__/pluginLib.snapshot | 1 + frontend/src/redux/headlampEventSlice.ts | 21 ++ 40 files changed, 3474 insertions(+), 30 deletions(-) create mode 100644 frontend/src/components/common/Resource/DeleteMultipleButton.tsx create mode 100644 frontend/src/components/common/Resource/ResourceTableMultiActions.tsx diff --git a/frontend/src/components/common/Resource/DeleteMultipleButton.tsx b/frontend/src/components/common/Resource/DeleteMultipleButton.tsx new file mode 100644 index 0000000000..224de9b910 --- /dev/null +++ b/frontend/src/components/common/Resource/DeleteMultipleButton.tsx @@ -0,0 +1,109 @@ +import _ from 'lodash'; +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import { useDispatch } from 'react-redux'; +import { KubeObject } from '../../../lib/k8s/KubeObject'; +import { CallbackActionOptions, clusterAction } from '../../../redux/clusterActionSlice'; +import { + EventStatus, + HeadlampEventType, + useEventCallback, +} from '../../../redux/headlampEventSlice'; +import { AppDispatch } from '../../../redux/stores/store'; +import ActionButton, { ButtonStyle } from '../ActionButton'; +import { ConfirmDialog } from '../Dialog'; + +interface DeleteMultipleButtonProps { + items?: KubeObject[]; + options?: CallbackActionOptions; + buttonStyle?: ButtonStyle; + afterConfirm?: () => void; +} + +interface DeleteMultipleButtonDescriptionProps { + items?: KubeObject[]; +} + +function DeleteMultipleButtonDescription(props: DeleteMultipleButtonDescriptionProps) { + const { t } = useTranslation(['translation']); + return ( +

+ {t('Are you sure you want to delete following items?')} +

    + {props.items?.map(item => ( +
  • {item.metadata.name}
  • + ))} +
+

+ ); +} + +export default function DeleteMultipleButton(props: DeleteMultipleButtonProps) { + const dispatch: AppDispatch = useDispatch(); + const { items, options, afterConfirm, buttonStyle } = props; + const [openAlert, setOpenAlert] = React.useState(false); + const { t } = useTranslation(['translation']); + const dispatchDeleteEvent = useEventCallback(HeadlampEventType.DELETE_RESOURCES); + + const deleteFunc = React.useCallback( + (items: KubeObject[]) => { + if (!items || items.length === 0) { + return; + } + const clonedItems = _.cloneDeep(items); + const itemsLength = clonedItems.length; + + dispatch( + clusterAction( + async () => { + await Promise.all(items.map(item => item.delete())); + }, + { + startMessage: t('Deleting {{ itemsLength }} items…', { itemsLength }), + cancelledMessage: t('Cancelled deletion of {{ itemsLength }} items.', { itemsLength }), + successMessage: t('Deleted {{ itemsLength }} items.', { itemsLength }), + errorMessage: t('Error deleting {{ itemsLength }} items.', { itemsLength }), + cancelUrl: location.pathname, + startUrl: location.pathname, + errorUrl: location.pathname, + ...options, + } + ) + ); + }, + [options] + ); + + if (!items || items.length === 0) { + return null; + } + + return ( + <> + { + setOpenAlert(true); + }} + icon="mdi:delete" + /> + } + handleClose={() => setOpenAlert(false)} + onConfirm={() => { + deleteFunc(items); + dispatchDeleteEvent({ + resources: items, + status: EventStatus.CONFIRMED, + }); + if (afterConfirm) { + afterConfirm(); + } + }} + /> + + ); +} diff --git a/frontend/src/components/common/Resource/ResourceListView.tsx b/frontend/src/components/common/Resource/ResourceListView.tsx index 19e6334b23..23c0528dcd 100644 --- a/frontend/src/components/common/Resource/ResourceListView.tsx +++ b/frontend/src/components/common/Resource/ResourceListView.tsx @@ -45,7 +45,7 @@ export default function ResourceListView( ) } > - + {children} ); diff --git a/frontend/src/components/common/Resource/ResourceTable.tsx b/frontend/src/components/common/Resource/ResourceTable.tsx index cf532bf2b1..527488f477 100644 --- a/frontend/src/components/common/Resource/ResourceTable.tsx +++ b/frontend/src/components/common/Resource/ResourceTable.tsx @@ -1,6 +1,6 @@ import { MenuItem, TableCellProps } from '@mui/material'; import { useTheme } from '@mui/material/styles'; -import { MRT_FilterFns, MRT_Row, MRT_SortingFn } from 'material-react-table'; +import { MRT_FilterFns, MRT_Row, MRT_SortingFn, MRT_TableInstance } from 'material-react-table'; import { ComponentProps, ReactNode, useEffect, useMemo, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import helpers from '../../../helpers'; @@ -20,6 +20,7 @@ import Link from '../Link'; import Table, { TableColumn } from '../Table'; import DeleteButton from './DeleteButton'; import EditButton from './EditButton'; +import ResourceTableMultiActions from './ResourceTableMultiActions'; import { RestartButton } from './RestartButton'; import ScaleButton from './ScaleButton'; import ViewButton from './ViewButton'; @@ -84,6 +85,8 @@ export interface ResourceTableProps { columns: (ResourceTableColumn | ColumnType)[]; /** Show or hide row actions @default false*/ enableRowActions?: boolean; + /** Show or hide row selections and actions @default false*/ + enableRowSelection?: boolean; actions?: null | RowAction[]; /** Provide a list of columns that won't be shown and cannot be turned on */ hideColumns?: string[] | null; @@ -253,6 +256,7 @@ function ResourceTableContent(props: ResourceTablePr defaultGlobalFilter, actions, enableRowActions = false, + enableRowSelection = false, } = props; const { t } = useTranslation(['glossary', 'translation']); const theme = useTheme(); @@ -459,6 +463,22 @@ function ResourceTableContent(props: ResourceTablePr }; }, [actionsProcessed]); + const wrappedEnableRowSelection = useMemo(() => { + if (import.meta.env.REACT_APP_HEADLAMP_ENABLE_ROW_SELECTION === 'false') { + return false; + } + return enableRowSelection; + }, [enableRowSelection]); + + const renderRowSelectionToolbar = useMemo(() => { + if (!wrappedEnableRowSelection) { + return undefined; + } + return ({ table }: { table: MRT_TableInstance> }) => ( + + ); + }, [wrappedEnableRowSelection]); + function onColumnsVisibilityChange(updater: any): void { setColumnVisibility(oldCols => { const newCols = updater(oldCols); @@ -491,6 +511,8 @@ function ResourceTableContent(props: ResourceTablePr >[]} diff --git a/frontend/src/components/common/Resource/ResourceTableMultiActions.tsx b/frontend/src/components/common/Resource/ResourceTableMultiActions.tsx new file mode 100644 index 0000000000..bb3fe5896c --- /dev/null +++ b/frontend/src/components/common/Resource/ResourceTableMultiActions.tsx @@ -0,0 +1,27 @@ +import { Grid } from '@mui/material'; +import { MRT_TableInstance } from 'material-react-table'; +import { useCallback } from 'react'; +import { KubeObject } from '../../../lib/k8s/KubeObject'; +import DeleteMultipleButton from './DeleteMultipleButton'; + +export interface ResourceTableMultiActionsProps> { + table: MRT_TableInstance; +} + +export default function ResourceTableMultiActions>( + props: ResourceTableMultiActionsProps +) { + const { table } = props; + const items = table.getSelectedRowModel().rows.map(t => t.original as unknown as KubeObject); + + const afterConfirm = useCallback(() => { + table.resetRowSelection(); + }, [table]); + return ( + + + + + + ); +} diff --git a/frontend/src/components/common/Resource/__snapshots__/ResourceListView.OneHiddenColumn.stories.storyshot b/frontend/src/components/common/Resource/__snapshots__/ResourceListView.OneHiddenColumn.stories.storyshot index aaf2da9bba..44a8092976 100644 --- a/frontend/src/components/common/Resource/__snapshots__/ResourceListView.OneHiddenColumn.stories.storyshot +++ b/frontend/src/components/common/Resource/__snapshots__/ResourceListView.OneHiddenColumn.stories.storyshot @@ -151,7 +151,7 @@
+
+
+ +
+
+
+ + + + + + + @@ -419,6 +498,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -481,6 +590,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -543,6 +682,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -605,6 +774,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/components/common/Resource/index.test.ts b/frontend/src/components/common/Resource/index.test.ts index e4573b53a2..ae4c85ad8c 100644 --- a/frontend/src/components/common/Resource/index.test.ts +++ b/frontend/src/components/common/Resource/index.test.ts @@ -16,6 +16,7 @@ const checkExports = [ 'CircularChart', 'CreateButton', 'DeleteButton', + 'DeleteMultipleButton', 'DocsViewer', 'EditButton', 'EditorDialog', @@ -26,6 +27,7 @@ const checkExports = [ 'Resource', 'ResourceListView', 'ResourceTable', + 'ResourceTableMultiActions', 'resourceTableSlice', 'ResourceTableColumnChooser', 'RestartButton', diff --git a/frontend/src/components/configmap/__snapshots__/List.Items.stories.storyshot b/frontend/src/components/configmap/__snapshots__/List.Items.stories.storyshot index 837e1f5afc..074251ca1d 100644 --- a/frontend/src/components/configmap/__snapshots__/List.Items.stories.storyshot +++ b/frontend/src/components/configmap/__snapshots__/List.Items.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + @@ -568,6 +647,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/components/crd/__snapshots__/CustomResourceDefinition.Details.stories.storyshot b/frontend/src/components/crd/__snapshots__/CustomResourceDefinition.Details.stories.storyshot index 525b2aca3c..b643fe3b65 100644 --- a/frontend/src/components/crd/__snapshots__/CustomResourceDefinition.Details.stories.storyshot +++ b/frontend/src/components/crd/__snapshots__/CustomResourceDefinition.Details.stories.storyshot @@ -600,7 +600,7 @@ +
+
+ +
+
+
+ + + + + + + @@ -928,6 +1007,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/components/crd/__snapshots__/CustomResourceDefinition.List.stories.storyshot b/frontend/src/components/crd/__snapshots__/CustomResourceDefinition.List.stories.storyshot index 0257b85f83..cc6b0e2b9b 100644 --- a/frontend/src/components/crd/__snapshots__/CustomResourceDefinition.List.stories.storyshot +++ b/frontend/src/components/crd/__snapshots__/CustomResourceDefinition.List.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/crd/__snapshots__/CustomResourceList.List.stories.storyshot b/frontend/src/components/crd/__snapshots__/CustomResourceList.List.stories.storyshot index 9ffafe048c..418a322555 100644 --- a/frontend/src/components/crd/__snapshots__/CustomResourceList.List.stories.storyshot +++ b/frontend/src/components/crd/__snapshots__/CustomResourceList.List.stories.storyshot @@ -223,7 +223,7 @@ +
+
+ +
+
+
+ + + + + + + @@ -551,6 +630,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/components/daemonset/__snapshots__/List.DaemonSets.stories.storyshot b/frontend/src/components/daemonset/__snapshots__/List.DaemonSets.stories.storyshot index 3ae18ea85b..2aa0428188 100644 --- a/frontend/src/components/daemonset/__snapshots__/List.DaemonSets.stories.storyshot +++ b/frontend/src/components/daemonset/__snapshots__/List.DaemonSets.stories.storyshot @@ -243,7 +243,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/endpoints/__snapshots__/EndpointList.Items.stories.storyshot b/frontend/src/components/endpoints/__snapshots__/EndpointList.Items.stories.storyshot index 9a01a31200..7552ae4baf 100644 --- a/frontend/src/components/endpoints/__snapshots__/EndpointList.Items.stories.storyshot +++ b/frontend/src/components/endpoints/__snapshots__/EndpointList.Items.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/horizontalPodAutoscaler/__snapshots__/HPAList.Items.stories.storyshot b/frontend/src/components/horizontalPodAutoscaler/__snapshots__/HPAList.Items.stories.storyshot index 0b1ed0b9cf..795ba40411 100644 --- a/frontend/src/components/horizontalPodAutoscaler/__snapshots__/HPAList.Items.stories.storyshot +++ b/frontend/src/components/horizontalPodAutoscaler/__snapshots__/HPAList.Items.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/ingress/__snapshots__/ClassList.Items.stories.storyshot b/frontend/src/components/ingress/__snapshots__/ClassList.Items.stories.storyshot index 6ba2f33354..673902d5f9 100644 --- a/frontend/src/components/ingress/__snapshots__/ClassList.Items.stories.storyshot +++ b/frontend/src/components/ingress/__snapshots__/ClassList.Items.stories.storyshot @@ -151,7 +151,7 @@ +
+
+ +
+
+
+ + + + + + + @@ -439,6 +518,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/components/ingress/__snapshots__/List.Items.stories.storyshot b/frontend/src/components/ingress/__snapshots__/List.Items.stories.storyshot index c4aa4f60e6..e8308219bd 100644 --- a/frontend/src/components/ingress/__snapshots__/List.Items.stories.storyshot +++ b/frontend/src/components/ingress/__snapshots__/List.Items.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + @@ -699,6 +778,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/components/job/__snapshots__/JobList.Items.stories.storyshot b/frontend/src/components/job/__snapshots__/JobList.Items.stories.storyshot index b5bea2b0e9..01ea2ed269 100644 --- a/frontend/src/components/job/__snapshots__/JobList.Items.stories.storyshot +++ b/frontend/src/components/job/__snapshots__/JobList.Items.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + @@ -831,6 +910,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -941,6 +1050,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -1051,6 +1190,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/components/lease/__snapshots__/List.Items.stories.storyshot b/frontend/src/components/lease/__snapshots__/List.Items.stories.storyshot index beb7bebc0b..b4386debe4 100644 --- a/frontend/src/components/lease/__snapshots__/List.Items.stories.storyshot +++ b/frontend/src/components/lease/__snapshots__/List.Items.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/limitRange/__snapshots__/List.Items.stories.storyshot b/frontend/src/components/limitRange/__snapshots__/List.Items.stories.storyshot index af3e5e50f3..0f675d2bf0 100644 --- a/frontend/src/components/limitRange/__snapshots__/List.Items.stories.storyshot +++ b/frontend/src/components/limitRange/__snapshots__/List.Items.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/namespace/__snapshots__/NamespaceList.Regular.stories.storyshot b/frontend/src/components/namespace/__snapshots__/NamespaceList.Regular.stories.storyshot index e3f34b9adc..fec1b08574 100644 --- a/frontend/src/components/namespace/__snapshots__/NamespaceList.Regular.stories.storyshot +++ b/frontend/src/components/namespace/__snapshots__/NamespaceList.Regular.stories.storyshot @@ -163,7 +163,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/node/__snapshots__/List.Nodes.stories.storyshot b/frontend/src/components/node/__snapshots__/List.Nodes.stories.storyshot index 681185bb4b..353d236662 100644 --- a/frontend/src/components/node/__snapshots__/List.Nodes.stories.storyshot +++ b/frontend/src/components/node/__snapshots__/List.Nodes.stories.storyshot @@ -154,7 +154,7 @@ +
+
+ +
+
+
+ + + + + + + @@ -844,6 +923,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/components/pod/__snapshots__/PodList.Items.stories.storyshot b/frontend/src/components/pod/__snapshots__/PodList.Items.stories.storyshot index fb9318ec82..7a281052bb 100644 --- a/frontend/src/components/pod/__snapshots__/PodList.Items.stories.storyshot +++ b/frontend/src/components/pod/__snapshots__/PodList.Items.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + @@ -830,6 +909,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -937,6 +1046,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -1046,6 +1185,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -1155,6 +1324,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -1264,6 +1463,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -1373,6 +1602,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -1482,6 +1741,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/components/podDisruptionBudget/__snapshots__/pdbList.Items.stories.storyshot b/frontend/src/components/podDisruptionBudget/__snapshots__/pdbList.Items.stories.storyshot index f3beb02547..4c41d07481 100644 --- a/frontend/src/components/podDisruptionBudget/__snapshots__/pdbList.Items.stories.storyshot +++ b/frontend/src/components/podDisruptionBudget/__snapshots__/pdbList.Items.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/priorityClass/__snapshots__/priorityClassList.Items.stories.storyshot b/frontend/src/components/priorityClass/__snapshots__/priorityClassList.Items.stories.storyshot index fdde3e1aa7..86237e0cec 100644 --- a/frontend/src/components/priorityClass/__snapshots__/priorityClassList.Items.stories.storyshot +++ b/frontend/src/components/priorityClass/__snapshots__/priorityClassList.Items.stories.storyshot @@ -151,7 +151,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/replicaset/__snapshots__/List.ReplicaSets.stories.storyshot b/frontend/src/components/replicaset/__snapshots__/List.ReplicaSets.stories.storyshot index a29f8e2450..5613d8077b 100644 --- a/frontend/src/components/replicaset/__snapshots__/List.ReplicaSets.stories.storyshot +++ b/frontend/src/components/replicaset/__snapshots__/List.ReplicaSets.stories.storyshot @@ -243,7 +243,7 @@ +
+
+ +
+
+
+ + + + + + + @@ -893,6 +972,36 @@ pod-template-hash=b123456 class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/components/resourceQuota/__snapshots__/resourceQuotaList.Items.stories.storyshot b/frontend/src/components/resourceQuota/__snapshots__/resourceQuotaList.Items.stories.storyshot index e9ce72ded5..8f35c8d0b7 100644 --- a/frontend/src/components/resourceQuota/__snapshots__/resourceQuotaList.Items.stories.storyshot +++ b/frontend/src/components/resourceQuota/__snapshots__/resourceQuotaList.Items.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/runtimeClass/__snapshots__/List.Items.stories.storyshot b/frontend/src/components/runtimeClass/__snapshots__/List.Items.stories.storyshot index 521f67c1d0..3627c0c07d 100644 --- a/frontend/src/components/runtimeClass/__snapshots__/List.Items.stories.storyshot +++ b/frontend/src/components/runtimeClass/__snapshots__/List.Items.stories.storyshot @@ -151,7 +151,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/secret/__snapshots__/List.Items.stories.storyshot b/frontend/src/components/secret/__snapshots__/List.Items.stories.storyshot index 843a8b649b..5fa17d52b4 100644 --- a/frontend/src/components/secret/__snapshots__/List.Items.stories.storyshot +++ b/frontend/src/components/secret/__snapshots__/List.Items.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + @@ -628,6 +707,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/components/storage/__snapshots__/ClaimList.Items.stories.storyshot b/frontend/src/components/storage/__snapshots__/ClaimList.Items.stories.storyshot index d97cdf47f7..9399e59f4f 100644 --- a/frontend/src/components/storage/__snapshots__/ClaimList.Items.stories.storyshot +++ b/frontend/src/components/storage/__snapshots__/ClaimList.Items.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + @@ -901,6 +980,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -1013,6 +1122,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/components/storage/__snapshots__/ClassList.Items.stories.storyshot b/frontend/src/components/storage/__snapshots__/ClassList.Items.stories.storyshot index eeb4f61dfa..fdd80c537a 100644 --- a/frontend/src/components/storage/__snapshots__/ClassList.Items.stories.storyshot +++ b/frontend/src/components/storage/__snapshots__/ClassList.Items.stories.storyshot @@ -151,7 +151,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/storage/__snapshots__/VolumeList.Items.stories.storyshot b/frontend/src/components/storage/__snapshots__/VolumeList.Items.stories.storyshot index 65dae6b3f2..ddeb035224 100644 --- a/frontend/src/components/storage/__snapshots__/VolumeList.Items.stories.storyshot +++ b/frontend/src/components/storage/__snapshots__/VolumeList.Items.stories.storyshot @@ -151,7 +151,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/verticalPodAutoscaler/__snapshots__/VPAList.List.stories.storyshot b/frontend/src/components/verticalPodAutoscaler/__snapshots__/VPAList.List.stories.storyshot index ae181c02b4..b4e896b3ac 100644 --- a/frontend/src/components/verticalPodAutoscaler/__snapshots__/VPAList.List.stories.storyshot +++ b/frontend/src/components/verticalPodAutoscaler/__snapshots__/VPAList.List.stories.storyshot @@ -240,7 +240,7 @@ +
+
+ +
+
+
+ + + + + + + diff --git a/frontend/src/components/webhookconfiguration/__snapshots__/MutatingWebhookConfigList.Items.stories.storyshot b/frontend/src/components/webhookconfiguration/__snapshots__/MutatingWebhookConfigList.Items.stories.storyshot index 06ced22675..3d93e2804f 100644 --- a/frontend/src/components/webhookconfiguration/__snapshots__/MutatingWebhookConfigList.Items.stories.storyshot +++ b/frontend/src/components/webhookconfiguration/__snapshots__/MutatingWebhookConfigList.Items.stories.storyshot @@ -154,7 +154,7 @@ +
+
+ +
+
+
+ + + + + + + @@ -417,6 +496,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -474,6 +583,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -531,6 +670,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -588,6 +757,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -645,6 +844,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/components/webhookconfiguration/__snapshots__/ValidatingWebhookConfigList.Items.stories.storyshot b/frontend/src/components/webhookconfiguration/__snapshots__/ValidatingWebhookConfigList.Items.stories.storyshot index d79b7327a2..476f102bf5 100644 --- a/frontend/src/components/webhookconfiguration/__snapshots__/ValidatingWebhookConfigList.Items.stories.storyshot +++ b/frontend/src/components/webhookconfiguration/__snapshots__/ValidatingWebhookConfigList.Items.stories.storyshot @@ -154,7 +154,7 @@ +
+
+ +
+
+
+ + + + + + + @@ -417,6 +496,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -474,6 +583,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -531,6 +670,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -588,6 +757,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + @@ -645,6 +844,36 @@ class="css-fqq3az" data-selected="false" > + + + + + + + diff --git a/frontend/src/i18n/locales/de/translation.json b/frontend/src/i18n/locales/de/translation.json index 3705543014..adf0b7db29 100644 --- a/frontend/src/i18n/locales/de/translation.json +++ b/frontend/src/i18n/locales/de/translation.json @@ -190,6 +190,12 @@ "Error deleting item {{ itemName }}.": "Fehler beim Löschen des Elements {{ itemName }}.", "Delete item": "Element löschen", "Are you sure you want to delete item {{ itemName }}?": "Sind Sie sicher, dass Sie dieses Element {{ itemName }} löschen möchten?", + "Are you sure you want to delete following items?": "Sind Sie sicher, dass Sie folgende Elemente löschen möchten?", + "Deleting {{ itemsLength }} items…": "Löschen von {{ itemsLength }} Elementen…", + "Cancelled deletion of {{ itemsLength }} items.": "Löschen von {{ itemsLength }} Elementen abgebrochen.", + "Deleted {{ itemsLength }} items.": "{{ itemsLength }} Elemente gelöscht.", + "Error deleting {{ itemsLength }} items.": "Fehler beim Löschen von {{ itemsLength }} Elementen.", + "Delete items": "Elemente löschen", "Loading documentation": "Dokumentation laden", "No documentation for type {{ docsType }}.": "Keine Dokumentation für Typ {{ docsType }}.", "Showing documentation for: {{ docsType }}": "Zeige die Dokumentation für: {{ docsType }}", diff --git a/frontend/src/i18n/locales/en/translation.json b/frontend/src/i18n/locales/en/translation.json index 6b60b149ef..1bb44e9518 100644 --- a/frontend/src/i18n/locales/en/translation.json +++ b/frontend/src/i18n/locales/en/translation.json @@ -190,6 +190,12 @@ "Error deleting item {{ itemName }}.": "Error deleting item {{ itemName }}.", "Delete item": "Delete item", "Are you sure you want to delete item {{ itemName }}?": "Are you sure you want to delete item {{ itemName }}?", + "Are you sure you want to delete following items?": "Are you sure you want to delete following items?", + "Deleting {{ itemsLength }} items…": "Deleting {{ itemsLength }} items…", + "Cancelled deletion of {{ itemsLength }} items.": "Cancelled deletion of {{ itemsLength }} items.", + "Deleted {{ itemsLength }} items.": "Deleted {{ itemsLength }} items.", + "Error deleting {{ itemsLength }} items.": "Error deleting {{ itemsLength }} items.", + "Delete items": "Delete items", "Loading documentation": "Loading documentation", "No documentation for type {{ docsType }}.": "No documentation for type {{ docsType }}.", "Showing documentation for: {{ docsType }}": "Showing documentation for: {{ docsType }}", diff --git a/frontend/src/i18n/locales/es/translation.json b/frontend/src/i18n/locales/es/translation.json index 97e95dcc65..3d51688a5a 100644 --- a/frontend/src/i18n/locales/es/translation.json +++ b/frontend/src/i18n/locales/es/translation.json @@ -191,6 +191,12 @@ "Error deleting item {{ itemName }}.": "Error al eliminar el item {{ itemName }}.", "Delete item": "Eliminar item", "Are you sure you want to delete item {{ itemName }}?": "¿Seguro que quiere eliminar este item {{ itemName }}?", + "Are you sure you want to delete following items?": "", + "Deleting {{ itemsLength }} items…": "", + "Cancelled deletion of {{ itemsLength }} items.": "", + "Deleted {{ itemsLength }} items.": "", + "Error deleting {{ itemsLength }} items.": "", + "Delete items": "", "Loading documentation": "Cargando documentación", "No documentation for type {{ docsType }}.": "Sin documentación para el tipo {{ docsType }}.", "Showing documentation for: {{ docsType }}": "Mostrando documentación para: {{ docsType }}", diff --git a/frontend/src/i18n/locales/fr/translation.json b/frontend/src/i18n/locales/fr/translation.json index 45bb73792b..b1e4901002 100644 --- a/frontend/src/i18n/locales/fr/translation.json +++ b/frontend/src/i18n/locales/fr/translation.json @@ -191,6 +191,12 @@ "Error deleting item {{ itemName }}.": "Erreur lors de la suppression de l'élément {{ itemName }}.", "Delete item": "Supprimer un élément", "Are you sure you want to delete item {{ itemName }}?": "Voulez-vous vraiment supprimer cet élément {{ itemName }}?", + "Are you sure you want to delete following items?": "", + "Deleting {{ itemsLength }} items…": "", + "Cancelled deletion of {{ itemsLength }} items.": "", + "Deleted {{ itemsLength }} items.": "", + "Error deleting {{ itemsLength }} items.": "", + "Delete items": "", "Loading documentation": "Chargement de la documentation", "No documentation for type {{ docsType }}.": "Pas de documentation pour le type {{ docsType }}.", "Showing documentation for: {{ docsType }}": "Afficher la documentation pour : {{ docsType }}", diff --git a/frontend/src/i18n/locales/pt/translation.json b/frontend/src/i18n/locales/pt/translation.json index 3f2a88813f..724ac536dc 100644 --- a/frontend/src/i18n/locales/pt/translation.json +++ b/frontend/src/i18n/locales/pt/translation.json @@ -191,6 +191,12 @@ "Error deleting item {{ itemName }}.": "Erro ao eliminar o item {{ itemName }}.", "Delete item": "Eliminar item", "Are you sure you want to delete item {{ itemName }}?": "Tem a certeza de que pretende eliminar este item {{ itemName }}?", + "Are you sure you want to delete following items?": "", + "Deleting {{ itemsLength }} items…": "", + "Cancelled deletion of {{ itemsLength }} items.": "", + "Deleted {{ itemsLength }} items.": "", + "Error deleting {{ itemsLength }} items.": "", + "Delete items": "", "Loading documentation": "A carregar documentação", "No documentation for type {{ docsType }}.": "Sem documentação para o tipo {{ docsType }}.", "Showing documentation for: {{ docsType }}": "A mostrar documentação para: {{ docsType }}", diff --git a/frontend/src/plugin/__snapshots__/pluginLib.snapshot b/frontend/src/plugin/__snapshots__/pluginLib.snapshot index 7bb73c5a37..388585d06e 100644 --- a/frontend/src/plugin/__snapshots__/pluginLib.snapshot +++ b/frontend/src/plugin/__snapshots__/pluginLib.snapshot @@ -185,6 +185,7 @@ "DefaultHeadlampEvents": { "CREATE_RESOURCE": "headlamp.create-resource", "DELETE_RESOURCE": "headlamp.delete-resource", + "DELETE_RESOURCES": "headlamp.delete-resources", "DETAILS_VIEW": "headlamp.details-view", "EDIT_RESOURCE": "headlamp.edit-resource", "ERROR_BOUNDARY": "headlamp.error-boundary", diff --git a/frontend/src/redux/headlampEventSlice.ts b/frontend/src/redux/headlampEventSlice.ts index a8b703bd20..e6f9e9edaf 100644 --- a/frontend/src/redux/headlampEventSlice.ts +++ b/frontend/src/redux/headlampEventSlice.ts @@ -19,6 +19,8 @@ export enum HeadlampEventType { ERROR_BOUNDARY = 'headlamp.error-boundary', /** Events related to deleting a resource. */ DELETE_RESOURCE = 'headlamp.delete-resource', + /** Events related to deleting multiple resources. */ + DELETE_RESOURCES = 'headlamp.delete-resources', /** Events related to creating a resource. */ CREATE_RESOURCE = 'headlamp.create-resource', /** Events related to editing a resource. */ @@ -92,6 +94,20 @@ export interface DeleteResourceEvent extends HeadlampEvent { + data: { + /** Resources for which the deletion was called. */ + resources: KubeObject[]; + /** What exactly this event represents. 'CONFIRMED' when the user confirms the deletion of resources. + * For now only 'CONFIRMED' is sent. + */ + status: EventStatus.CONFIRMED; + }; +} + /** * Event fired when editing a resource. */ @@ -326,6 +342,9 @@ export function useEventCallback( export function useEventCallback( eventType: HeadlampEventType.DELETE_RESOURCE ): (data: EventDataType) => void; +export function useEventCallback( + eventType: HeadlampEventType.DELETE_RESOURCES +): (data: EventDataType) => void; export function useEventCallback( eventType: HeadlampEventType.EDIT_RESOURCE ): (data: EventDataType) => void; @@ -388,6 +407,8 @@ export function useEventCallback(eventType?: HeadlampEventType | string) { }; case HeadlampEventType.DELETE_RESOURCE: return dispatchDataEventFunc(HeadlampEventType.DELETE_RESOURCE); + case HeadlampEventType.DELETE_RESOURCES: + return dispatchDataEventFunc(HeadlampEventType.DELETE_RESOURCES); case HeadlampEventType.EDIT_RESOURCE: return dispatchDataEventFunc(HeadlampEventType.EDIT_RESOURCE); case HeadlampEventType.SCALE_RESOURCE: