mirror of https://github.com/halo-dev/halo
Disable persistence of selected group and policy in attachment upload modal (#7738)
#### 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 在附件上传组件中取消所选分组和存储策略的持久化,默认选择为附件列表筛选条件相同的策略和分组。 ```pull/7743/head
parent
e8d547e506
commit
bdbbbdf3af
|
@ -249,7 +249,14 @@ const thumbnailsVisible = ref(false);
|
|||
</span>
|
||||
</template>
|
||||
</AttachmentDetailModal>
|
||||
<AttachmentUploadModal v-if="uploadVisible" @close="onUploadModalClose" />
|
||||
<AttachmentUploadModal
|
||||
v-if="uploadVisible"
|
||||
:initial-group-name="
|
||||
selectedGroup === 'ungrouped' ? undefined : selectedGroup
|
||||
"
|
||||
:initial-policy-name="selectedPolicy"
|
||||
@close="onUploadModalClose"
|
||||
/>
|
||||
<AttachmentPoliciesModal
|
||||
v-if="policyVisible"
|
||||
@close="policyVisible = false"
|
||||
|
|
|
@ -9,7 +9,6 @@ import {
|
|||
VTabItem,
|
||||
VTabs,
|
||||
} from "@halo-dev/components";
|
||||
import { useLocalStorage } from "@vueuse/core";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useFetchAttachmentGroup } from "../composables/use-attachment-group";
|
||||
import {
|
||||
|
@ -22,6 +21,11 @@ import AttachmentPolicyBadge from "./AttachmentPolicyBadge.vue";
|
|||
import AttachmentPolicyEditingModal from "./AttachmentPolicyEditingModal.vue";
|
||||
import UploadFromUrl from "./UploadFromUrl.vue";
|
||||
|
||||
const { initialPolicyName, initialGroupName } = defineProps<{
|
||||
initialPolicyName?: string;
|
||||
initialGroupName?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: "close"): void;
|
||||
}>();
|
||||
|
@ -31,8 +35,8 @@ const { policies, handleFetchPolicies } = useFetchAttachmentPolicy();
|
|||
const { policyTemplates } = useFetchAttachmentPolicyTemplate();
|
||||
|
||||
const modal = ref<InstanceType<typeof VModal> | 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();
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -413,7 +413,14 @@ const viewType = useLocalStorage("attachment-selector-view-type", "grid");
|
|||
:size-options="[60, 120, 200]"
|
||||
/>
|
||||
</div>
|
||||
<AttachmentUploadModal v-if="uploadVisible" @close="onUploadModalClose" />
|
||||
<AttachmentUploadModal
|
||||
v-if="uploadVisible"
|
||||
:initial-group-name="
|
||||
selectedGroup === 'ungrouped' ? undefined : selectedGroup
|
||||
"
|
||||
:initial-policy-name="selectedPolicy"
|
||||
@close="onUploadModalClose"
|
||||
/>
|
||||
<AttachmentDetailModal
|
||||
v-if="selectedAttachment"
|
||||
:mount-to-body="true"
|
||||
|
|
Loading…
Reference in New Issue