mirror of
https://github.com/docmost/docmost.git
synced 2026-06-15 22:48:42 +08:00
fix: base trash list handling
This commit is contained in:
@@ -193,6 +193,7 @@ export function useRestorePageMutation() {
|
|||||||
spaceId: restoredPage.spaceId,
|
spaceId: restoredPage.spaceId,
|
||||||
parentPageId: restoredPage.parentPageId,
|
parentPageId: restoredPage.parentPageId,
|
||||||
hasChildren: restoredPage.hasChildren || false,
|
hasChildren: restoredPage.hasChildren || false,
|
||||||
|
isBase: restoredPage.isBase,
|
||||||
children: [],
|
children: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import { Modal, Text, ScrollArea } from "@mantine/core";
|
import { Modal, Text, ScrollArea } from "@mantine/core";
|
||||||
|
import { IconTable } from "@tabler/icons-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import ReadonlyPageEditor from "@/features/editor/readonly-page-editor.tsx";
|
import ReadonlyPageEditor from "@/features/editor/readonly-page-editor.tsx";
|
||||||
|
import { EmptyState } from "@/components/ui/empty-state.tsx";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
opened: boolean;
|
opened: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
pageTitle: string;
|
pageTitle: string;
|
||||||
pageContent: any;
|
pageContent: any;
|
||||||
|
isBase?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TrashPageContentModal({
|
export default function TrashPageContentModal({
|
||||||
@@ -14,6 +17,7 @@ export default function TrashPageContentModal({
|
|||||||
onClose,
|
onClose,
|
||||||
pageTitle,
|
pageTitle,
|
||||||
pageContent,
|
pageContent,
|
||||||
|
isBase,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const title = pageTitle || t("Untitled");
|
const title = pageTitle || t("Untitled");
|
||||||
@@ -32,7 +36,15 @@ export default function TrashPageContentModal({
|
|||||||
</Modal.Header>
|
</Modal.Header>
|
||||||
<Modal.Body p={0}>
|
<Modal.Body p={0}>
|
||||||
<ScrollArea h="650" w="100%" scrollbarSize={5}>
|
<ScrollArea h="650" w="100%" scrollbarSize={5}>
|
||||||
<ReadonlyPageEditor title={title} content={pageContent} />
|
{isBase ? (
|
||||||
|
<EmptyState
|
||||||
|
icon={IconTable}
|
||||||
|
title={t("Base preview unavailable")}
|
||||||
|
description={t("Restore this base to view its contents.")}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<ReadonlyPageEditor title={title} content={pageContent} />
|
||||||
|
)}
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
</Modal.Content>
|
</Modal.Content>
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import {
|
|||||||
IconDots,
|
IconDots,
|
||||||
IconRestore,
|
IconRestore,
|
||||||
IconTrash,
|
IconTrash,
|
||||||
IconFileDescription,
|
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { TrashBanner } from "@/features/page/trash/components/trash-banner.tsx";
|
import { TrashBanner } from "@/features/page/trash/components/trash-banner.tsx";
|
||||||
import {
|
import {
|
||||||
@@ -31,6 +30,7 @@ import { UserInfo } from "@/components/common/user-info.tsx";
|
|||||||
import Paginate from "@/components/common/paginate.tsx";
|
import Paginate from "@/components/common/paginate.tsx";
|
||||||
import { useCursorPaginate } from "@/hooks/use-cursor-paginate";
|
import { useCursorPaginate } from "@/hooks/use-cursor-paginate";
|
||||||
import { useRestorePageModal } from "@/features/page/hooks/use-restore-page-modal.tsx";
|
import { useRestorePageModal } from "@/features/page/hooks/use-restore-page-modal.tsx";
|
||||||
|
import { PageListIcon } from "@/components/common/page-list-icon";
|
||||||
|
|
||||||
export default function Trash() {
|
export default function Trash() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -47,6 +47,7 @@ export default function Trash() {
|
|||||||
const [selectedPage, setSelectedPage] = useState<{
|
const [selectedPage, setSelectedPage] = useState<{
|
||||||
title: string;
|
title: string;
|
||||||
content: any;
|
content: any;
|
||||||
|
isBase?: boolean;
|
||||||
} | null>(null);
|
} | null>(null);
|
||||||
const [modalOpened, setModalOpened] = useState(false);
|
const [modalOpened, setModalOpened] = useState(false);
|
||||||
|
|
||||||
@@ -79,7 +80,11 @@ export default function Trash() {
|
|||||||
const hasPages = deletedPages && deletedPages.items.length > 0;
|
const hasPages = deletedPages && deletedPages.items.length > 0;
|
||||||
|
|
||||||
const handlePageClick = (page: any) => {
|
const handlePageClick = (page: any) => {
|
||||||
setSelectedPage({ title: page.title, content: page.content });
|
setSelectedPage({
|
||||||
|
title: page.title,
|
||||||
|
content: page.content,
|
||||||
|
isBase: page.isBase,
|
||||||
|
});
|
||||||
setModalOpened(true);
|
setModalOpened(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -118,15 +123,7 @@ export default function Trash() {
|
|||||||
style={{ cursor: "pointer" }}
|
style={{ cursor: "pointer" }}
|
||||||
onClick={() => handlePageClick(page)}
|
onClick={() => handlePageClick(page)}
|
||||||
>
|
>
|
||||||
{page.icon || (
|
<PageListIcon icon={page.icon} isBase={page.isBase} />
|
||||||
<ActionIcon
|
|
||||||
variant="transparent"
|
|
||||||
color="gray"
|
|
||||||
size={18}
|
|
||||||
>
|
|
||||||
<IconFileDescription size={18} />
|
|
||||||
</ActionIcon>
|
|
||||||
)}
|
|
||||||
<div>
|
<div>
|
||||||
<Text fw={500} size="sm" lineClamp={1}>
|
<Text fw={500} size="sm" lineClamp={1}>
|
||||||
{page.title || t("Untitled")}
|
{page.title || t("Untitled")}
|
||||||
@@ -207,6 +204,7 @@ export default function Trash() {
|
|||||||
onClose={() => setModalOpened(false)}
|
onClose={() => setModalOpened(false)}
|
||||||
pageTitle={selectedPage.title}
|
pageTitle={selectedPage.title}
|
||||||
pageContent={selectedPage.content}
|
pageContent={selectedPage.content}
|
||||||
|
isBase={selectedPage.isBase}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
Reference in New Issue
Block a user