feat(core): add remove from collection to collection page list (#6265)
close AFF-246
This commit is contained in:
@@ -2,6 +2,7 @@ import { toast } from '@affine/component';
|
|||||||
import { useBlockSuiteMetaHelper } from '@affine/core/hooks/affine/use-block-suite-meta-helper';
|
import { useBlockSuiteMetaHelper } from '@affine/core/hooks/affine/use-block-suite-meta-helper';
|
||||||
import { useTrashModalHelper } from '@affine/core/hooks/affine/use-trash-modal-helper';
|
import { useTrashModalHelper } from '@affine/core/hooks/affine/use-trash-modal-helper';
|
||||||
import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta';
|
import { useBlockSuiteDocMeta } from '@affine/core/hooks/use-block-suite-page-meta';
|
||||||
|
import { CollectionService } from '@affine/core/modules/collection';
|
||||||
import type { Tag } from '@affine/core/modules/tag';
|
import type { Tag } from '@affine/core/modules/tag';
|
||||||
import { Workbench } from '@affine/core/modules/workbench';
|
import { Workbench } from '@affine/core/modules/workbench';
|
||||||
import type { Collection, Filter } from '@affine/env/filter';
|
import type { Collection, Filter } from '@affine/env/filter';
|
||||||
@@ -36,9 +37,17 @@ const usePageOperationsRenderer = () => {
|
|||||||
);
|
);
|
||||||
const t = useAFFiNEI18N();
|
const t = useAFFiNEI18N();
|
||||||
const workbench = useService(Workbench);
|
const workbench = useService(Workbench);
|
||||||
|
const collectionService = useService(CollectionService);
|
||||||
|
const removeFromAllowList = useCallback(
|
||||||
|
(id: string) => {
|
||||||
|
collectionService.deletePagesFromCollections([id]);
|
||||||
|
toast(t['com.affine.collection.removePage.success']());
|
||||||
|
},
|
||||||
|
[collectionService, t]
|
||||||
|
);
|
||||||
|
|
||||||
const pageOperationsRenderer = useCallback(
|
const pageOperationsRenderer = useCallback(
|
||||||
(page: DocMeta) => {
|
(page: DocMeta, isInAllowList?: boolean) => {
|
||||||
const onDisablePublicSharing = () => {
|
const onDisablePublicSharing = () => {
|
||||||
toast('Successfully disabled', {
|
toast('Successfully disabled', {
|
||||||
portal: document.body,
|
portal: document.body,
|
||||||
@@ -49,6 +58,7 @@ const usePageOperationsRenderer = () => {
|
|||||||
<PageOperationCell
|
<PageOperationCell
|
||||||
favorite={!!page.favorite}
|
favorite={!!page.favorite}
|
||||||
isPublic={!!page.isPublic}
|
isPublic={!!page.isPublic}
|
||||||
|
isInAllowList={isInAllowList}
|
||||||
onDisablePublicSharing={onDisablePublicSharing}
|
onDisablePublicSharing={onDisablePublicSharing}
|
||||||
link={`/workspace/${currentWorkspace.id}/${page.id}`}
|
link={`/workspace/${currentWorkspace.id}/${page.id}`}
|
||||||
onOpenInSplitView={() => workbench.openPage(page.id, { at: 'tail' })}
|
onOpenInSplitView={() => workbench.openPage(page.id, { at: 'tail' })}
|
||||||
@@ -71,6 +81,7 @@ const usePageOperationsRenderer = () => {
|
|||||||
: t['com.affine.toastMessage.addedFavorites']()
|
: t['com.affine.toastMessage.addedFavorites']()
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
onRemoveFromAllowList={() => removeFromAllowList(page.id)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -81,6 +92,7 @@ const usePageOperationsRenderer = () => {
|
|||||||
setTrashModal,
|
setTrashModal,
|
||||||
toggleFavorite,
|
toggleFavorite,
|
||||||
t,
|
t,
|
||||||
|
removeFromAllowList,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -134,9 +146,10 @@ export const VirtualizedPageList = ({
|
|||||||
const pageOperationRenderer = useCallback(
|
const pageOperationRenderer = useCallback(
|
||||||
(item: ListItem) => {
|
(item: ListItem) => {
|
||||||
const page = item as DocMeta;
|
const page = item as DocMeta;
|
||||||
return pageOperations(page);
|
const isInAllowList = collection?.allowList?.includes(page.id);
|
||||||
|
return pageOperations(page, isInAllowList);
|
||||||
},
|
},
|
||||||
[pageOperations]
|
[collection, pageOperations]
|
||||||
);
|
);
|
||||||
|
|
||||||
const pageHeaderRenderer = useCallback(() => {
|
const pageHeaderRenderer = useCallback(() => {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
FavoritedIcon,
|
FavoritedIcon,
|
||||||
FavoriteIcon,
|
FavoriteIcon,
|
||||||
FilterIcon,
|
FilterIcon,
|
||||||
|
FilterMinusIcon,
|
||||||
MoreVerticalIcon,
|
MoreVerticalIcon,
|
||||||
OpenInNewIcon,
|
OpenInNewIcon,
|
||||||
ResetIcon,
|
ResetIcon,
|
||||||
@@ -39,26 +40,31 @@ export interface PageOperationCellProps {
|
|||||||
favorite: boolean;
|
favorite: boolean;
|
||||||
isPublic: boolean;
|
isPublic: boolean;
|
||||||
link: string;
|
link: string;
|
||||||
|
isInAllowList?: boolean;
|
||||||
onToggleFavoritePage: () => void;
|
onToggleFavoritePage: () => void;
|
||||||
onRemoveToTrash: () => void;
|
onRemoveToTrash: () => void;
|
||||||
onDuplicate: () => void;
|
onDuplicate: () => void;
|
||||||
onDisablePublicSharing: () => void;
|
onDisablePublicSharing: () => void;
|
||||||
onOpenInSplitView: () => void;
|
onOpenInSplitView: () => void;
|
||||||
|
onRemoveFromAllowList?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PageOperationCell = ({
|
export const PageOperationCell = ({
|
||||||
favorite,
|
favorite,
|
||||||
isPublic,
|
isPublic,
|
||||||
|
isInAllowList,
|
||||||
link,
|
link,
|
||||||
onToggleFavoritePage,
|
onToggleFavoritePage,
|
||||||
onRemoveToTrash,
|
onRemoveToTrash,
|
||||||
onDuplicate,
|
onDuplicate,
|
||||||
onDisablePublicSharing,
|
onDisablePublicSharing,
|
||||||
onOpenInSplitView,
|
onOpenInSplitView,
|
||||||
|
onRemoveFromAllowList,
|
||||||
}: PageOperationCellProps) => {
|
}: PageOperationCellProps) => {
|
||||||
const t = useAFFiNEI18N();
|
const t = useAFFiNEI18N();
|
||||||
const { appSettings } = useAppSettingHelper();
|
const { appSettings } = useAppSettingHelper();
|
||||||
const [openDisableShared, setOpenDisableShared] = useState(false);
|
const [openDisableShared, setOpenDisableShared] = useState(false);
|
||||||
|
|
||||||
const OperationMenu = (
|
const OperationMenu = (
|
||||||
<>
|
<>
|
||||||
{isPublic && (
|
{isPublic && (
|
||||||
@@ -69,6 +75,18 @@ export const PageOperationCell = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{isInAllowList && (
|
||||||
|
<MenuItem
|
||||||
|
onClick={onRemoveFromAllowList}
|
||||||
|
preFix={
|
||||||
|
<MenuIcon>
|
||||||
|
<FilterMinusIcon />
|
||||||
|
</MenuIcon>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{t['Remove special filter']()}
|
||||||
|
</MenuItem>
|
||||||
|
)}
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={onToggleFavoritePage}
|
onClick={onToggleFavoritePage}
|
||||||
preFix={
|
preFix={
|
||||||
|
|||||||
Reference in New Issue
Block a user