mirror of https://github.com/halo-dev/halo
feat: add support for deleting an attachment
Signed-off-by: Ryan Wang <i@ryanc.cc>pull/3445/head
parent
e458385968
commit
7f8072419a
|
@ -75,6 +75,7 @@ const {
|
||||||
handleSelectNext,
|
handleSelectNext,
|
||||||
handleSelectPrevious,
|
handleSelectPrevious,
|
||||||
handlePaginationChange,
|
handlePaginationChange,
|
||||||
|
handleDelete,
|
||||||
handleDeleteInBatch,
|
handleDeleteInBatch,
|
||||||
handleCheckAll,
|
handleCheckAll,
|
||||||
handleSelect,
|
handleSelect,
|
||||||
|
@ -632,7 +633,14 @@ onMounted(() => {
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #dropdownItems>
|
<template #dropdownItems>
|
||||||
<VButton v-close-popper block type="danger"> 删除 </VButton>
|
<VButton
|
||||||
|
v-close-popper
|
||||||
|
block
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(attachment)"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</VButton>
|
||||||
</template>
|
</template>
|
||||||
</VEntity>
|
</VEntity>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -28,6 +28,7 @@ interface useAttachmentControlReturn {
|
||||||
}) => void;
|
}) => void;
|
||||||
handleSelectPrevious: () => void;
|
handleSelectPrevious: () => void;
|
||||||
handleSelectNext: () => void;
|
handleSelectNext: () => void;
|
||||||
|
handleDelete: (attachment: Attachment) => void;
|
||||||
handleDeleteInBatch: () => void;
|
handleDeleteInBatch: () => void;
|
||||||
handleCheckAll: (checkAll: boolean) => void;
|
handleCheckAll: (checkAll: boolean) => void;
|
||||||
handleSelect: (attachment: Attachment | undefined) => void;
|
handleSelect: (attachment: Attachment | undefined) => void;
|
||||||
|
@ -132,10 +133,37 @@ export function useAttachmentControl(filterOptions?: {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDelete = (attachment: Attachment) => {
|
||||||
|
dialog.warning({
|
||||||
|
title: "确定要删除该附件吗?",
|
||||||
|
description: "删除之后将无法恢复",
|
||||||
|
confirmType: "danger",
|
||||||
|
onConfirm: async () => {
|
||||||
|
try {
|
||||||
|
await apiClient.extension.storage.attachment.deletestorageHaloRunV1alpha1Attachment(
|
||||||
|
{
|
||||||
|
name: attachment.metadata.name,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
selectedAttachment.value?.metadata.name === attachment.metadata.name
|
||||||
|
) {
|
||||||
|
selectedAttachment.value = undefined;
|
||||||
|
}
|
||||||
|
selectedAttachments.value.delete(attachment);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to delete attachment", e);
|
||||||
|
} finally {
|
||||||
|
await handleFetchAttachments();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleDeleteInBatch = () => {
|
const handleDeleteInBatch = () => {
|
||||||
dialog.warning({
|
dialog.warning({
|
||||||
title: "确定要删除所选的附件吗?",
|
title: "确定要删除所选的附件吗?",
|
||||||
description: "其中 20 个附件包含关联关系,删除之后将无法恢复",
|
description: "删除之后将无法恢复",
|
||||||
confirmType: "danger",
|
confirmType: "danger",
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -211,6 +239,7 @@ export function useAttachmentControl(filterOptions?: {
|
||||||
handlePaginationChange,
|
handlePaginationChange,
|
||||||
handleSelectPrevious,
|
handleSelectPrevious,
|
||||||
handleSelectNext,
|
handleSelectNext,
|
||||||
|
handleDelete,
|
||||||
handleDeleteInBatch,
|
handleDeleteInBatch,
|
||||||
handleCheckAll,
|
handleCheckAll,
|
||||||
handleSelect,
|
handleSelect,
|
||||||
|
|
Loading…
Reference in New Issue