diff --git a/ui/console-src/modules/contents/pages/SinglePageSnapshots.vue b/ui/console-src/modules/contents/pages/SinglePageSnapshots.vue
index fb0e5ad95..246bcee87 100644
--- a/ui/console-src/modules/contents/pages/SinglePageSnapshots.vue
+++ b/ui/console-src/modules/contents/pages/SinglePageSnapshots.vue
@@ -1,12 +1,15 @@
@@ -78,9 +121,14 @@ watch(
-
- {{ $t("core.common.buttons.back") }}
-
+
+
+ {{ $t("core.common.buttons.back") }}
+
+
+ {{ $t("core.page_snapshots.operations.cleanup.button") }}
+
+
diff --git a/ui/console-src/modules/contents/pages/components/SnapshotListItem.vue b/ui/console-src/modules/contents/pages/components/SnapshotListItem.vue
index d4ad9446b..bdc3bcadb 100644
--- a/ui/console-src/modules/contents/pages/components/SnapshotListItem.vue
+++ b/ui/console-src/modules/contents/pages/components/SnapshotListItem.vue
@@ -109,6 +109,9 @@ const isBase = computed(() => {
{{ $t("core.page_snapshots.status.draft") }}
+
+ {{ $t("core.page_snapshots.status.base") }}
+
import {
+ Dialog,
IconHistoryLine,
+ Toast,
VButton,
VCard,
VLoading,
VPageHeader,
+ VSpace,
} from "@halo-dev/components";
-import { useQuery } from "@tanstack/vue-query";
+import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { useRoute } from "vue-router";
import { apiClient } from "@/utils/api-client";
import { computed, watch } from "vue";
@@ -14,8 +17,11 @@ import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
import { useRouteQuery } from "@vueuse/router";
import SnapshotContent from "@console/modules/contents/posts/components/SnapshotContent.vue";
import SnapshotListItem from "@console/modules/contents/posts/components/SnapshotListItem.vue";
+import { useI18n } from "vue-i18n";
+const { t } = useI18n();
const route = useRoute();
+const queryClient = useQueryClient();
const postName = computed(() => route.query.name as string);
@@ -70,6 +76,43 @@ watch(
immediate: true,
}
);
+
+function handleCleanup() {
+ Dialog.warning({
+ title: t("core.post_snapshots.operations.cleanup.title"),
+ description: t("core.post_snapshots.operations.cleanup.description"),
+ confirmText: t("core.common.buttons.confirm"),
+ cancelText: t("core.common.buttons.cancel"),
+ async onConfirm() {
+ const { releaseSnapshot, baseSnapshot, headSnapshot } =
+ post.value?.spec || {};
+ const snapshotsToDelete = snapshots.value?.filter((snapshot) => {
+ const { name } = snapshot.metadata;
+ return ![releaseSnapshot, baseSnapshot, headSnapshot]
+ .filter(Boolean)
+ .includes(name);
+ });
+
+ if (!snapshotsToDelete?.length) {
+ Toast.info(t("core.post_snapshots.operations.cleanup.toast_empty"));
+ return;
+ }
+
+ for (let i = 0; i < snapshotsToDelete?.length; i++) {
+ await apiClient.post.deletePostContent({
+ name: postName.value,
+ snapshotName: snapshotsToDelete[i].metadata.name,
+ });
+ }
+
+ await queryClient.invalidateQueries({
+ queryKey: ["post-snapshots-by-post-name", postName],
+ });
+
+ Toast.success(t("core.post_snapshots.operations.cleanup.toast_success"));
+ },
+ });
+}
@@ -78,9 +121,14 @@ watch(
-
- {{ $t("core.common.buttons.back") }}
-
+
+
+ {{ $t("core.common.buttons.back") }}
+
+
+ {{ $t("core.post_snapshots.operations.cleanup.button") }}
+
+
diff --git a/ui/console-src/modules/contents/posts/components/SnapshotListItem.vue b/ui/console-src/modules/contents/posts/components/SnapshotListItem.vue
index 4790d2646..5d5e0ada4 100644
--- a/ui/console-src/modules/contents/posts/components/SnapshotListItem.vue
+++ b/ui/console-src/modules/contents/posts/components/SnapshotListItem.vue
@@ -107,6 +107,9 @@ const isBase = computed(() => {
{{ $t("core.post_snapshots.status.draft") }}
+
+ {{ $t("core.post_snapshots.status.base") }}
+
-
Are you sure you want to delete this snapshot? This operation is
irreversible.
+ cleanup:
+ button: Cleanup
+ title: Cleanup snapshots
+ description: >-
+ Are you sure you want to delete all unused snapshots? Only published,
+ base version, and draft versions will be retained.
+ toast_empty: There are no snapshots to be cleaned up
+ toast_success: Cleanup completed
status:
released: Released
draft: Draft
+ base: Base
title: Post snapshots
page_snapshots:
operations:
@@ -1710,7 +1719,16 @@ core:
description: >-
Are you sure you want to delete this snapshot? This operation is
irreversible.
+ cleanup:
+ button: Cleanup
+ title: Cleanup snapshots
+ description: >-
+ Are you sure you want to delete all unused snapshots? Only published,
+ base version, and draft versions will be retained.
+ toast_empty: There are no snapshots to be cleaned up
+ toast_success: Cleanup completed
status:
released: Released
draft: Draft
+ base: Base
title: Page snapshots
diff --git a/ui/src/locales/zh-CN.yaml b/ui/src/locales/zh-CN.yaml
index 340bf01ff..bc6ad04cd 100644
--- a/ui/src/locales/zh-CN.yaml
+++ b/ui/src/locales/zh-CN.yaml
@@ -1592,9 +1592,16 @@ core:
delete:
title: 删除快照
description: 确定要删除该快照吗?此操作无法恢复。
+ cleanup:
+ button: 清理
+ title: 清理快照
+ description: 确定要清理所有不再使用的快照吗?只会保留已发布、基础和草稿版本。
+ toast_empty: 没有需要清理的快照
+ toast_success: 清理完成
status:
released: 已发布
draft: 草稿
+ base: 基础
title: 文章版本历史
page_snapshots:
operations:
@@ -1606,7 +1613,14 @@ core:
delete:
title: 删除快照
description: 确定要删除该快照吗?此操作无法恢复。
+ cleanup:
+ button: 清理
+ title: 清理快照
+ description: 确定要清理所有不再使用的快照吗?只会保留已发布、基础和草稿版本。
+ toast_empty: 没有需要清理的快照
+ toast_success: 清理完成
status:
released: 已发布
draft: 草稿
+ base: 基础
title: 页面版本历史
diff --git a/ui/src/locales/zh-TW.yaml b/ui/src/locales/zh-TW.yaml
index 28aadb308..cf477f902 100644
--- a/ui/src/locales/zh-TW.yaml
+++ b/ui/src/locales/zh-TW.yaml
@@ -1586,9 +1586,16 @@ core:
delete:
title: 刪除快照
description: 確定要刪除該快照嗎?此操作無法恢復。
+ cleanup:
+ button: 清理
+ title: 清理快照
+ description: 確定要清理所有不再使用的快照嗎?只會保留已發佈、基礎和草稿版本。
+ toast_empty: 沒有需要清理的快照
+ toast_success: 清理完成
status:
released: 已發布
draft: 草稿
+ base: 基礎
title: 文章版本歷史
page_snapshots:
operations:
@@ -1600,7 +1607,14 @@ core:
delete:
title: 刪除快照
description: 確定要刪除該快照嗎?此操作無法恢復。
+ cleanup:
+ button: 清理
+ title: 清理快照
+ description: 確定要清理所有不再使用的快照嗎?只會保留已發佈、基礎和草稿版本。
+ toast_empty: 沒有需要清理的快照
+ toast_success: 清理完成
status:
released: 已發布
draft: 草稿
+ base: 基礎
title: 頁面版本歷史