mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-11-28 00:19:20 +03:00
fix(mobile): remove the collection edit action (#15897)
The mobile collection menu offered "Edit collection", which opens the `collection-editor` dialog, but the mobile dialog registry never registered it (the editor is the desktop dialog and was left commented out when the mobile app got its own dialogs), so tapping it did nothing. This removes the action and the handlers that only served it. A mobile e2e test checks the collection menu no longer offers it. fix #15005 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Changes** * Removed the “Edit collection” action from collection menus in mobile navigation. * Collection menus continue to offer rename, add page, favorite, open, split view, and delete actions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: DarkSky <darksky2048@gmail.com>
This commit is contained in:
1 parent
9972c63524
commit
bb996d298f
5 files changed
+36
-66
No files matched your search
@@ -4,7 +4,6 @@ import {
|
||||
type Collection,
|
||||
CollectionService,
|
||||
} from '@affine/core/modules/collection';
|
||||
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
|
||||
import { GlobalContextService } from '@affine/core/modules/global-context';
|
||||
import { NavigationPanelService } from '@affine/core/modules/navigation-panel';
|
||||
import { ShareDocsListService } from '@affine/core/modules/share-doc';
|
||||
@@ -34,12 +33,10 @@ export const NavigationPanelCollectionNode = ({
|
||||
parentPath: string[];
|
||||
}) => {
|
||||
const t = useI18n();
|
||||
const { globalContextService, collectionService, workspaceDialogService } =
|
||||
useServices({
|
||||
GlobalContextService,
|
||||
CollectionService,
|
||||
WorkspaceDialogService,
|
||||
});
|
||||
const { globalContextService, collectionService } = useServices({
|
||||
GlobalContextService,
|
||||
CollectionService,
|
||||
});
|
||||
const navigationPanelService = useService(NavigationPanelService);
|
||||
const active =
|
||||
useLiveData(globalContextService.globalContext.collectionId.$) ===
|
||||
@@ -63,15 +60,6 @@ export const NavigationPanelCollectionNode = ({
|
||||
setCollapsed(false);
|
||||
}, [setCollapsed]);
|
||||
|
||||
const handleEditCollection = useCallback(() => {
|
||||
if (!collection) {
|
||||
return;
|
||||
}
|
||||
workspaceDialogService.open('collection-editor', {
|
||||
collectionId: collection.id,
|
||||
});
|
||||
}, [collection, workspaceDialogService]);
|
||||
|
||||
const handleAddDocToCollection = useNavigationPanelCollectionAddDoc(
|
||||
collectionId,
|
||||
handleOpenCollapsed
|
||||
@@ -81,16 +69,10 @@ export const NavigationPanelCollectionNode = ({
|
||||
<NavigationPanelCollectionNodeMenu
|
||||
collectionId={collectionId}
|
||||
handleAddDocToCollection={handleAddDocToCollection}
|
||||
onOpenEdit={handleEditCollection}
|
||||
additionalOperations={additionalOperations}
|
||||
/>
|
||||
),
|
||||
[
|
||||
additionalOperations,
|
||||
collectionId,
|
||||
handleAddDocToCollection,
|
||||
handleEditCollection,
|
||||
]
|
||||
[additionalOperations, collectionId, handleAddDocToCollection]
|
||||
);
|
||||
|
||||
if (!collection) {
|
||||
|
||||
+4
-27
@@ -16,7 +16,6 @@ import { useI18n } from '@affine/i18n';
|
||||
import { track } from '@affine/track';
|
||||
import {
|
||||
DeleteIcon,
|
||||
FilterIcon,
|
||||
OpenInNewIcon,
|
||||
PlusIcon,
|
||||
SplitViewIcon,
|
||||
@@ -63,8 +62,7 @@ export const useNavigationPanelCollectionAddDoc = (
|
||||
|
||||
export const useNavigationPanelCollectionNodeOperations = (
|
||||
collectionId: string,
|
||||
handleAddDocToCollection: () => void,
|
||||
onOpenEdit: () => void
|
||||
handleAddDocToCollection: () => void
|
||||
) => {
|
||||
const t = useI18n();
|
||||
const {
|
||||
@@ -110,10 +108,6 @@ export const useNavigationPanelCollectionNodeOperations = (
|
||||
});
|
||||
}, [collectionId, collectionService]);
|
||||
|
||||
const handleShowEdit = useCallback(() => {
|
||||
onOpenEdit();
|
||||
}, [onOpenEdit]);
|
||||
|
||||
const handleRename = useCallback(
|
||||
(name: string) => {
|
||||
const collection = collectionService.collection$(collectionId).value;
|
||||
@@ -138,7 +132,6 @@ export const useNavigationPanelCollectionNodeOperations = (
|
||||
handleDeleteCollection,
|
||||
handleOpenInNewTab,
|
||||
handleOpenInSplitView,
|
||||
handleShowEdit,
|
||||
handleToggleFavoriteCollection,
|
||||
handleRename,
|
||||
}),
|
||||
@@ -149,7 +142,6 @@ export const useNavigationPanelCollectionNodeOperations = (
|
||||
handleOpenInNewTab,
|
||||
handleOpenInSplitView,
|
||||
handleRename,
|
||||
handleShowEdit,
|
||||
handleToggleFavoriteCollection,
|
||||
]
|
||||
);
|
||||
@@ -157,8 +149,7 @@ export const useNavigationPanelCollectionNodeOperations = (
|
||||
|
||||
export const useNavigationPanelCollectionNodeOperationsMenu = (
|
||||
collectionId: string,
|
||||
handleAddDocToCollection: () => void,
|
||||
onOpenEdit: () => void
|
||||
handleAddDocToCollection: () => void
|
||||
): NodeOperation[] => {
|
||||
const t = useI18n();
|
||||
|
||||
@@ -168,13 +159,11 @@ export const useNavigationPanelCollectionNodeOperationsMenu = (
|
||||
handleDeleteCollection,
|
||||
handleOpenInNewTab,
|
||||
handleOpenInSplitView,
|
||||
handleShowEdit,
|
||||
handleToggleFavoriteCollection,
|
||||
handleRename,
|
||||
} = useNavigationPanelCollectionNodeOperations(
|
||||
collectionId,
|
||||
handleAddDocToCollection,
|
||||
onOpenEdit
|
||||
handleAddDocToCollection
|
||||
);
|
||||
|
||||
return useMemo(
|
||||
@@ -202,14 +191,6 @@ export const useNavigationPanelCollectionNodeOperationsMenu = (
|
||||
index: 11,
|
||||
view: <MenuSeparator />,
|
||||
},
|
||||
{
|
||||
index: 99,
|
||||
view: (
|
||||
<MenuItem prefixIcon={<FilterIcon />} onClick={handleShowEdit}>
|
||||
{t['com.affine.collection.menu.edit']()}
|
||||
</MenuItem>
|
||||
),
|
||||
},
|
||||
{
|
||||
index: 99,
|
||||
view: (
|
||||
@@ -278,7 +259,6 @@ export const useNavigationPanelCollectionNodeOperationsMenu = (
|
||||
handleOpenInNewTab,
|
||||
handleOpenInSplitView,
|
||||
handleRename,
|
||||
handleShowEdit,
|
||||
handleToggleFavoriteCollection,
|
||||
t,
|
||||
]
|
||||
@@ -288,18 +268,15 @@ export const useNavigationPanelCollectionNodeOperationsMenu = (
|
||||
export const NavigationPanelCollectionNodeMenu = ({
|
||||
collectionId,
|
||||
handleAddDocToCollection,
|
||||
onOpenEdit,
|
||||
additionalOperations,
|
||||
}: {
|
||||
collectionId: string;
|
||||
handleAddDocToCollection: () => void;
|
||||
onOpenEdit: () => void;
|
||||
additionalOperations?: NodeOperation[];
|
||||
}) => {
|
||||
const operations = useNavigationPanelCollectionNodeOperationsMenu(
|
||||
collectionId,
|
||||
handleAddDocToCollection,
|
||||
onOpenEdit
|
||||
handleAddDocToCollection
|
||||
);
|
||||
const allOperations = useMemo(
|
||||
() => [...(additionalOperations ?? []), ...operations],
|
||||
|
||||
@@ -2,7 +2,6 @@ import { MenuItem, SafeArea, usePromptModal } from '@affine/component';
|
||||
import { usePageHelper } from '@affine/core/blocksuite/block-suite-page-list/utils';
|
||||
import { NavigationPanelTreeRoot } from '@affine/core/desktop/components/navigation-panel';
|
||||
import { CollectionService } from '@affine/core/modules/collection';
|
||||
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
|
||||
import { FavoriteService } from '@affine/core/modules/favorite';
|
||||
import { NavigationPanelService } from '@affine/core/modules/navigation-panel';
|
||||
import { OrganizeService } from '@affine/core/modules/organize';
|
||||
@@ -236,28 +235,15 @@ const CollectionRow = ({
|
||||
entry: MobileShellNavigationEntry;
|
||||
toggle: () => void;
|
||||
}) => {
|
||||
const { collectionService, workspaceDialogService } = useServices({
|
||||
CollectionService,
|
||||
WorkspaceDialogService,
|
||||
});
|
||||
const expand = useCallback(() => {
|
||||
if (!row.expanded) toggle();
|
||||
}, [row.expanded, toggle]);
|
||||
const handleAdd = useNavigationPanelCollectionAddDoc(entry.id, expand);
|
||||
const handleEdit = useCallback(() => {
|
||||
const collection = collectionService.collection$(entry.id).value;
|
||||
if (collection) {
|
||||
workspaceDialogService.open('collection-editor', {
|
||||
collectionId: entry.id,
|
||||
});
|
||||
}
|
||||
}, [collectionService, entry.id, workspaceDialogService]);
|
||||
const menuTarget = useMemo(
|
||||
() => (
|
||||
<NavigationPanelCollectionNodeMenu
|
||||
collectionId={entry.id}
|
||||
handleAddDocToCollection={handleAdd}
|
||||
onOpenEdit={handleEdit}
|
||||
additionalOperations={
|
||||
row.relationId
|
||||
? [
|
||||
@@ -272,7 +258,7 @@ const CollectionRow = ({
|
||||
}
|
||||
/>
|
||||
),
|
||||
[entry.id, handleAdd, handleEdit, row.relationId]
|
||||
[entry.id, handleAdd, row.relationId]
|
||||
);
|
||||
return (
|
||||
<EntityRowShell
|
||||
|
||||
@@ -26,7 +26,6 @@ const GLOBAL_DIALOGS = {
|
||||
|
||||
const WORKSPACE_DIALOGS = {
|
||||
// 'doc-info': DocInfoDialog,
|
||||
// 'collection-editor': CollectionEditorDialog,
|
||||
'tag-selector': TagSelectorDialog,
|
||||
'doc-selector': DocSelectorDialog,
|
||||
'collection-selector': CollectionSelectorDialog,
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { test } from '@affine-test/kit/mobile';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import {
|
||||
expandCollapsibleSection,
|
||||
openNavigationPanelNodeMenu,
|
||||
pageBack,
|
||||
} from './utils';
|
||||
|
||||
test('collection menu does not offer an edit action', async ({ page }) => {
|
||||
const name = 'Test Collection';
|
||||
const section = await expandCollapsibleSection(page, 'collections');
|
||||
await section.getByTestId('navigation-panel-bar-add-collection-button').tap();
|
||||
await page.getByTestId('prompt-modal-input').fill(name);
|
||||
await page.getByTestId('prompt-modal-confirm').tap();
|
||||
await pageBack(page);
|
||||
|
||||
const collection = section.locator(
|
||||
`[data-role="navigation-panel-collection"][aria-label="${name}"]`
|
||||
);
|
||||
await expect(collection).toBeVisible();
|
||||
|
||||
const menu = await openNavigationPanelNodeMenu(page, collection);
|
||||
await expect(menu.getByText('Delete')).toBeVisible();
|
||||
await expect(menu.getByText('Edit collection')).toHaveCount(0);
|
||||
});
|
||||
Reference in new issue
Block a user