From bdbbbdf3afbe4581e005e4089fbe28a25bd9a116 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Sat, 6 Sep 2025 10:09:38 +0800 Subject: [PATCH] Disable persistence of selected group and policy in attachment upload modal (#7738) 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.21.x #### What this PR does / why we need it: In the attachment upload modal, we previously persisted the user’s selected storage policy and group to make future uploads more convenient. However, this overlooked a common usage scenario—users often apply filters for storage policy and group in the attachment list before uploading. Persisting those previous selections could then conflict with the current filters and cause confusion. This PR removes the persistence of selected group and storage policy to avoid such mismatches. #### Which issue(s) this PR fixes: Fixes #7713 #### Does this PR introduce a user-facing change? ```release-note 在附件上传组件中取消所选分组和存储策略的持久化,默认选择为附件列表筛选条件相同的策略和分组。 ``` --- .../modules/contents/attachments/AttachmentList.vue | 9 ++++++++- .../components/AttachmentUploadModal.vue | 10 +++++++--- .../attachments/components/UploadFromUrl.vue | 13 ++++++++++--- .../selector-providers/CoreSelectorProvider.vue | 9 ++++++++- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/ui/console-src/modules/contents/attachments/AttachmentList.vue b/ui/console-src/modules/contents/attachments/AttachmentList.vue index f897d9343..051cbcaf6 100644 --- a/ui/console-src/modules/contents/attachments/AttachmentList.vue +++ b/ui/console-src/modules/contents/attachments/AttachmentList.vue @@ -249,7 +249,14 @@ const thumbnailsVisible = ref(false); - + (); + const emit = defineEmits<{ (event: "close"): void; }>(); @@ -31,8 +35,8 @@ const { policies, handleFetchPolicies } = useFetchAttachmentPolicy(); const { policyTemplates } = useFetchAttachmentPolicyTemplate(); const modal = ref | null>(null); -const selectedGroupName = useLocalStorage("attachment-upload-group", ""); -const selectedPolicyName = useLocalStorage("attachment-upload-policy", ""); +const selectedGroupName = ref(initialGroupName || ""); +const selectedPolicyName = ref(initialPolicyName); const policyEditingModal = ref(false); const groupEditingModal = ref(false); const policyTemplateNameToCreate = ref(); diff --git a/ui/console-src/modules/contents/attachments/components/UploadFromUrl.vue b/ui/console-src/modules/contents/attachments/components/UploadFromUrl.vue index d80bf9d43..821b7368f 100644 --- a/ui/console-src/modules/contents/attachments/components/UploadFromUrl.vue +++ b/ui/console-src/modules/contents/attachments/components/UploadFromUrl.vue @@ -10,10 +10,13 @@ const { t } = useI18n(); const props = withDefaults( defineProps<{ - policyName: string; - groupName: string; + policyName?: string; + groupName?: string; }>(), - {} + { + policyName: undefined, + groupName: undefined, + } ); onMounted(() => { @@ -26,6 +29,10 @@ async function onSubmit(data: { url: string }) { try { downloading.value = true; + if (!props.policyName) { + throw new Error("Policy name is required"); + } + await consoleApiClient.storage.attachment.externalTransferAttachment({ uploadFromUrlRequest: { url: data.url, diff --git a/ui/console-src/modules/contents/attachments/components/selector-providers/CoreSelectorProvider.vue b/ui/console-src/modules/contents/attachments/components/selector-providers/CoreSelectorProvider.vue index f469af09d..064e863ad 100644 --- a/ui/console-src/modules/contents/attachments/components/selector-providers/CoreSelectorProvider.vue +++ b/ui/console-src/modules/contents/attachments/components/selector-providers/CoreSelectorProvider.vue @@ -413,7 +413,14 @@ const viewType = useLocalStorage("attachment-selector-view-type", "grid"); :size-options="[60, 120, 200]" /> - +