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,
|
||||
parentPageId: restoredPage.parentPageId,
|
||||
hasChildren: restoredPage.hasChildren || false,
|
||||
isBase: restoredPage.isBase,
|
||||
children: [],
|
||||
};
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { Modal, Text, ScrollArea } from "@mantine/core";
|
||||
import { IconTable } from "@tabler/icons-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import ReadonlyPageEditor from "@/features/editor/readonly-page-editor.tsx";
|
||||
import { EmptyState } from "@/components/ui/empty-state.tsx";
|
||||
|
||||
interface Props {
|
||||
opened: boolean;
|
||||
onClose: () => void;
|
||||
pageTitle: string;
|
||||
pageContent: any;
|
||||
isBase?: boolean;
|
||||
}
|
||||
|
||||
export default function TrashPageContentModal({
|
||||
@@ -14,6 +17,7 @@ export default function TrashPageContentModal({
|
||||
onClose,
|
||||
pageTitle,
|
||||
pageContent,
|
||||
isBase,
|
||||
}: Props) {
|
||||
const { t } = useTranslation();
|
||||
const title = pageTitle || t("Untitled");
|
||||
@@ -32,7 +36,15 @@ export default function TrashPageContentModal({
|
||||
</Modal.Header>
|
||||
<Modal.Body p={0}>
|
||||
<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>
|
||||
</Modal.Body>
|
||||
</Modal.Content>
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
IconDots,
|
||||
IconRestore,
|
||||
IconTrash,
|
||||
IconFileDescription,
|
||||
} from "@tabler/icons-react";
|
||||
import { TrashBanner } from "@/features/page/trash/components/trash-banner.tsx";
|
||||
import {
|
||||
@@ -31,6 +30,7 @@ import { UserInfo } from "@/components/common/user-info.tsx";
|
||||
import Paginate from "@/components/common/paginate.tsx";
|
||||
import { useCursorPaginate } from "@/hooks/use-cursor-paginate";
|
||||
import { useRestorePageModal } from "@/features/page/hooks/use-restore-page-modal.tsx";
|
||||
import { PageListIcon } from "@/components/common/page-list-icon";
|
||||
|
||||
export default function Trash() {
|
||||
const { t } = useTranslation();
|
||||
@@ -47,6 +47,7 @@ export default function Trash() {
|
||||
const [selectedPage, setSelectedPage] = useState<{
|
||||
title: string;
|
||||
content: any;
|
||||
isBase?: boolean;
|
||||
} | null>(null);
|
||||
const [modalOpened, setModalOpened] = useState(false);
|
||||
|
||||
@@ -79,7 +80,11 @@ export default function Trash() {
|
||||
const hasPages = deletedPages && deletedPages.items.length > 0;
|
||||
|
||||
const handlePageClick = (page: any) => {
|
||||
setSelectedPage({ title: page.title, content: page.content });
|
||||
setSelectedPage({
|
||||
title: page.title,
|
||||
content: page.content,
|
||||
isBase: page.isBase,
|
||||
});
|
||||
setModalOpened(true);
|
||||
};
|
||||
|
||||
@@ -118,15 +123,7 @@ export default function Trash() {
|
||||
style={{ cursor: "pointer" }}
|
||||
onClick={() => handlePageClick(page)}
|
||||
>
|
||||
{page.icon || (
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
color="gray"
|
||||
size={18}
|
||||
>
|
||||
<IconFileDescription size={18} />
|
||||
</ActionIcon>
|
||||
)}
|
||||
<PageListIcon icon={page.icon} isBase={page.isBase} />
|
||||
<div>
|
||||
<Text fw={500} size="sm" lineClamp={1}>
|
||||
{page.title || t("Untitled")}
|
||||
@@ -207,6 +204,7 @@ export default function Trash() {
|
||||
onClose={() => setModalOpened(false)}
|
||||
pageTitle={selectedPage.title}
|
||||
pageContent={selectedPage.content}
|
||||
isBase={selectedPage.isBase}
|
||||
/>
|
||||
)}
|
||||
</Container>
|
||||
|
||||
Reference in New Issue
Block a user