mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 10:22:55 +08:00
chore: remove favorite page (#2372)
This commit is contained in:
@@ -19,7 +19,7 @@ import { pageListEmptyStyle } from './index.css';
|
|||||||
|
|
||||||
export type BlockSuitePageListProps = {
|
export type BlockSuitePageListProps = {
|
||||||
blockSuiteWorkspace: BlockSuiteWorkspace;
|
blockSuiteWorkspace: BlockSuiteWorkspace;
|
||||||
listType: 'all' | 'trash' | 'favorite' | 'shared' | 'public';
|
listType: 'all' | 'trash' | 'shared' | 'public';
|
||||||
isPublic?: true;
|
isPublic?: true;
|
||||||
onOpenPage: (pageId: string, newTab?: boolean) => void;
|
onOpenPage: (pageId: string, newTab?: boolean) => void;
|
||||||
};
|
};
|
||||||
@@ -31,7 +31,6 @@ const filter = {
|
|||||||
const parentMeta = allMetas.find(m => m.subpageIds?.includes(pageMeta.id));
|
const parentMeta = allMetas.find(m => m.subpageIds?.includes(pageMeta.id));
|
||||||
return !parentMeta?.trash && pageMeta.trash;
|
return !parentMeta?.trash && pageMeta.trash;
|
||||||
},
|
},
|
||||||
favorite: (pageMeta: PageMeta) => pageMeta.favorite && !pageMeta.trash,
|
|
||||||
shared: (pageMeta: PageMeta) => pageMeta.isPublic && !pageMeta.trash,
|
shared: (pageMeta: PageMeta) => pageMeta.isPublic && !pageMeta.trash,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,9 +51,6 @@ const PageListEmpty = (props: {
|
|||||||
if (listType === 'all') {
|
if (listType === 'all') {
|
||||||
return t['emptyAllPages']();
|
return t['emptyAllPages']();
|
||||||
}
|
}
|
||||||
if (listType === 'favorite') {
|
|
||||||
return t['emptyFavorite']();
|
|
||||||
}
|
|
||||||
if (listType === 'trash') {
|
if (listType === 'trash') {
|
||||||
return t['emptyTrash']();
|
return t['emptyTrash']();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
import {
|
import {
|
||||||
DeleteTemporarilyIcon,
|
DeleteTemporarilyIcon,
|
||||||
FavoriteIcon,
|
|
||||||
FolderIcon,
|
FolderIcon,
|
||||||
SettingsIcon,
|
SettingsIcon,
|
||||||
} from '@blocksuite/icons';
|
} from '@blocksuite/icons';
|
||||||
@@ -24,11 +23,6 @@ export const useSwitchToConfig = (
|
|||||||
href: pathGenerator.all(workspaceId),
|
href: pathGenerator.all(workspaceId),
|
||||||
icon: FolderIcon,
|
icon: FolderIcon,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: t['Favorites'](),
|
|
||||||
href: pathGenerator.favorite(workspaceId),
|
|
||||||
icon: FavoriteIcon,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: t['Workspace Settings'](),
|
title: t['Workspace Settings'](),
|
||||||
href: pathGenerator.setting(workspaceId),
|
href: pathGenerator.setting(workspaceId),
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ export type RootAppSidebarProps = {
|
|||||||
currentPath: string;
|
currentPath: string;
|
||||||
paths: {
|
paths: {
|
||||||
all: (workspaceId: string) => string;
|
all: (workspaceId: string) => string;
|
||||||
favorite: (workspaceId: string) => string;
|
|
||||||
trash: (workspaceId: string) => string;
|
trash: (workspaceId: string) => string;
|
||||||
setting: (workspaceId: string) => string;
|
setting: (workspaceId: string) => string;
|
||||||
shared: (workspaceId: string) => string;
|
shared: (workspaceId: string) => string;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ beforeAll(() => {
|
|||||||
createDynamicRouteParser([
|
createDynamicRouteParser([
|
||||||
'/workspace/[workspaceId]/[pageId]',
|
'/workspace/[workspaceId]/[pageId]',
|
||||||
'/workspace/[workspaceId]/all',
|
'/workspace/[workspaceId]/all',
|
||||||
'/workspace/[workspaceId]/favorite',
|
|
||||||
'/workspace/[workspaceId]/trash',
|
'/workspace/[workspaceId]/trash',
|
||||||
'/workspace/[workspaceId]/setting',
|
'/workspace/[workspaceId]/setting',
|
||||||
'/workspace/[workspaceId]/shared',
|
'/workspace/[workspaceId]/shared',
|
||||||
@@ -54,19 +53,6 @@ describe('useRouterHelper', () => {
|
|||||||
// routerHook.result.current.back()
|
// routerHook.result.current.back()
|
||||||
// routerHook.rerender()
|
// routerHook.rerender()
|
||||||
// expect(routerHook.result.current.pathname).toBe('/')
|
// expect(routerHook.result.current.pathname).toBe('/')
|
||||||
|
|
||||||
await hook.jumpToSubPath(
|
|
||||||
'workspace1',
|
|
||||||
WorkspaceSubPath.FAVORITE,
|
|
||||||
RouteLogic.REPLACE
|
|
||||||
);
|
|
||||||
routerHook.rerender();
|
|
||||||
expect(routerHook.result.current.pathname).toBe(
|
|
||||||
'/workspace/[workspaceId]/favorite'
|
|
||||||
);
|
|
||||||
expect(routerHook.result.current.asPath).toBe(
|
|
||||||
'/workspace/workspace1/favorite'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should jump to the expected page', async () => {
|
test('should jump to the expected page', async () => {
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
|
||||||
import { FavoriteIcon } from '@blocksuite/icons';
|
|
||||||
import { assertExists } from '@blocksuite/store';
|
|
||||||
import Head from 'next/head';
|
|
||||||
import { useRouter } from 'next/router';
|
|
||||||
import React, { useCallback } from 'react';
|
|
||||||
|
|
||||||
import { BlockSuitePageList } from '../../../components/blocksuite/block-suite-page-list';
|
|
||||||
import { PageLoading } from '../../../components/pure/loading';
|
|
||||||
import { WorkspaceTitle } from '../../../components/pure/workspace-title';
|
|
||||||
import { useCurrentWorkspace } from '../../../hooks/current/use-current-workspace';
|
|
||||||
import { useRouterHelper } from '../../../hooks/use-router-helper';
|
|
||||||
import { WorkspaceLayout } from '../../../layouts/workspace-layout';
|
|
||||||
import type { NextPageWithLayout } from '../../../shared';
|
|
||||||
|
|
||||||
const FavouritePage: NextPageWithLayout = () => {
|
|
||||||
const router = useRouter();
|
|
||||||
const { jumpToPage } = useRouterHelper(router);
|
|
||||||
const [currentWorkspace] = useCurrentWorkspace();
|
|
||||||
const t = useAFFiNEI18N();
|
|
||||||
const onClickPage = useCallback(
|
|
||||||
(pageId: string, newTab?: boolean) => {
|
|
||||||
assertExists(currentWorkspace);
|
|
||||||
if (newTab) {
|
|
||||||
window.open(`/workspace/${currentWorkspace?.id}/${pageId}`, '_blank');
|
|
||||||
} else {
|
|
||||||
jumpToPage(currentWorkspace.id, pageId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[currentWorkspace, jumpToPage]
|
|
||||||
);
|
|
||||||
if (currentWorkspace === null) {
|
|
||||||
return <PageLoading />;
|
|
||||||
}
|
|
||||||
const blockSuiteWorkspace = currentWorkspace.blockSuiteWorkspace;
|
|
||||||
assertExists(blockSuiteWorkspace);
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Head>
|
|
||||||
<title>{t['Favorites']()} - AFFiNE</title>
|
|
||||||
</Head>
|
|
||||||
<WorkspaceTitle
|
|
||||||
workspace={currentWorkspace}
|
|
||||||
currentPage={null}
|
|
||||||
isPreview={false}
|
|
||||||
isPublic={false}
|
|
||||||
icon={<FavoriteIcon />}
|
|
||||||
>
|
|
||||||
{t['Favorites']()}
|
|
||||||
</WorkspaceTitle>
|
|
||||||
<BlockSuitePageList
|
|
||||||
blockSuiteWorkspace={blockSuiteWorkspace}
|
|
||||||
onOpenPage={onClickPage}
|
|
||||||
listType="favorite"
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default FavouritePage;
|
|
||||||
|
|
||||||
FavouritePage.getLayout = page => {
|
|
||||||
return <WorkspaceLayout>{page}</WorkspaceLayout>;
|
|
||||||
};
|
|
||||||
@@ -26,7 +26,6 @@ export type NextPageWithLayout<P = Record<string, unknown>, IP = P> = NextPage<
|
|||||||
|
|
||||||
export const enum WorkspaceSubPath {
|
export const enum WorkspaceSubPath {
|
||||||
ALL = 'all',
|
ALL = 'all',
|
||||||
FAVORITE = 'favorite',
|
|
||||||
SETTING = 'setting',
|
SETTING = 'setting',
|
||||||
TRASH = 'trash',
|
TRASH = 'trash',
|
||||||
SHARED = 'shared',
|
SHARED = 'shared',
|
||||||
@@ -34,7 +33,6 @@ export const enum WorkspaceSubPath {
|
|||||||
|
|
||||||
export const WorkspaceSubPathName = {
|
export const WorkspaceSubPathName = {
|
||||||
[WorkspaceSubPath.ALL]: 'All Pages',
|
[WorkspaceSubPath.ALL]: 'All Pages',
|
||||||
[WorkspaceSubPath.FAVORITE]: 'Favorites',
|
|
||||||
[WorkspaceSubPath.SETTING]: 'Settings',
|
[WorkspaceSubPath.SETTING]: 'Settings',
|
||||||
[WorkspaceSubPath.TRASH]: 'Trash',
|
[WorkspaceSubPath.TRASH]: 'Trash',
|
||||||
[WorkspaceSubPath.SHARED]: 'Shared',
|
[WorkspaceSubPath.SHARED]: 'Shared',
|
||||||
@@ -44,7 +42,6 @@ export const WorkspaceSubPathName = {
|
|||||||
|
|
||||||
export const pathGenerator = {
|
export const pathGenerator = {
|
||||||
all: workspaceId => `/workspace/${workspaceId}/all`,
|
all: workspaceId => `/workspace/${workspaceId}/all`,
|
||||||
favorite: workspaceId => `/workspace/${workspaceId}/favorite`,
|
|
||||||
trash: workspaceId => `/workspace/${workspaceId}/trash`,
|
trash: workspaceId => `/workspace/${workspaceId}/trash`,
|
||||||
setting: workspaceId => `/workspace/${workspaceId}/setting`,
|
setting: workspaceId => `/workspace/${workspaceId}/setting`,
|
||||||
shared: workspaceId => `/workspace/${workspaceId}/shared`,
|
shared: workspaceId => `/workspace/${workspaceId}/shared`,
|
||||||
@@ -54,7 +51,6 @@ export const pathGenerator = {
|
|||||||
|
|
||||||
export const publicPathGenerator = {
|
export const publicPathGenerator = {
|
||||||
all: workspaceId => `/public-workspace/${workspaceId}/all`,
|
all: workspaceId => `/public-workspace/${workspaceId}/all`,
|
||||||
favorite: workspaceId => `/public-workspace/${workspaceId}/favorite`,
|
|
||||||
trash: workspaceId => `/public-workspace/${workspaceId}/trash`,
|
trash: workspaceId => `/public-workspace/${workspaceId}/trash`,
|
||||||
setting: workspaceId => `/public-workspace/${workspaceId}/setting`,
|
setting: workspaceId => `/public-workspace/${workspaceId}/setting`,
|
||||||
shared: workspaceId => `/public-workspace/${workspaceId}/shared`,
|
shared: workspaceId => `/public-workspace/${workspaceId}/shared`,
|
||||||
|
|||||||
Reference in New Issue
Block a user