From 77548ec5a7f6cf69529d9f7f5be8e4754cedac68 Mon Sep 17 00:00:00 2001 From: Nancy <153055234+LEIYOUSU@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:30:38 +0800 Subject: [PATCH] feat: add name existence check before creating attachment group and storage policy (#6959) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /area ui /kind improvement /milestone 2.20.x #### What this PR does / why we need it: 在创建附件分组或者存储策略时,支持检查是否有已存在的名称。 #### Which issue(s) this PR fixes: Fixes #6946 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 在创建附件分组或者存储策略时,支持检查是否有已存在的名称。 ``` --- .../AttachmentGroupEditingModal.vue | 10 +++++++ .../components/AttachmentGroupList.vue | 2 +- .../AttachmentPolicyEditingModal.vue | 14 +++++++-- .../components/AttachmentUploadModal.vue | 9 ++++-- ui/src/locales/en.yaml | 29 ++++++++++++++----- ui/src/locales/zh-CN.yaml | 4 +++ ui/src/locales/zh-TW.yaml | 4 +++ 7 files changed, 60 insertions(+), 12 deletions(-) diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue index dad1ed46d9..e419003712 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue @@ -50,6 +50,16 @@ const handleSave = async () => { group: formState.value, }); } else { + const { data: groups } = await coreApiClient.storage.group.listGroup(); + const hasDisplayNameDuplicate = groups.items.some( + (group) => group.spec.displayName === formState.value.spec.displayName + ); + if (hasDisplayNameDuplicate) { + Toast.error( + t("core.attachment.group_editing_modal.toast.group_name_exists") + ); + return; + } await coreApiClient.storage.group.createGroup({ group: formState.value, }); diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentGroupList.vue b/ui/console-src/modules/contents/attachments/components/AttachmentGroupList.vue index b8b01d3956..7991e5f9aa 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentGroupList.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentGroupList.vue @@ -1,4 +1,5 @@