From a58e1769eabefdcbd084811e512d09c9feb95fa3 Mon Sep 17 00:00:00 2001 From: Kapian1234 Date: Wed, 4 Sep 2024 11:36:27 +0800 Subject: [PATCH 1/3] Hide workspace delete button for non OSD admin Signed-off-by: Kapian1234 --- .../workspace_detail/workspace_detail.tsx | 34 ++++++++++--------- .../components/workspace_list/index.tsx | 1 + 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/plugins/workspace/public/components/workspace_detail/workspace_detail.tsx b/src/plugins/workspace/public/components/workspace_detail/workspace_detail.tsx index c5e39b6f49b4..3205b4b2579e 100644 --- a/src/plugins/workspace/public/components/workspace_detail/workspace_detail.tsx +++ b/src/plugins/workspace/public/components/workspace_detail/workspace_detail.tsx @@ -170,22 +170,24 @@ export const WorkspaceDetail = (props: WorkspaceDetailProps) => { setMountPoint={application.setAppDescriptionControls} /> )} - setDeletedWorkspace(currentWorkspace), - color: 'danger', - iconType: 'trash', - ariaLabel: i18n.translate('workspace.detail.delete.button', { - defaultMessage: 'Delete', - }), - testId: 'workspace-detail-delete-button', - controlType: 'icon', - display: 'base', - } as TopNavControlIconData, - ]} - setMountPoint={application.setAppRightControls} - /> + {isDashboardAdmin && ( + setDeletedWorkspace(currentWorkspace), + color: 'danger', + iconType: 'trash', + ariaLabel: i18n.translate('workspace.detail.delete.button', { + defaultMessage: 'Delete', + }), + testId: 'workspace-detail-delete-button', + controlType: 'icon', + display: 'base', + } as TopNavControlIconData, + ]} + setMountPoint={application.setAppRightControls} + /> + )} { iconType="trash" color="danger" style={{ padding: 0 }} + disabled={!isDashboardAdmin} > Delete From bb9bf4183397adb0313321979fd741c0f344a802 Mon Sep 17 00:00:00 2001 From: Kapian1234 Date: Wed, 4 Sep 2024 17:36:16 +0800 Subject: [PATCH 2/3] hide delete action instead of disabled Signed-off-by: Kapian1234 --- .../workspace/public/components/workspace_list/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/workspace/public/components/workspace_list/index.tsx b/src/plugins/workspace/public/components/workspace_list/index.tsx index 9c907b79368d..e47705cf1902 100644 --- a/src/plugins/workspace/public/components/workspace_list/index.tsx +++ b/src/plugins/workspace/public/components/workspace_list/index.tsx @@ -410,6 +410,7 @@ export const WorkspaceList = ({ registeredUseCases$ }: WorkspaceListProps) => { type: 'button', description: 'Delete workspace', 'data-test-subj': 'workspace-list-delete-icon', + available: () => isDashboardAdmin, render: (item: WorkspaceAttribute) => { return ( { iconType="trash" color="danger" style={{ padding: 0 }} - disabled={!isDashboardAdmin} > Delete From 471772c06b98c30c02252849da92727a2a422904 Mon Sep 17 00:00:00 2001 From: "opensearch-changeset-bot[bot]" <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Date: Wed, 4 Sep 2024 09:41:00 +0000 Subject: [PATCH 3/3] Changeset file for PR #7987 created/updated --- changelogs/fragments/7987.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/7987.yml diff --git a/changelogs/fragments/7987.yml b/changelogs/fragments/7987.yml new file mode 100644 index 000000000000..0b67c17de12d --- /dev/null +++ b/changelogs/fragments/7987.yml @@ -0,0 +1,2 @@ +fix: +- Hide delete button for non OSD admin ([#7987](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7987)) \ No newline at end of file