diff --git a/console/src/modules/contents/pages/SinglePageList.vue b/console/src/modules/contents/pages/SinglePageList.vue index 900d185fe..8790bdf26 100644 --- a/console/src/modules/contents/pages/SinglePageList.vue +++ b/console/src/modules/contents/pages/SinglePageList.vue @@ -2,11 +2,8 @@ import { IconArrowLeft, IconArrowRight, - IconEye, - IconEyeOff, IconAddCircle, IconRefreshLine, - IconExternalLinkLine, IconPages, VButton, VCard, @@ -14,31 +11,23 @@ import { VSpace, Dialog, VEmpty, - VAvatar, - VStatusDot, - VEntity, - VEntityField, VLoading, VPageHeader, Toast, - VDropdownItem, - VDropdownDivider, } from "@halo-dev/components"; import SinglePageSettingModal from "./components/SinglePageSettingModal.vue"; import { computed, ref, watch } from "vue"; import type { ListedSinglePage, SinglePage } from "@halo-dev/api-client"; import { apiClient } from "@/utils/api-client"; -import { formatDatetime } from "@/utils/date"; -import { RouterLink } from "vue-router"; -import cloneDeep from "lodash.clonedeep"; -import { usePermission } from "@/utils/permission"; import { singlePageLabels } from "@/constants/labels"; -import { useMutation, useQuery } from "@tanstack/vue-query"; +import { useQuery } from "@tanstack/vue-query"; import { useI18n } from "vue-i18n"; import UserFilterDropdown from "@/components/filter/UserFilterDropdown.vue"; +import SinglePageListItem from "./components/SinglePageListItem.vue"; +import { provide } from "vue"; +import type { Ref } from "vue"; import { useRouteQuery } from "@vueuse/router"; -const { currentUserHasPermission } = usePermission(); const { t } = useI18n(); const settingModal = ref(false); @@ -46,6 +35,8 @@ const selectedSinglePage = ref(); const selectedPageNames = ref([]); const checkedAll = ref(false); +provide>("selectedPageNames", selectedPageNames); + // Filters const selectedContributor = useRouteQuery("contributor"); const selectedVisible = useRouteQuery< @@ -233,29 +224,6 @@ const handleCheckAllChange = (e: Event) => { } }; -const handleDelete = async (singlePage: SinglePage) => { - Dialog.warning({ - title: t("core.page.operations.delete.title"), - description: t("core.page.operations.delete.description"), - confirmType: "danger", - confirmText: t("core.common.buttons.confirm"), - cancelText: t("core.common.buttons.cancel"), - onConfirm: async () => { - const singlePageToUpdate = cloneDeep(singlePage); - singlePageToUpdate.spec.deleted = true; - await apiClient.extension.singlePage.updatecontentHaloRunV1alpha1SinglePage( - { - name: singlePage.metadata.name, - singlePage: singlePageToUpdate, - } - ); - await refetch(); - - Toast.success(t("core.common.toast.delete_success")); - }, - }); -}; - const handleDeleteInBatch = async () => { Dialog.warning({ title: t("core.page.operations.delete_in_batch.title"), @@ -296,59 +264,9 @@ const handleDeleteInBatch = async () => { }); }; -const getPublishStatus = (singlePage: SinglePage) => { - const { labels } = singlePage.metadata; - return labels?.[singlePageLabels.PUBLISHED] === "true" - ? t("core.page.filters.status.items.published") - : t("core.page.filters.status.items.draft"); -}; - -const isPublishing = (singlePage: SinglePage) => { - const { spec, status, metadata } = singlePage; - return ( - (spec.publish && - metadata.labels?.[singlePageLabels.PUBLISHED] !== "true") || - (spec.releaseSnapshot === spec.headSnapshot && status?.inProgress) - ); -}; - watch(selectedPageNames, (newValue) => { checkedAll.value = newValue.length === singlePages.value?.length; }); - -const { mutate: changeVisibleMutation } = useMutation({ - mutationFn: async (singlePage: SinglePage) => { - const { data } = - await apiClient.extension.singlePage.getcontentHaloRunV1alpha1SinglePage({ - name: singlePage.metadata.name, - }); - data.spec.visible = data.spec.visible === "PRIVATE" ? "PUBLIC" : "PRIVATE"; - await apiClient.extension.singlePage.updatecontentHaloRunV1alpha1SinglePage( - { - name: singlePage.metadata.name, - singlePage: data, - }, - { - mute: true, - } - ); - await refetch(); - }, - retry: 3, - onSuccess: () => { - Toast.success(t("core.common.toast.operation_success")); - }, - onError: () => { - Toast.error(t("core.common.toast.operation_failed")); - }, -}); - -const getExternalUrl = (singlePage: SinglePage) => { - if (singlePage.metadata.labels?.[singlePageLabels.PUBLISHED] === "true") { - return singlePage.status?.permalink; - } - return `/preview/singlepages/${singlePage.metadata.name}`; -};