From 8d9d2eb2152fff34d682437998a64850a610e5b0 Mon Sep 17 00:00:00 2001 From: KubeSphere CI Bot <47586280+ks-ci-bot@users.noreply.github.com> Date: Tue, 24 Dec 2024 17:38:07 +0800 Subject: [PATCH] [master] fix: Fix delete workspace with deleting project on workspace baseinfo page (#4389) fix: Fix delete workspace with deleting project on workspace baseinfo page Signed-off-by: lannyfu Co-authored-by: lannyfu --- .../access/containers/Workspaces/index.tsx | 4 ++-- packages/shared/src/stores/workspace.ts | 19 ++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/packages/console/src/pages/access/containers/Workspaces/index.tsx b/packages/console/src/pages/access/containers/Workspaces/index.tsx index 38853dc43e0..d39946d490e 100644 --- a/packages/console/src/pages/access/containers/Workspaces/index.tsx +++ b/packages/console/src/pages/access/containers/Workspaces/index.tsx @@ -104,7 +104,7 @@ export default function Workspaces(): JSX.Element { (item: { namespace?: string; name: string }) => ({ namespace: item.namespace, name: item.name, - deleteProject: checkkboxRef.current, + shouldDeleteResource: checkkboxRef.current, ...params, }), ); @@ -167,7 +167,7 @@ export default function Workspaces(): JSX.Element { const deleteParams = [record].map(item => ({ namespace: item.namespace, name: item.name, - deleteProject: checkkboxRef.current, + shouldDeleteResource: checkkboxRef.current, ...params, })); await workspaceStore.batchDelete(deleteParams); diff --git a/packages/shared/src/stores/workspace.ts b/packages/shared/src/stores/workspace.ts index 42b0cd29c8d..3d81c7283c6 100644 --- a/packages/shared/src/stores/workspace.ts +++ b/packages/shared/src/stores/workspace.ts @@ -114,21 +114,14 @@ const patch = async (params: PathParams, data: Record) => { interface DeleteWorkspaceOptions extends PathParams { shouldDeleteResource?: boolean; - deleteProject?: boolean; } -const deleteWorkspace = ({ - shouldDeleteResource, - deleteProject, - ...params -}: DeleteWorkspaceOptions) => { - const data = !shouldDeleteResource - ? { - kind: 'DeleteOptions', - apiVersion: 'v1', - propagationPolicy: deleteProject ? 'Background' : 'Orphan', - } - : {}; +const deleteWorkspace = ({ shouldDeleteResource, ...params }: DeleteWorkspaceOptions) => { + const data = { + kind: 'DeleteOptions', + apiVersion: 'v1', + propagationPolicy: shouldDeleteResource ? 'Background' : 'Orphan', + }; return request.delete>(getDetailUrl(params), { data, });