mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-01 01:29:31 +08:00
feat(core): adjust pinned collections edit button (#12533)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added a centralized "Edit collection rules" button in the pinned collections footer, enabling users to edit collection rules via a dialog. - **Style** - Removed hover effects and visual styling from the edit icon button in pinned collections. - **Bug Fixes** - Removed per-item edit buttons to streamline the editing process. - **Documentation** - Added a new localized label for the edit collection rules action. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -122,7 +122,7 @@ export const AllPage = () => {
|
|||||||
.watch(
|
.watch(
|
||||||
selectedCollectionInfo
|
selectedCollectionInfo
|
||||||
? {
|
? {
|
||||||
filters: tempFilters ?? selectedCollectionInfo.rules.filters,
|
filters: selectedCollectionInfo.rules.filters,
|
||||||
groupBy,
|
groupBy,
|
||||||
orderBy,
|
orderBy,
|
||||||
extraAllowList: selectedCollectionInfo.allowList,
|
extraAllowList: selectedCollectionInfo.allowList,
|
||||||
@@ -221,19 +221,6 @@ export const AllPage = () => {
|
|||||||
setTempFilters(null);
|
setTempFilters(null);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleEditCollection = useCallback(
|
|
||||||
(collectionId: string) => {
|
|
||||||
const collection = collectionService.collection$(collectionId).value;
|
|
||||||
if (!collection) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setSelectedCollectionId(collectionId);
|
|
||||||
setTempFilters(collection.info$.value.rules.filters);
|
|
||||||
setTempFiltersInitial(null);
|
|
||||||
},
|
|
||||||
[collectionService]
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleSaveFilters = useCallback(() => {
|
const handleSaveFilters = useCallback(() => {
|
||||||
if (selectedCollectionId) {
|
if (selectedCollectionId) {
|
||||||
collectionService.updateCollection(selectedCollectionId, {
|
collectionService.updateCollection(selectedCollectionId, {
|
||||||
@@ -312,7 +299,6 @@ export const AllPage = () => {
|
|||||||
onActiveAll={handleSelectAll}
|
onActiveAll={handleSelectAll}
|
||||||
onActiveCollection={handleSelectCollection}
|
onActiveCollection={handleSelectCollection}
|
||||||
onAddFilter={handleNewTempFilter}
|
onAddFilter={handleNewTempFilter}
|
||||||
onEditCollection={handleEditCollection}
|
|
||||||
hiddenAdd={tempFilters !== null}
|
hiddenAdd={tempFilters !== null}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+1
-19
@@ -35,27 +35,9 @@ export const itemContent = style({
|
|||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
maxWidth: '128px',
|
maxWidth: '128px',
|
||||||
minWidth: '32px',
|
minWidth: '32px',
|
||||||
|
|
||||||
selectors: {
|
|
||||||
[`${item}:hover > &`]: {
|
|
||||||
mask:
|
|
||||||
'linear-gradient(#fff) left / calc(100% - 32px) no-repeat,' +
|
|
||||||
'linear-gradient(90deg,#fff 0%,transparent 50%,transparent 100%) right / 32px no-repeat',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const editIconButton = style({
|
export const editIconButton = style({});
|
||||||
opacity: 0,
|
|
||||||
marginLeft: -16,
|
|
||||||
backgroundColor: cssVarV2('layer/background/hoverOverlay'),
|
|
||||||
|
|
||||||
selectors: {
|
|
||||||
[`${item}:hover > &`]: {
|
|
||||||
opacity: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export const closeButton = style({});
|
export const closeButton = style({});
|
||||||
|
|
||||||
|
|||||||
+25
-16
@@ -1,4 +1,10 @@
|
|||||||
import { Divider, IconButton, Menu, MenuItem } from '@affine/component';
|
import {
|
||||||
|
Divider,
|
||||||
|
IconButton,
|
||||||
|
Menu,
|
||||||
|
MenuItem,
|
||||||
|
Tooltip,
|
||||||
|
} from '@affine/component';
|
||||||
import { AddFilterMenu } from '@affine/core/components/filter/add-filter';
|
import { AddFilterMenu } from '@affine/core/components/filter/add-filter';
|
||||||
import {
|
import {
|
||||||
CollectionService,
|
CollectionService,
|
||||||
@@ -6,6 +12,7 @@ import {
|
|||||||
PinnedCollectionService,
|
PinnedCollectionService,
|
||||||
} from '@affine/core/modules/collection';
|
} from '@affine/core/modules/collection';
|
||||||
import type { FilterParams } from '@affine/core/modules/collection-rules';
|
import type { FilterParams } from '@affine/core/modules/collection-rules';
|
||||||
|
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
|
||||||
import { useI18n } from '@affine/i18n';
|
import { useI18n } from '@affine/i18n';
|
||||||
import {
|
import {
|
||||||
CloseIcon,
|
CloseIcon,
|
||||||
@@ -24,13 +31,11 @@ export const PinnedCollectionItem = ({
|
|||||||
isActive,
|
isActive,
|
||||||
onClick,
|
onClick,
|
||||||
onClickRemove,
|
onClickRemove,
|
||||||
onClickEdit,
|
|
||||||
}: {
|
}: {
|
||||||
record: PinnedCollectionRecord;
|
record: PinnedCollectionRecord;
|
||||||
onClickRemove: () => void;
|
onClickRemove: () => void;
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
onClickEdit: () => void;
|
|
||||||
}) => {
|
}) => {
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
const collectionService = useService(CollectionService);
|
const collectionService = useService(CollectionService);
|
||||||
@@ -49,16 +54,6 @@ export const PinnedCollectionItem = ({
|
|||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
<span className={styles.itemContent}>{name ?? t['Untitled']()}</span>
|
<span className={styles.itemContent}>{name ?? t['Untitled']()}</span>
|
||||||
<IconButton
|
|
||||||
size="16"
|
|
||||||
className={styles.editIconButton}
|
|
||||||
onClick={e => {
|
|
||||||
e.stopPropagation();
|
|
||||||
onClickEdit();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<EditIcon />
|
|
||||||
</IconButton>
|
|
||||||
{isActive && (
|
{isActive && (
|
||||||
<IconButton
|
<IconButton
|
||||||
className={styles.closeButton}
|
className={styles.closeButton}
|
||||||
@@ -80,17 +75,16 @@ export const PinnedCollections = ({
|
|||||||
onActiveAll,
|
onActiveAll,
|
||||||
onActiveCollection,
|
onActiveCollection,
|
||||||
onAddFilter,
|
onAddFilter,
|
||||||
onEditCollection,
|
|
||||||
hiddenAdd,
|
hiddenAdd,
|
||||||
}: {
|
}: {
|
||||||
activeCollectionId: string | null;
|
activeCollectionId: string | null;
|
||||||
onActiveAll: () => void;
|
onActiveAll: () => void;
|
||||||
onActiveCollection: (collectionId: string) => void;
|
onActiveCollection: (collectionId: string) => void;
|
||||||
onAddFilter: (params: FilterParams) => void;
|
onAddFilter: (params: FilterParams) => void;
|
||||||
onEditCollection: (collectionId: string) => void;
|
|
||||||
hiddenAdd?: boolean;
|
hiddenAdd?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
|
const workspaceDialogService = useService(WorkspaceDialogService);
|
||||||
const pinnedCollectionService = useService(PinnedCollectionService);
|
const pinnedCollectionService = useService(PinnedCollectionService);
|
||||||
const pinnedCollections = useLiveData(
|
const pinnedCollections = useLiveData(
|
||||||
pinnedCollectionService.sortedPinnedCollections$
|
pinnedCollectionService.sortedPinnedCollections$
|
||||||
@@ -127,7 +121,6 @@ export const PinnedCollections = ({
|
|||||||
? onActiveCollection(record.collectionId)
|
? onActiveCollection(record.collectionId)
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
onClickEdit={() => onEditCollection(record.collectionId)}
|
|
||||||
onClickRemove={() => {
|
onClickRemove={() => {
|
||||||
const nextCollectionId = pinnedCollections[index - 1]?.collectionId;
|
const nextCollectionId = pinnedCollections[index - 1]?.collectionId;
|
||||||
if (nextCollectionId) {
|
if (nextCollectionId) {
|
||||||
@@ -145,6 +138,22 @@ export const PinnedCollections = ({
|
|||||||
onAddFilter={onAddFilter}
|
onAddFilter={onAddFilter}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
<div style={{ flex: 1 }}></div>
|
||||||
|
{activeCollectionId && (
|
||||||
|
<Tooltip content={t['com.affine.all-docs.pinned-collection.edit']()}>
|
||||||
|
<IconButton
|
||||||
|
size="16"
|
||||||
|
className={styles.editIconButton}
|
||||||
|
onClick={() =>
|
||||||
|
workspaceDialogService.open('collection-editor', {
|
||||||
|
collectionId: activeCollectionId,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<EditIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7172,6 +7172,10 @@ export function useAFFiNEI18N(): {
|
|||||||
* `All`
|
* `All`
|
||||||
*/
|
*/
|
||||||
["com.affine.all-docs.pinned-collection.all"](): string;
|
["com.affine.all-docs.pinned-collection.all"](): string;
|
||||||
|
/**
|
||||||
|
* `Edit collection rules`
|
||||||
|
*/
|
||||||
|
["com.affine.all-docs.pinned-collection.edit"](): string;
|
||||||
/**
|
/**
|
||||||
* `Template`
|
* `Template`
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1792,6 +1792,7 @@
|
|||||||
"com.affine.all-docs.quick-action.delete-permanently": "Delete permanently",
|
"com.affine.all-docs.quick-action.delete-permanently": "Delete permanently",
|
||||||
"com.affine.all-docs.quick-action.restore": "Restore",
|
"com.affine.all-docs.quick-action.restore": "Restore",
|
||||||
"com.affine.all-docs.pinned-collection.all": "All",
|
"com.affine.all-docs.pinned-collection.all": "All",
|
||||||
|
"com.affine.all-docs.pinned-collection.edit": "Edit collection rules",
|
||||||
"com.affine.all-docs.group.is-template": "Template",
|
"com.affine.all-docs.group.is-template": "Template",
|
||||||
"com.affine.all-docs.group.is-not-template": "Not Template",
|
"com.affine.all-docs.group.is-not-template": "Not Template",
|
||||||
"com.affine.all-docs.group.is-journal": "Journal",
|
"com.affine.all-docs.group.is-journal": "Journal",
|
||||||
|
|||||||
Reference in New Issue
Block a user