mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 01:56:27 +08:00
fix: page list all, favorite, trash
This commit is contained in:
@@ -30,8 +30,14 @@ import { SyncIcon } from './sync-icon';
|
||||
import { toast } from '@/components/toast';
|
||||
|
||||
const PopoverContent = () => {
|
||||
const { getPageMeta, editor, currentPage } = useAppState();
|
||||
const { mode, setMode, toggleFavoritePage, toggleDeletePage } = useEditor();
|
||||
const {
|
||||
getPageMeta,
|
||||
editor,
|
||||
currentPage,
|
||||
toggleFavoritePage,
|
||||
toggleDeletePage,
|
||||
} = useAppState();
|
||||
const { mode, setMode } = useEditor();
|
||||
const { confirm } = useConfirm();
|
||||
|
||||
const { id, favorite, title } = (currentPage?.id
|
||||
@@ -47,6 +53,7 @@ const PopoverContent = () => {
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
toggleFavoritePage(id);
|
||||
toast(!favorite ? 'Removed to Favourites' : 'Added to Favourites');
|
||||
}}
|
||||
icon={favorite ? <FavouritedIcon /> : <FavouritesIcon />}
|
||||
>
|
||||
@@ -125,7 +132,8 @@ const BrowserWarning = ({
|
||||
};
|
||||
|
||||
const HeaderRight = () => {
|
||||
const { pageList, toggleDeletePage, permanentlyDeletePage } = useEditor();
|
||||
const { pageList, permanentlyDeletePage } = useEditor();
|
||||
const { currentWorkspaceId, toggleDeletePage } = useAppState();
|
||||
const { confirm } = useConfirm();
|
||||
const router = useRouter();
|
||||
const currentPageMeta = pageList.find(p => p.id === router.query.pageId);
|
||||
@@ -158,7 +166,7 @@ const HeaderRight = () => {
|
||||
confirmType: 'danger',
|
||||
}).then(confirm => {
|
||||
if (confirm) {
|
||||
router.push({ pathname: '/page-list/all' });
|
||||
router.push(`/workspace/${currentWorkspaceId}/all`);
|
||||
permanentlyDeletePage(id);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -19,13 +19,16 @@ import React from 'react';
|
||||
import DateCell from '@/components/page-list/date-cell';
|
||||
import { IconButton } from '@/ui/button';
|
||||
import { Tooltip } from '@/ui/tooltip';
|
||||
import { router } from 'next/client';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useAppState } from '@/providers/app-state-provider/context';
|
||||
import { toast } from '@/components/toast';
|
||||
|
||||
const FavoriteTag = ({
|
||||
pageMeta: { favorite, id },
|
||||
}: {
|
||||
pageMeta: PageMeta;
|
||||
}) => {
|
||||
const { toggleFavoritePage } = useEditor();
|
||||
const { toggleFavoritePage } = useAppState();
|
||||
return (
|
||||
<Tooltip
|
||||
content={favorite ? 'Favourited' : 'Favourite'}
|
||||
@@ -37,6 +40,7 @@ const FavoriteTag = ({
|
||||
onClick={e => {
|
||||
e.stopPropagation();
|
||||
toggleFavoritePage(id);
|
||||
toast(!favorite ? 'Removed to Favourites' : 'Added to Favourites');
|
||||
}}
|
||||
>
|
||||
{favorite ? <FavouritedIcon /> : <FavouritesIcon />}
|
||||
@@ -54,6 +58,8 @@ export const PageList = ({
|
||||
showFavoriteTag?: boolean;
|
||||
isTrash?: boolean;
|
||||
}) => {
|
||||
const router = useRouter();
|
||||
const { currentWorkspaceId } = useAppState();
|
||||
if (pageList.length === 0) {
|
||||
return <Empty />;
|
||||
}
|
||||
@@ -77,10 +83,9 @@ export const PageList = ({
|
||||
<StyledTableRow
|
||||
key={`${pageMeta.id}-${index}`}
|
||||
onClick={() => {
|
||||
router.push({
|
||||
pathname: '/',
|
||||
query: { pageId: pageMeta.id },
|
||||
});
|
||||
router.push(
|
||||
`/workspace/${currentWorkspaceId}/${pageMeta.id}`
|
||||
);
|
||||
}}
|
||||
>
|
||||
<TableCell>
|
||||
|
||||
@@ -20,7 +20,7 @@ import { toast } from '@/components/toast';
|
||||
export const OperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
|
||||
const { id, favorite } = pageMeta;
|
||||
const goToPage = useGoToPage();
|
||||
const { toggleFavoritePage, toggleDeletePage } = useEditor();
|
||||
const { toggleFavoritePage, toggleDeletePage } = useAppState();
|
||||
const { confirm } = useConfirm();
|
||||
|
||||
const OperationMenu = (
|
||||
@@ -28,6 +28,7 @@ export const OperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
toggleFavoritePage(id);
|
||||
toast(!favorite ? 'Removed to Favourites' : 'Added to Favourites');
|
||||
}}
|
||||
icon={favorite ? <FavouritedIcon /> : <FavouritesIcon />}
|
||||
>
|
||||
@@ -73,8 +74,8 @@ export const OperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
|
||||
export const TrashOperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
|
||||
const { id } = pageMeta;
|
||||
const goToPage = useGoToPage();
|
||||
const { getPageMeta } = useAppState();
|
||||
const { permanentlyDeletePage, toggleDeletePage } = useEditor();
|
||||
const { getPageMeta, toggleDeletePage } = useAppState();
|
||||
const { permanentlyDeletePage } = useEditor();
|
||||
const { confirm } = useConfirm();
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { AllPagesIcon, FavouritesIcon, TrashIcon } from '@blocksuite/icons';
|
||||
|
||||
// FIXME: href changed
|
||||
export const List = [
|
||||
{
|
||||
title: 'All pages',
|
||||
|
||||
@@ -26,6 +26,7 @@ import { Tooltip } from '@/ui/tooltip';
|
||||
import { useEditor } from '@/providers/editor-provider';
|
||||
import { useModal } from '@/providers/global-modal-provider';
|
||||
import { useGoToPage } from '@/providers/app-state-provider/hooks';
|
||||
import { useAppState } from '@/providers/app-state-provider/context';
|
||||
|
||||
import { IconButton } from '@/ui/button';
|
||||
import { WorkspaceSelector } from './WorkspaceSelector';
|
||||
@@ -62,9 +63,9 @@ const FavoriteList = ({ showList }: { showList: boolean }) => {
|
||||
);
|
||||
};
|
||||
export const WorkSpaceSliderBar = () => {
|
||||
const { triggerQuickSearchModal, triggerImportModal } = useModal();
|
||||
const { triggerQuickSearchModal } = useModal();
|
||||
const [showSubFavorite, setShowSubFavorite] = useState(true);
|
||||
const { createPage } = useEditor();
|
||||
const { createPage, currentWorkspaceId } = useAppState();
|
||||
const goToPage = useGoToPage();
|
||||
const router = useRouter();
|
||||
|
||||
@@ -85,13 +86,21 @@ export const WorkSpaceSliderBar = () => {
|
||||
>
|
||||
<SearchIcon /> Quick search
|
||||
</StyledListItem>
|
||||
<Link href={{ pathname: '/page-list/all' }}>
|
||||
<StyledListItem active={router.pathname === '/page-list/all'}>
|
||||
<Link href={{ pathname: `/workspace/${currentWorkspaceId}/all` }}>
|
||||
<StyledListItem
|
||||
active={router.pathname === `/workspace/${currentWorkspaceId}/all`}
|
||||
>
|
||||
<AllPagesIcon /> <span>All pages</span>
|
||||
</StyledListItem>
|
||||
</Link>
|
||||
<StyledListItem active={router.pathname === '/page-list/favorite'}>
|
||||
<StyledLink href={{ pathname: '/page-list/favorite' }}>
|
||||
<StyledListItem
|
||||
active={
|
||||
router.pathname === `/workspace/${currentWorkspaceId}/favorite`
|
||||
}
|
||||
>
|
||||
<StyledLink
|
||||
href={{ pathname: `/workspace/${currentWorkspaceId}/favorite` }}
|
||||
>
|
||||
<FavouritesIcon />
|
||||
Favourites
|
||||
</StyledLink>
|
||||
@@ -121,15 +130,22 @@ export const WorkSpaceSliderBar = () => {
|
||||
</StyledListItem>
|
||||
</Tooltip>
|
||||
|
||||
<Link href={{ pathname: '/page-list/trash' }}>
|
||||
<StyledListItem active={router.pathname === '/page-list/trash'}>
|
||||
<Link href={{ pathname: `/workspace/${currentWorkspaceId}/trash` }}>
|
||||
<StyledListItem
|
||||
active={
|
||||
router.pathname === `/workspace/${currentWorkspaceId}/trash`
|
||||
}
|
||||
>
|
||||
<TrashIcon /> Trash
|
||||
</StyledListItem>
|
||||
</Link>
|
||||
<StyledNewPageButton
|
||||
onClick={async () => {
|
||||
const page = await createPage();
|
||||
goToPage(page.pageId);
|
||||
const pageId = await createPage();
|
||||
console.log('pageID', pageId);
|
||||
if (pageId) {
|
||||
goToPage(pageId);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<AddIcon /> New Page
|
||||
|
||||
Reference in New Issue
Block a user