mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-26 14:58:55 +08:00
feat(core): adjust collection rules (#12268)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Trashed page titles are now visually indicated with a strikethrough style in collection editor dialogs. - **Bug Fixes** - Trashed pages are now properly excluded from allowed lists and filtered views. - **Refactor** - Improved filtering logic for collections and page lists, separating user filters from system filters for more consistent results. - Enhanced filter configuration options for more flexible and maintainable filtering behavior. - **Style** - Added a new style for displaying trashed items with a strikethrough effect. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -37,6 +37,9 @@ export const includeItemTitle = style({
|
||||
overflow: 'hidden',
|
||||
fontWeight: 600,
|
||||
});
|
||||
export const trashTitle = style({
|
||||
textDecoration: 'line-through',
|
||||
});
|
||||
export const includeItemContentIs = style({
|
||||
padding: '0 8px',
|
||||
color: cssVar('textSecondaryColor'),
|
||||
|
||||
@@ -49,21 +49,23 @@ export const RulesMode = ({
|
||||
|
||||
useEffect(() => {
|
||||
const subscription = collectionRulesService
|
||||
.watch(
|
||||
collection.rules.filters.length > 0
|
||||
? [
|
||||
...collection.rules.filters,
|
||||
{
|
||||
type: 'system',
|
||||
key: 'trash',
|
||||
method: 'is',
|
||||
value: 'false',
|
||||
},
|
||||
]
|
||||
: [],
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
.watch({
|
||||
filters: collection.rules.filters,
|
||||
extraFilters: [
|
||||
{
|
||||
type: 'system',
|
||||
key: 'trash',
|
||||
method: 'is',
|
||||
value: 'false',
|
||||
},
|
||||
{
|
||||
type: 'system',
|
||||
key: 'empty-journal',
|
||||
method: 'is',
|
||||
value: 'false',
|
||||
},
|
||||
],
|
||||
})
|
||||
.subscribe(rules => {
|
||||
setRulesPageIds(rules.groups.flatMap(group => group.items));
|
||||
});
|
||||
@@ -82,7 +84,8 @@ export const RulesMode = ({
|
||||
return allPageListConfig.allPages.filter(meta => {
|
||||
return (
|
||||
collection.allowList.includes(meta.id) &&
|
||||
!rulesPageIds.includes(meta.id)
|
||||
!rulesPageIds.includes(meta.id) &&
|
||||
!meta.trash
|
||||
);
|
||||
});
|
||||
}, [allPageListConfig.allPages, collection.allowList, rulesPageIds]);
|
||||
@@ -196,6 +199,7 @@ export const RulesMode = ({
|
||||
<div
|
||||
className={clsx(
|
||||
styles.includeItemTitle,
|
||||
page?.trash && styles.trashTitle,
|
||||
styles.ellipsis
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -143,9 +143,22 @@ export const AllPage = () => {
|
||||
const collectionRulesService = useService(CollectionRulesService);
|
||||
useEffect(() => {
|
||||
const subscription = collectionRulesService
|
||||
.watch(
|
||||
[
|
||||
...(filters ?? []),
|
||||
.watch({
|
||||
filters:
|
||||
filters && filters.length > 0
|
||||
? filters
|
||||
: [
|
||||
// if no filters are present, match all non-trash documents
|
||||
{
|
||||
type: 'system',
|
||||
key: 'trash',
|
||||
method: 'is',
|
||||
value: 'false',
|
||||
},
|
||||
],
|
||||
groupBy,
|
||||
orderBy,
|
||||
extraFilters: [
|
||||
{
|
||||
type: 'system',
|
||||
key: 'empty-journal',
|
||||
@@ -159,9 +172,7 @@ export const AllPage = () => {
|
||||
value: 'false',
|
||||
},
|
||||
],
|
||||
groupBy,
|
||||
orderBy
|
||||
)
|
||||
})
|
||||
.subscribe({
|
||||
next: result => {
|
||||
explorerContextValue.groups$.next(result.groups);
|
||||
|
||||
Reference in New Issue
Block a user