From b604532a7b903f693d031024a2eb05988a46bb62 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Mon, 28 Nov 2022 22:00:18 +0800 Subject: [PATCH] fix: issue of uploading attachments to ungrouped group (#716) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind bug /milestone 2.0-rc.2 #### What this PR does / why we need it: 修复选择未分组的分组时,上传附件会将分组设置为 `ungrouped` 的问题。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2777 #### Special notes for your reviewer: 测试方式: 1. 新建若干附件分组。 2. 切换到未分组,然后打开上传弹框,上传若干附件。 3. 检查所上传附件是否归为未分组。 4. 切换到其他分组,上传若干附件,检查所上传附件是否归为正确分组。 #### Does this PR introduce a user-facing change? ```release-note 修复在 Console 端选择未分组的分组时,上传附件会将分组设置为 `ungrouped` 的问题。 ``` --- .../components/AttachmentUploadModal.vue | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/modules/contents/attachments/components/AttachmentUploadModal.vue b/src/modules/contents/attachments/components/AttachmentUploadModal.vue index cfbf8318..05665690 100644 --- a/src/modules/contents/attachments/components/AttachmentUploadModal.vue +++ b/src/modules/contents/attachments/components/AttachmentUploadModal.vue @@ -20,6 +20,13 @@ const props = withDefaults( } ); +const groupName = computed(() => { + if (props.group?.metadata.name === "ungrouped") { + return ""; + } + return props.group?.metadata.name; +}); + const emit = defineEmits<{ (event: "update:visible", visible: boolean): void; (event: "close"): void; @@ -37,10 +44,13 @@ const uploadVisible = ref(false); const policyEditingModal = ref(false); const modalTitle = computed(() => { - if (props.group && props.group.metadata.name) { + if ( + props.group?.metadata.name && + props.group?.metadata.name !== "ungrouped" + ) { return `上传附件到分组:${props.group.spec.displayName}`; } - return "上传附件"; + return "上传附件到未分组"; }); watchEffect(() => { @@ -173,7 +183,7 @@ watch( :disabled="!selectedPolicy" :meta="{ policyName: selectedPolicy?.metadata.name as string, - groupName: props.group?.metadata.name as string + groupName: groupName }" :allowed-meta-fields="['policyName', 'groupName']" :note="selectedPolicy ? '' : '请先选择存储策略'"