From 5035ab218dae61969c9e3735b554fbad69448fa3 Mon Sep 17 00:00:00 2001 From: EYHN Date: Thu, 22 May 2025 11:29:05 +0000 Subject: [PATCH] feat(core): enable new all docs by default (#12404) ## Summary by CodeRabbit - **Refactor** - Simplified the user interface by always displaying the new All Pages view, removing the feature flag and old page version. - Updated selection interactions to use shift+click on document items instead of checkboxes. - Centralized drag-and-drop functionality in document list items and simplified drag handle behavior. - Generalized new page button component to accept standard HTML attributes. - Changed test ID attributes on new page buttons and list headers to use standard `data-testid`. - **Bug Fixes** - Added stable test identifiers to new page buttons, document list items, menu items, and operation buttons for improved test reliability. - Enabled external drag-and-drop support on the trash button. - **Tests** - Streamlined and updated end-to-end tests to match the new selection flow and UI changes, removing outdated or redundant test cases. - Simplified utility functions and wait conditions in test helpers for better accuracy and maintainability. - Updated selectors in tests to reflect new document item identifiers and centralized page element retrieval using utility functions. --- .../core/src/components/explorer/context.ts | 8 + .../explorer/docs-view/doc-list-item.tsx | 108 ++++---- .../explorer/docs-view/more-menu.tsx | 29 ++- .../explorer/docs-view/quick-actions.tsx | 2 + .../page-list/docs/page-list-header.tsx | 4 +- .../docs/page-list-new-page-button.tsx | 8 +- .../root-app-sidebar/trash-button.tsx | 1 + .../workspace/all-page/all-page-header.tsx | 1 + .../pages/workspace/all-page/all-page.tsx | 9 +- .../workspace/collection/list-header.tsx | 2 +- .../core/src/modules/feature-flag/constant.ts | 7 - tests/affine-cloud/e2e/storage.spec.ts | 11 +- tests/affine-desktop/e2e/split-view.spec.ts | 18 +- tests/affine-desktop/e2e/tabs.spec.ts | 8 +- tests/affine-desktop/e2e/workspace.spec.ts | 3 +- tests/affine-local/e2e/all-page.spec.ts | 244 ++---------------- .../affine-local/e2e/change-page-mode.spec.ts | 2 +- tests/affine-local/e2e/drag-page.spec.ts | 8 +- .../e2e/local-first-collections-items.spec.ts | 20 +- .../e2e/local-first-delete-page.spec.ts | 30 +-- .../e2e/local-first-favorite-page.spec.ts | 12 +- .../e2e/local-first-new-page.spec.ts | 4 +- .../e2e/local-first-openpage-newtab.spec.ts | 3 +- .../e2e/local-first-restore-page.spec.ts | 14 +- .../e2e/local-first-show-delete-modal.spec.ts | 10 +- .../e2e/local-first-trash-page.spec.ts | 10 +- tests/kit/src/utils/filter.ts | 13 +- tests/kit/src/utils/page-logic.ts | 21 +- 28 files changed, 212 insertions(+), 398 deletions(-) diff --git a/packages/frontend/core/src/components/explorer/context.ts b/packages/frontend/core/src/components/explorer/context.ts index 54d1066b1..88a3b96e4 100644 --- a/packages/frontend/core/src/components/explorer/context.ts +++ b/packages/frontend/core/src/components/explorer/context.ts @@ -15,6 +15,8 @@ const DefaultDisplayPreference: ExplorerDisplayPreference = { showDocIcon: true, showDocPreview: true, quickFavorite: true, + showDragHandle: true, + showMoreOperation: true, }; export type DocExplorerContextType = { @@ -85,5 +87,11 @@ export const createDocExplorerContext = ( quickTab$: displayPreference$.selector( displayPreference => displayPreference.quickTab ), + showMoreOperation$: displayPreference$.selector( + displayPreference => displayPreference.showMoreOperation + ), + showDragHandle$: displayPreference$.selector( + displayPreference => displayPreference.showDragHandle + ), } satisfies DocExplorerContextType; }; diff --git a/packages/frontend/core/src/components/explorer/docs-view/doc-list-item.tsx b/packages/frontend/core/src/components/explorer/docs-view/doc-list-item.tsx index 624ff84df..3160b108a 100644 --- a/packages/frontend/core/src/components/explorer/docs-view/doc-list-item.tsx +++ b/packages/frontend/core/src/components/explorer/docs-view/doc-list-item.tsx @@ -8,7 +8,6 @@ import { DocsService } from '@affine/core/modules/doc'; import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta'; import { WorkbenchLink } from '@affine/core/modules/workbench'; import type { AffineDNDData } from '@affine/core/types/dnd'; -import { useI18n } from '@affine/i18n'; import { AutoTidyUpIcon, PropertyIcon, @@ -146,20 +145,45 @@ export const DocListItem = ({ ...props }: DocListItemProps) => { [contextValue, handleMultiSelect, prevCheckAnchorId, props, selectMode] ); + const { dragRef, CustomDragPreview } = useDraggable( + () => ({ + canDrag: true, + data: { + entity: { + type: 'doc', + id: props.docId as string, + }, + from: { + at: 'all-docs:list', + }, + }, + }), + [props.docId] + ); + return ( - - {view === 'list' ? ( - - ) : ( - - )} - + <> + + {view === 'list' ? ( + + ) : ( + + )} + + + + + + ); }; @@ -172,10 +196,9 @@ const RawDocIcon = memo(function RawDocIcon({ return ; }); const RawDocTitle = memo(function RawDocTitle({ id }: { id: string }) { - const i18n = useI18n(); const docDisplayMetaService = useService(DocDisplayMetaService); const title = useLiveData(docDisplayMetaService.title$(id)); - return i18n.t(title); + return title; }); const RawDocPreview = memo(function RawDocPreview({ id, @@ -188,47 +211,20 @@ const RawDocPreview = memo(function RawDocPreview({ }); const DragHandle = memo(function DragHandle({ id, - preview, ...props -}: HTMLProps & { preview?: ReactNode }) { +}: HTMLProps) { const contextValue = useContext(DocExplorerContext); const selectMode = useLiveData(contextValue.selectMode$); const showDragHandle = useLiveData(contextValue.showDragHandle$); - const { dragRef, CustomDragPreview } = useDraggable( - () => ({ - canDrag: true, - data: { - entity: { - type: 'doc', - id: id as string, - }, - from: { - at: 'all-docs:list', - }, - }, - }), - [id] - ); - if (selectMode || !id || !showDragHandle) { return null; } return ( - <> -
- -
- - {preview ?? ( - <> - - - - )} - - +
+ +
); }); const Select = memo(function Select({ @@ -248,7 +244,11 @@ const Select = memo(function Select({ } return ( -
+
{