From b5db2e46f3ed4a3c269c5b565e80ffc235566d3f Mon Sep 17 00:00:00 2001 From: Nancy <3510671794@qq.com> Date: Sat, 26 Oct 2024 15:56:40 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9C=A8=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E9=99=84=E4=BB=B6=E6=97=B6=E6=96=B0=E5=BB=BA=E5=88=86?= =?UTF-8?q?=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contents/attachments/components/AttachmentUploadModal.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue index f2dfc1ddce..1f956ff5a5 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue @@ -19,6 +19,8 @@ import AttachmentGroupBadge from "./AttachmentGroupBadge.vue"; import AttachmentGroupEditingModal from "./AttachmentGroupEditingModal.vue"; import AttachmentPolicyBadge from "./AttachmentPolicyBadge.vue"; import AttachmentPolicyEditingModal from "./AttachmentPolicyEditingModal.vue"; +import AttachmentGroupEditingModal from "./AttachmentGroupEditingModal.vue"; +import UppyUpload from "@/components/upload/UppyUpload.vue"; const emit = defineEmits<{ (event: "close"): void; From f81ce26ae24a1a838c52952d486964bc366ebd01 Mon Sep 17 00:00:00 2001 From: Nancy <3510671794@qq.com> Date: Mon, 28 Oct 2024 13:08:16 +0800 Subject: [PATCH 2/8] Fix UI minor issues --- .../attachments/components/AttachmentUploadModal.vue | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue index 1f956ff5a5..b53d04e6d5 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue @@ -19,8 +19,6 @@ import AttachmentGroupBadge from "./AttachmentGroupBadge.vue"; import AttachmentGroupEditingModal from "./AttachmentGroupEditingModal.vue"; import AttachmentPolicyBadge from "./AttachmentPolicyBadge.vue"; import AttachmentPolicyEditingModal from "./AttachmentPolicyEditingModal.vue"; -import AttachmentGroupEditingModal from "./AttachmentGroupEditingModal.vue"; -import UppyUpload from "@/components/upload/UppyUpload.vue"; const emit = defineEmits<{ (event: "close"): void; @@ -145,14 +143,14 @@ const onGroupEditingModalClose = async () => { @click="selectedGroupName = group.metadata.name" /> - + - + Date: Mon, 28 Oct 2024 14:50:34 +0800 Subject: [PATCH 3/8] Fix #6946: Prevent duplicate storage policy and group names --- .../components/AttachmentGroupEditingModal.vue | 12 ++++++++++++ .../components/AttachmentPolicyEditingModal.vue | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue index dad1ed46d9..fd724c9ace 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue @@ -44,6 +44,18 @@ const modalTitle = props.group const handleSave = async () => { try { isSubmitting.value = true; + const existingGroupsResponse = + await coreApiClient.storage.group.listGroup(); + const existingGroups = existingGroupsResponse.data.items || []; + const nameExists = existingGroups.some( + (group) => group.spec.displayName === formState.value.spec.displayName + ); + + if (nameExists) { + alert("该分组名称已存在,请重新创建!"); + return; + } + if (props.group) { await coreApiClient.storage.group.updateGroup({ name: formState.value.metadata.name, diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue index ec09872025..0cf15cb852 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue @@ -47,6 +47,14 @@ const formState = ref({ const isUpdateMode = !!props.policy; +const { data: policies } = useQuery({ + queryKey: ["core:attachment:policies"], + queryFn: async () => { + const { data } = await coreApiClient.storage.policy.listPolicy(); // 修改为 listPolicy + return data; + }, +}); + onMounted(async () => { if (props.policy) { formState.value = cloneDeep(props.policy); @@ -135,6 +143,14 @@ const submitting = ref(false); const handleSave = async () => { try { submitting.value = true; + const nameExists = policies.value?.items.some( + (policy) => policy.spec.displayName === formState.value.spec.displayName + ); + + if (nameExists) { + alert("该存储策略名称已存在,请重新创建!"); + return; + } const configMapToUpdate = convertToSave(); From 72f1451dbc9959f51782be8457f8d47043a52bae Mon Sep 17 00:00:00 2001 From: Nancy <3510671794@qq.com> Date: Mon, 28 Oct 2024 20:29:33 +0800 Subject: [PATCH 4/8] Modified code based on the review --- .../components/AttachmentGroupEditingModal.vue | 11 ++++------- .../components/AttachmentPolicyEditingModal.vue | 15 ++++----------- .../components/AttachmentUploadModal.vue | 7 +++++-- ui/src/locales/zh-CN.yaml | 2 ++ 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue index fd724c9ace..68e9be5ff0 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue @@ -44,15 +44,12 @@ const modalTitle = props.group const handleSave = async () => { try { isSubmitting.value = true; - const existingGroupsResponse = - await coreApiClient.storage.group.listGroup(); - const existingGroups = existingGroupsResponse.data.items || []; - const nameExists = existingGroups.some( + const { data: groups } = await coreApiClient.storage.group.listGroup(); + const hasDisplayNameDuplicate = groups.items.some( (group) => group.spec.displayName === formState.value.spec.displayName ); - - if (nameExists) { - alert("该分组名称已存在,请重新创建!"); + if (hasDisplayNameDuplicate) { + Toast.error(t("core.common.toast.group_name_exists")); return; } diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue index 0cf15cb852..367b4d5e1c 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue @@ -47,14 +47,6 @@ const formState = ref({ const isUpdateMode = !!props.policy; -const { data: policies } = useQuery({ - queryKey: ["core:attachment:policies"], - queryFn: async () => { - const { data } = await coreApiClient.storage.policy.listPolicy(); // 修改为 listPolicy - return data; - }, -}); - onMounted(async () => { if (props.policy) { formState.value = cloneDeep(props.policy); @@ -143,12 +135,13 @@ const submitting = ref(false); const handleSave = async () => { try { submitting.value = true; - const nameExists = policies.value?.items.some( + const { data: policies } = await coreApiClient.storage.policy.listPolicy(); + const hasDisplayNameDuplicate = policies.items.some( (policy) => policy.spec.displayName === formState.value.spec.displayName ); - if (nameExists) { - alert("该存储策略名称已存在,请重新创建!"); + if (hasDisplayNameDuplicate) { + Toast.error(t("core.common.toast.policy_name_exists")); return; } diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue index b53d04e6d5..3909595b2c 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue @@ -143,14 +143,17 @@ const onGroupEditingModalClose = async () => { @click="selectedGroupName = group.metadata.name" /> - + - + Date: Tue, 29 Oct 2024 15:26:40 +0800 Subject: [PATCH 5/8] Refine i18n Signed-off-by: Ryan Wang --- .../AttachmentGroupEditingModal.vue | 4 ++- .../AttachmentPolicyEditingModal.vue | 4 ++- ui/src/locales/en.yaml | 29 ++++++++++++++----- ui/src/locales/zh-CN.yaml | 6 ++-- ui/src/locales/zh-TW.yaml | 4 +++ 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue index 68e9be5ff0..21f12b46a3 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue @@ -49,7 +49,9 @@ const handleSave = async () => { (group) => group.spec.displayName === formState.value.spec.displayName ); if (hasDisplayNameDuplicate) { - Toast.error(t("core.common.toast.group_name_exists")); + Toast.error( + t("core.attachment.group_editing_modal.toast.group_name_exists") + ); return; } diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue index 367b4d5e1c..d5cb89475b 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue @@ -141,7 +141,9 @@ const handleSave = async () => { ); if (hasDisplayNameDuplicate) { - Toast.error(t("core.common.toast.policy_name_exists")); + Toast.error( + t("core.attachment.policy_editing_modal.toast.policy_name_exists") + ); return; } diff --git a/ui/src/locales/en.yaml b/ui/src/locales/en.yaml index 1936b5beb5..4de7d181e9 100644 --- a/ui/src/locales/en.yaml +++ b/ui/src/locales/en.yaml @@ -26,7 +26,9 @@ core: logout: tooltip: Logout title: Logout - description: Clicking Confirm will redirect to the logout page. Please ensure that the content you are editing is saved. + description: >- + Clicking Confirm will redirect to the logout page. Please ensure that + the content you are editing is saved. profile: tooltip: Profile visit_homepage: @@ -598,6 +600,8 @@ core: fields: display_name: label: Display name + toast: + group_name_exists: Group name already exists group_list: internal_groups: all: All @@ -643,6 +647,8 @@ core: fields: display_name: label: Display name + toast: + policy_name_exists: Storage policy name already exists upload_modal: title: Upload attachment filters: @@ -666,8 +672,8 @@ core: empty: title: There are no attachments. message: >- - There are no attachments, you can try refreshing or - uploading attachments. + There are no attachments, you can try refreshing or uploading + attachments. actions: upload: Upload Attachment filters: @@ -1457,7 +1463,9 @@ core: first: >- 1. The restore process may last for a long time, please do not refresh the page during this period. - second: 2. Before performing the restore, all existing data will be cleared. Please ensure that there is no data that needs to be retained. + second: >- + 2. Before performing the restore, all existing data will be cleared. + Please ensure that there is no data that needs to be retained. third: >- 3. After the restore is completed, you need to restart Halo to load the system resources normally. @@ -1673,7 +1681,9 @@ core: creation_label: Create {text} tag validation: trim: Please remove the leading and trailing spaces - password: "The password can only use uppercase and lowercase letters (A-Z, a-z), numbers (0-9), and the following special characters: !{'@'}#$%^&*" + password: >- + The password can only use uppercase and lowercase letters (A-Z, a-z), + numbers (0-9), and the following special characters: !{'@'}#$%^&* verification_form: no_action_defined: "{label} interface not defined" verify_success: "{label} successful" @@ -1791,7 +1801,10 @@ core: editor_not_found: >- No editor found that matches the {raw_type} format. Please check if the editor plugin has been installed. - login_expired: The current session has expired. Click Confirm to go to the login page. Please ensure that the current content is saved. You can click Cancel to manually copy any unsaved content. + login_expired: >- + The current session has expired. Click Confirm to go to the login + page. Please ensure that the current content is saved. You can click + Cancel to manually copy any unsaved content. filters: results: keyword: "Keyword: {keyword}" @@ -1832,7 +1845,9 @@ core: title: Cancel publish delete: title: Delete post - description: This action will move the post to the recycle bin, where it will be managed by the site administrator. + description: >- + This action will move the post to the recycle bin, where it will be + managed by the site administrator. publish_modal: title: Publish post setting_modal: diff --git a/ui/src/locales/zh-CN.yaml b/ui/src/locales/zh-CN.yaml index 7a6612dde1..5ad468be78 100644 --- a/ui/src/locales/zh-CN.yaml +++ b/ui/src/locales/zh-CN.yaml @@ -572,6 +572,8 @@ core: fields: display_name: label: 名称 + toast: + group_name_exists: 分组名称已存在 group_list: internal_groups: all: 全部 @@ -607,6 +609,8 @@ core: fields: display_name: label: 名称 + toast: + policy_name_exists: 存储策略名称已存在 upload_modal: title: 上传附件 filters: @@ -1671,8 +1675,6 @@ core: unknown_error: 未知错误 disable_success: 禁用成功 enable_success: 啟用成功 - group_name_exists: 该分组名称已存在,请重新创建 - policy_name_exists: 该存储策略已存在,请重新创建 dialog: titles: tip: 提示 diff --git a/ui/src/locales/zh-TW.yaml b/ui/src/locales/zh-TW.yaml index fed0c13f2a..9fb191650f 100644 --- a/ui/src/locales/zh-TW.yaml +++ b/ui/src/locales/zh-TW.yaml @@ -549,6 +549,8 @@ core: fields: display_name: label: 名稱 + toast: + group_name_exists: 分組名稱已存在 group_list: internal_groups: all: 全部 @@ -584,6 +586,8 @@ core: fields: display_name: label: 名稱 + toast: + policy_name_exists: 儲存策略名稱已存在 upload_modal: title: 上傳附件 filters: From cccc770be2acd13b374d7cb8823bcdd86ffa5962 Mon Sep 17 00:00:00 2001 From: Nancy <3510671794@qq.com> Date: Tue, 29 Oct 2024 20:42:40 +0800 Subject: [PATCH 6/8] Fix hidden issues based on review --- .../AttachmentGroupEditingModal.vue | 20 +++++++++------- .../AttachmentPolicyEditingModal.vue | 24 +++++++++++-------- .../components/AttachmentUploadModal.vue | 10 +++++++- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue index 21f12b46a3..afa0fd23e7 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentGroupEditingModal.vue @@ -11,9 +11,11 @@ import { useI18n } from "vue-i18n"; const props = withDefaults( defineProps<{ group?: Group; + isNew?: boolean; }>(), { group: undefined, + isNew: false, } ); @@ -44,15 +46,17 @@ const modalTitle = props.group const handleSave = async () => { try { isSubmitting.value = true; - 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") + if (props.isNew) { + const { data: groups } = await coreApiClient.storage.group.listGroup(); + const hasDisplayNameDuplicate = groups.items.some( + (group) => group.spec.displayName === formState.value.spec.displayName ); - return; + if (hasDisplayNameDuplicate) { + Toast.error( + t("core.attachment.group_editing_modal.toast.group_name_exists") + ); + return; + } } if (props.group) { diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue index d5cb89475b..86e7192b28 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentPolicyEditingModal.vue @@ -14,10 +14,12 @@ const props = withDefaults( defineProps<{ policy?: Policy; templateName?: string; + isNew?: boolean; }>(), { policy: undefined, templateName: undefined, + isNew: false, } ); @@ -135,18 +137,20 @@ const submitting = ref(false); const handleSave = async () => { try { submitting.value = true; - const { data: policies } = await coreApiClient.storage.policy.listPolicy(); - const hasDisplayNameDuplicate = policies.items.some( - (policy) => policy.spec.displayName === formState.value.spec.displayName - ); - - if (hasDisplayNameDuplicate) { - Toast.error( - t("core.attachment.policy_editing_modal.toast.policy_name_exists") + if (props.isNew) { + const { data: policies } = + await coreApiClient.storage.policy.listPolicy(); + const hasDisplayNameDuplicate = policies.items.some( + (policy) => policy.spec.displayName === formState.value.spec.displayName ); - return; - } + if (hasDisplayNameDuplicate) { + Toast.error( + t("core.attachment.policy_editing_modal.toast.policy_name_exists") + ); + return; + } + } const configMapToUpdate = convertToSave(); if (isUpdateMode) { diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue b/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue index 3909595b2c..33a8cb4d08 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentUploadModal.vue @@ -33,6 +33,8 @@ const selectedGroupName = useLocalStorage("attachment-upload-group", ""); const selectedPolicyName = useLocalStorage("attachment-upload-policy", ""); const policyEditingModal = ref(false); const groupEditingModal = ref(false); +const isNewPolicy = ref(false); +const isNewGroup = ref(false); const policyTemplateNameToCreate = ref(); onMounted(() => { @@ -41,12 +43,16 @@ onMounted(() => { } }); -const handleOpenCreateNewPolicyModal = (policyTemplate: PolicyTemplate) => { +const handleOpenCreateNewPolicyModal = async ( + policyTemplate: PolicyTemplate +) => { policyTemplateNameToCreate.value = policyTemplate.metadata.name; + isNewPolicy.value = true; policyEditingModal.value = true; }; const handleOpenCreateNewGroupModal = () => { + isNewGroup.value = true; groupEditingModal.value = true; }; @@ -177,11 +183,13 @@ const onGroupEditingModalClose = async () => { From d74791392c60a8a70bb1005347ddeadf4b520216 Mon Sep 17 00:00:00 2001 From: Nancy <3510671794@qq.com> Date: Tue, 29 Oct 2024 21:37:33 +0800 Subject: [PATCH 7/8] Refine and resolve hidden issues based on the review --- .../attachments/components/AttachmentGroupList.vue | 11 +++++++++-- .../components/AttachmentPoliciesModal.vue | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentGroupList.vue b/ui/console-src/modules/contents/attachments/components/AttachmentGroupList.vue index b8b01d3956..9676cfa4a3 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 @@