From 7013f9b8049c5a665f09e1ed5cbe678c53b1e103 Mon Sep 17 00:00:00 2001 From: CatsJuice Date: Fri, 9 May 2025 09:38:48 +0000 Subject: [PATCH] feat(core): new all docs header (#12182) ## Summary by CodeRabbit - **New Features** - Introduced a new grouped document explorer with a masonry layout, advanced filtering, and multi-select capabilities. - Added a floating toolbar for batch actions, such as deleting multiple documents. - Implemented a feature flag to enable the new "All Docs" page, allowing gradual rollout. - Added a new navigation component with links for Docs, Collections, and Tags. - Introduced a display menu button supporting additional menu properties. - **Enhancements** - Redesigned navigation headers across document, collection, and tag pages for improved consistency and usability. - Added new display and view toggling options for document lists. - Improved styling and responsiveness for explorer and header components. - Updated context to support dynamic view switching in the document explorer. - **Bug Fixes** - Updated context and prop types to enhance state management and user interactions. - **Refactor** - Replaced legacy page list views with a modern, grouped explorer interface. - Simplified and modularized header components and styles for better maintainability. - Removed workspace-specific controls from document headers to focus on explorer functionality. --- .../core/src/components/explorer/context.ts | 5 +- .../explorer/display-menu/index.tsx | 11 +- .../explorer/header/navigation.css.ts | 20 + .../components/explorer/header/navigation.tsx | 47 +++ .../pages/workspace/all-collection/header.tsx | 4 +- .../pages/workspace/all-page-new/all-page.tsx | 360 ----------------- .../all-page-filter.tsx | 0 .../all-page-old/all-page-header.tsx | 103 +++++ .../all-page.css.ts | 16 +- .../pages/workspace/all-page-old/all-page.tsx | 96 +++++ .../workspace/all-page/all-page-header.css.ts | 35 ++ .../workspace/all-page/all-page-header.tsx | 166 ++++---- .../pages/workspace/all-page/all-page.css.ts | 33 ++ .../pages/workspace/all-page/all-page.tsx | 380 +++++++++++++++--- .../migration-data.css.ts | 0 .../migration-data.tsx | 0 .../pages/workspace/all-tag/header.tsx | 4 +- .../pages/workspace/collection/header.tsx | 4 +- .../desktop/pages/workspace/tag/header.tsx | 4 +- .../core/src/desktop/workbench-router.ts | 4 +- .../core/src/modules/feature-flag/constant.ts | 7 + 21 files changed, 755 insertions(+), 544 deletions(-) create mode 100644 packages/frontend/core/src/components/explorer/header/navigation.css.ts create mode 100644 packages/frontend/core/src/components/explorer/header/navigation.tsx delete mode 100644 packages/frontend/core/src/desktop/pages/workspace/all-page-new/all-page.tsx rename packages/frontend/core/src/desktop/pages/workspace/{all-page => all-page-old}/all-page-filter.tsx (100%) create mode 100644 packages/frontend/core/src/desktop/pages/workspace/all-page-old/all-page-header.tsx rename packages/frontend/core/src/desktop/pages/workspace/{all-page-new => all-page-old}/all-page.css.ts (68%) create mode 100644 packages/frontend/core/src/desktop/pages/workspace/all-page-old/all-page.tsx create mode 100644 packages/frontend/core/src/desktop/pages/workspace/all-page/all-page-header.css.ts rename packages/frontend/core/src/desktop/pages/workspace/{all-page-new => all-page}/migration-data.css.ts (100%) rename packages/frontend/core/src/desktop/pages/workspace/{all-page-new => all-page}/migration-data.tsx (100%) diff --git a/packages/frontend/core/src/components/explorer/context.ts b/packages/frontend/core/src/components/explorer/context.ts index f04af7646f..1555a64b3d 100644 --- a/packages/frontend/core/src/components/explorer/context.ts +++ b/packages/frontend/core/src/components/explorer/context.ts @@ -1,9 +1,11 @@ import { createContext, type Dispatch, type SetStateAction } from 'react'; +import type { DocListItemView } from './docs-view/doc-list-item'; import type { ExplorerPreference } from './types'; export type DocExplorerContextType = ExplorerPreference & { - view: 'list' | 'grid' | 'masonry'; + view: DocListItemView; + setView: Dispatch>; groups: Array<{ key: string; items: string[] }>; collapsed: string[]; selectMode?: boolean; @@ -17,6 +19,7 @@ export type DocExplorerContextType = ExplorerPreference & { export const DocExplorerContext = createContext({ view: 'list', + setView: () => {}, groups: [], collapsed: [], selectedDocIds: [], diff --git a/packages/frontend/core/src/components/explorer/display-menu/index.tsx b/packages/frontend/core/src/components/explorer/display-menu/index.tsx index 1ac1487218..ab97f36d01 100644 --- a/packages/frontend/core/src/components/explorer/display-menu/index.tsx +++ b/packages/frontend/core/src/components/explorer/display-menu/index.tsx @@ -1,4 +1,10 @@ -import { Button, Divider, Menu, MenuSub } from '@affine/component'; +import { + Button, + Divider, + Menu, + type MenuProps, + MenuSub, +} from '@affine/component'; import type { GroupByParams, OrderByParams, @@ -92,12 +98,14 @@ export const ExplorerDisplayMenuButton = ({ style, className, preference, + menuProps, onChange, }: { style?: React.CSSProperties; className?: string; preference: ExplorerPreference; onChange?: (preference: ExplorerPreference) => void; + menuProps?: Omit; }) => { const t = useI18n(); return ( @@ -105,6 +113,7 @@ export const ExplorerDisplayMenuButton = ({ items={ } + {...menuProps} >