@elementor/editor-site-navigation 4.5.0-1216 → 4.5.0-1218
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +830 -344
- package/dist/index.mjs +782 -288
- package/package.json +11 -10
- package/src/api/post.ts +21 -5
- package/src/components/panel/actions-menu/action-menu-item.tsx +4 -3
- package/src/components/panel/actions-menu/actions/force-delete.tsx +99 -0
- package/src/components/panel/actions-menu/actions/restore.tsx +33 -0
- package/src/components/panel/content-panel-active-filters.tsx +53 -0
- package/src/components/panel/content-panel-chrome.ts +19 -0
- package/src/components/panel/content-panel-clear-filters-button.tsx +22 -0
- package/src/components/panel/content-panel-search.tsx +1 -2
- package/src/components/panel/content-panel-status-filter-list.tsx +70 -0
- package/src/components/panel/content-panel-status-filter.tsx +75 -0
- package/src/components/panel/content-panel-toolbar.tsx +23 -0
- package/src/components/panel/posts-list/collapsible-list.tsx +7 -4
- package/src/components/panel/posts-list/list-items/list-item-view.tsx +80 -47
- package/src/components/panel/posts-list/list-items/site-content-list-item-actions-location.tsx +14 -0
- package/src/components/panel/posts-list/posts-collapsible-list.tsx +30 -9
- package/src/components/panel/shell.tsx +6 -2
- package/src/components/shared/page-title-and-status.tsx +2 -0
- package/src/contexts/content-panel-coordinator.tsx +34 -3
- package/src/hooks/use-posts-actions.ts +20 -1
- package/src/hooks/use-posts-baseline-total.ts +22 -0
- package/src/hooks/use-posts.ts +19 -13
- package/src/hooks/use-site-content-status-filter-counts.ts +56 -0
- package/src/index.ts +5 -0
- package/src/site-content-restore.ts +1 -0
- package/src/site-content-status-filter.ts +111 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-site-navigation",
|
|
3
|
-
"version": "4.5.0-
|
|
3
|
+
"version": "4.5.0-1218",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,16 +39,17 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor-app-bar": "4.5.0-
|
|
43
|
-
"@elementor/editor-documents": "4.5.0-
|
|
44
|
-
"@elementor/editor-panels": "4.5.0-
|
|
45
|
-
"@elementor/editor-sidebar": "4.5.0-
|
|
46
|
-
"@elementor/editor-ui": "4.5.0-
|
|
47
|
-
"@elementor/editor-v1-adapters": "4.5.0-
|
|
48
|
-
"@elementor/env": "4.5.0-
|
|
42
|
+
"@elementor/editor-app-bar": "4.5.0-1218",
|
|
43
|
+
"@elementor/editor-documents": "4.5.0-1218",
|
|
44
|
+
"@elementor/editor-panels": "4.5.0-1218",
|
|
45
|
+
"@elementor/editor-sidebar": "4.5.0-1218",
|
|
46
|
+
"@elementor/editor-ui": "4.5.0-1218",
|
|
47
|
+
"@elementor/editor-v1-adapters": "4.5.0-1218",
|
|
48
|
+
"@elementor/env": "4.5.0-1218",
|
|
49
|
+
"@elementor/events": "4.5.0-1218",
|
|
49
50
|
"@elementor/icons": "~1.78.1",
|
|
50
|
-
"@elementor/
|
|
51
|
-
"@elementor/query": "4.5.0-
|
|
51
|
+
"@elementor/locations": "4.5.0-1218",
|
|
52
|
+
"@elementor/query": "4.5.0-1218",
|
|
52
53
|
"@elementor/ui": "1.41.4",
|
|
53
54
|
"@wordpress/api-fetch": "^6.42.0",
|
|
54
55
|
"@wordpress/i18n": "^5.13.0"
|
package/src/api/post.ts
CHANGED
|
@@ -10,6 +10,7 @@ export type NewPost = {
|
|
|
10
10
|
|
|
11
11
|
export type UpdatePost = {
|
|
12
12
|
id: number;
|
|
13
|
+
status?: 'draft' | 'publish';
|
|
13
14
|
title?: string;
|
|
14
15
|
};
|
|
15
16
|
|
|
@@ -58,6 +59,8 @@ export function getCannotEditPanelItemMessage( postTypeSlug: Slug ): string {
|
|
|
58
59
|
|
|
59
60
|
export const POST_PER_PAGE = 10;
|
|
60
61
|
|
|
62
|
+
export const COUNT_QUERY_PER_PAGE = 1;
|
|
63
|
+
|
|
61
64
|
type WpPostsResponse = {
|
|
62
65
|
json: () => Promise< Post[] >;
|
|
63
66
|
headers: {
|
|
@@ -72,16 +75,22 @@ export type PostsResponse = {
|
|
|
72
75
|
currentPage: number;
|
|
73
76
|
};
|
|
74
77
|
|
|
75
|
-
export const getRequest = async (
|
|
78
|
+
export const getRequest = async (
|
|
79
|
+
postTypeSlug: Slug,
|
|
80
|
+
page: number,
|
|
81
|
+
search = '',
|
|
82
|
+
status: string = 'any',
|
|
83
|
+
perPage = POST_PER_PAGE
|
|
84
|
+
): Promise< PostsResponse > => {
|
|
76
85
|
const baseUri = `/wp/v2/${ postTypesMap[ postTypeSlug ].rest_base }`;
|
|
77
86
|
|
|
78
87
|
const keys: Array< keyof Post > = [ 'id', 'type', 'title', 'link', 'status', 'user_can' ];
|
|
79
88
|
|
|
80
89
|
const queryParams = new URLSearchParams( {
|
|
81
|
-
status
|
|
90
|
+
status,
|
|
82
91
|
order: 'asc',
|
|
83
92
|
page: page.toString(),
|
|
84
|
-
per_page:
|
|
93
|
+
per_page: perPage.toString(),
|
|
85
94
|
_fields: keys.join( ',' ),
|
|
86
95
|
} );
|
|
87
96
|
|
|
@@ -128,15 +137,22 @@ export const updateRequest = ( postTypeSlug: Slug, updatedPost: UpdatePost ) =>
|
|
|
128
137
|
} );
|
|
129
138
|
};
|
|
130
139
|
|
|
131
|
-
export const deleteRequest = ( postTypeSlug: Slug, postId: number ) => {
|
|
140
|
+
export const deleteRequest = ( postTypeSlug: Slug, postId: number, force = false ) => {
|
|
132
141
|
const path = `/wp/v2/${ postTypesMap[ postTypeSlug ].rest_base }`;
|
|
142
|
+
const forceQuery = force ? '?force=true' : '';
|
|
133
143
|
|
|
134
144
|
return apiFetch( {
|
|
135
|
-
path: `${ path }/${ postId }`,
|
|
145
|
+
path: `${ path }/${ postId }${ forceQuery }`,
|
|
136
146
|
method: 'DELETE',
|
|
137
147
|
} );
|
|
138
148
|
};
|
|
139
149
|
|
|
150
|
+
export const fetchPostsTotal = async ( postTypeSlug: Slug, status = 'any', search = '' ): Promise< number > => {
|
|
151
|
+
const response = await getRequest( postTypeSlug, 1, search, status, COUNT_QUERY_PER_PAGE );
|
|
152
|
+
|
|
153
|
+
return response.totalPosts;
|
|
154
|
+
};
|
|
155
|
+
|
|
140
156
|
export const duplicateRequest = ( originalPost: UpdatePost ) => {
|
|
141
157
|
const path = `/elementor/v1/site-navigation/duplicate-post`;
|
|
142
158
|
|
|
@@ -3,12 +3,13 @@ import { type ComponentType } from 'react';
|
|
|
3
3
|
import { ListItemIcon, ListItemText, MenuItem, type MenuItemProps as MenuItemPropsType } from '@elementor/ui';
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
|
-
|
|
6
|
+
description?: string;
|
|
7
7
|
icon: ComponentType;
|
|
8
8
|
MenuItemProps: MenuItemPropsType;
|
|
9
|
+
title: string;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
|
-
export default function ActionMenuItem( {
|
|
12
|
+
export default function ActionMenuItem( { description, icon: Icon, MenuItemProps, title }: Props ) {
|
|
12
13
|
return (
|
|
13
14
|
<MenuItem { ...MenuItemProps }>
|
|
14
15
|
<ListItemIcon
|
|
@@ -18,7 +19,7 @@ export default function ActionMenuItem( { title, icon: Icon, MenuItemProps }: Pr
|
|
|
18
19
|
>
|
|
19
20
|
<Icon />
|
|
20
21
|
</ListItemIcon>
|
|
21
|
-
<ListItemText primary={ title } />
|
|
22
|
+
<ListItemText primary={ title } secondary={ description } />
|
|
22
23
|
</MenuItem>
|
|
23
24
|
);
|
|
24
25
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { TrashIcon } from '@elementor/icons';
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
CircularProgress,
|
|
7
|
+
Dialog,
|
|
8
|
+
DialogActions,
|
|
9
|
+
DialogContent,
|
|
10
|
+
DialogContentText,
|
|
11
|
+
DialogTitle,
|
|
12
|
+
Divider,
|
|
13
|
+
} from '@elementor/ui';
|
|
14
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
15
|
+
|
|
16
|
+
import { usePostListContext } from '../../../../contexts/post-list-context';
|
|
17
|
+
import { usePostActions } from '../../../../hooks/use-posts-actions';
|
|
18
|
+
import { type Post } from '../../../../types';
|
|
19
|
+
import ActionMenuItem from '../action-menu-item';
|
|
20
|
+
|
|
21
|
+
export default function ForceDelete( { post }: { post: Post } ) {
|
|
22
|
+
const [ isDialogOpen, setIsDialogOpen ] = useState( false );
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<ActionMenuItem
|
|
27
|
+
icon={ TrashIcon }
|
|
28
|
+
MenuItemProps={ {
|
|
29
|
+
disabled: ! post.user_can.delete,
|
|
30
|
+
onClick: () => setIsDialogOpen( true ),
|
|
31
|
+
sx: { '&:hover': { color: 'error.main' } },
|
|
32
|
+
} }
|
|
33
|
+
title={ __( 'Delete permanently', 'elementor' ) }
|
|
34
|
+
/>
|
|
35
|
+
{ isDialogOpen && <ForceDeleteDialog post={ post } setIsDialogOpen={ setIsDialogOpen } /> }
|
|
36
|
+
</>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function ForceDeleteDialog( {
|
|
41
|
+
post,
|
|
42
|
+
setIsDialogOpen,
|
|
43
|
+
}: {
|
|
44
|
+
post: Post;
|
|
45
|
+
setIsDialogOpen: React.Dispatch< React.SetStateAction< boolean > >;
|
|
46
|
+
} ) {
|
|
47
|
+
const { setError, type } = usePostListContext();
|
|
48
|
+
const { forceDeletePost } = usePostActions( type );
|
|
49
|
+
|
|
50
|
+
/* translators: %s: Post title. */
|
|
51
|
+
const dialogTitle = sprintf( __( 'Delete "%s" permanently?', 'elementor' ), post.title.rendered );
|
|
52
|
+
const dialogBody = __( 'This will permanently delete the item. You cannot undo this action.', 'elementor' );
|
|
53
|
+
|
|
54
|
+
const handleDelete = async () => {
|
|
55
|
+
try {
|
|
56
|
+
await forceDeletePost.mutateAsync( post.id );
|
|
57
|
+
setIsDialogOpen( false );
|
|
58
|
+
} catch {
|
|
59
|
+
setError();
|
|
60
|
+
setIsDialogOpen( false );
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const handleCancel = () => {
|
|
65
|
+
if ( forceDeletePost.isPending ) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setIsDialogOpen( false );
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Dialog aria-labelledby="force-delete-dialog" onClose={ handleCancel } open>
|
|
74
|
+
<DialogTitle noWrap>{ dialogTitle }</DialogTitle>
|
|
75
|
+
<Divider />
|
|
76
|
+
<DialogContent>
|
|
77
|
+
<DialogContentText>{ dialogBody }</DialogContentText>
|
|
78
|
+
</DialogContent>
|
|
79
|
+
<DialogActions>
|
|
80
|
+
<Button
|
|
81
|
+
variant="contained"
|
|
82
|
+
color="secondary"
|
|
83
|
+
onClick={ handleCancel }
|
|
84
|
+
disabled={ forceDeletePost.isPending }
|
|
85
|
+
>
|
|
86
|
+
{ __( 'Cancel', 'elementor' ) }
|
|
87
|
+
</Button>
|
|
88
|
+
<Button
|
|
89
|
+
variant="contained"
|
|
90
|
+
color="error"
|
|
91
|
+
onClick={ () => void handleDelete() }
|
|
92
|
+
disabled={ forceDeletePost.isPending }
|
|
93
|
+
>
|
|
94
|
+
{ ! forceDeletePost.isPending ? __( 'Delete permanently', 'elementor' ) : <CircularProgress /> }
|
|
95
|
+
</Button>
|
|
96
|
+
</DialogActions>
|
|
97
|
+
</Dialog>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { RefreshIcon } from '@elementor/icons';
|
|
3
|
+
import { __ } from '@wordpress/i18n';
|
|
4
|
+
|
|
5
|
+
import { usePostListContext } from '../../../../contexts/post-list-context';
|
|
6
|
+
import { usePostActions } from '../../../../hooks/use-posts-actions';
|
|
7
|
+
import { type Post } from '../../../../types';
|
|
8
|
+
import ActionMenuItem from '../action-menu-item';
|
|
9
|
+
|
|
10
|
+
export default function Restore( { post }: { post: Post } ) {
|
|
11
|
+
const { setError, type } = usePostListContext();
|
|
12
|
+
const { restorePost } = usePostActions( type );
|
|
13
|
+
|
|
14
|
+
const handleClick = async () => {
|
|
15
|
+
try {
|
|
16
|
+
await restorePost.mutateAsync( post.id );
|
|
17
|
+
} catch {
|
|
18
|
+
setError();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<ActionMenuItem
|
|
24
|
+
description={ __( 'Restored as draft', 'elementor' ) }
|
|
25
|
+
title={ __( 'Restore', 'elementor' ) }
|
|
26
|
+
icon={ RefreshIcon }
|
|
27
|
+
MenuItemProps={ {
|
|
28
|
+
disabled: restorePost.isPending || ! post.user_can.delete,
|
|
29
|
+
onClick: () => void handleClick(),
|
|
30
|
+
} }
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Chip, Stack } from '@elementor/ui';
|
|
3
|
+
import { __ } from '@wordpress/i18n';
|
|
4
|
+
|
|
5
|
+
import { useContentPanelCoordinator } from '../../contexts/content-panel-coordinator';
|
|
6
|
+
import {
|
|
7
|
+
getActiveSiteContentStatusFilterKeys,
|
|
8
|
+
getSiteContentStatusFilterLabel,
|
|
9
|
+
hasActiveSiteContentStatusFilters,
|
|
10
|
+
} from '../../site-content-status-filter';
|
|
11
|
+
import ContentPanelClearFiltersButton from './content-panel-clear-filters-button';
|
|
12
|
+
|
|
13
|
+
const contentPanelFilterChipSx = {
|
|
14
|
+
'& .MuiChip-deleteIcon': {
|
|
15
|
+
display: 'none',
|
|
16
|
+
transition: 'opacity 0.2s',
|
|
17
|
+
},
|
|
18
|
+
'&:hover .MuiChip-deleteIcon': {
|
|
19
|
+
display: 'block',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default function ContentPanelActiveFilters() {
|
|
24
|
+
const { clearStatusFilters, statusFilters, toggleStatusFilter } = useContentPanelCoordinator();
|
|
25
|
+
|
|
26
|
+
if ( ! hasActiveSiteContentStatusFilters( statusFilters ) ) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const activeKeys = getActiveSiteContentStatusFilterKeys( statusFilters );
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Stack alignItems="center" direction="row" justifyContent="space-between">
|
|
34
|
+
<Stack alignItems="center" direction="row" flexWrap="wrap" gap={ 0.5 }>
|
|
35
|
+
{ activeKeys.map( ( key ) => (
|
|
36
|
+
<Chip
|
|
37
|
+
key={ key }
|
|
38
|
+
label={ getSiteContentStatusFilterLabel( key ) }
|
|
39
|
+
onDelete={ () => toggleStatusFilter( key ) }
|
|
40
|
+
size="tiny"
|
|
41
|
+
sx={ contentPanelFilterChipSx }
|
|
42
|
+
/>
|
|
43
|
+
) ) }
|
|
44
|
+
</Stack>
|
|
45
|
+
<ContentPanelClearFiltersButton
|
|
46
|
+
ariaLabel={ __( 'Clear Filters', 'elementor' ) }
|
|
47
|
+
onClear={ clearStatusFilters }
|
|
48
|
+
sx={ { margin: '0 0 auto auto' } }
|
|
49
|
+
tooltipText={ __( 'Clear Filters', 'elementor' ) }
|
|
50
|
+
/>
|
|
51
|
+
</Stack>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const CONTENT_PANEL_INSET_SPACING = 2;
|
|
2
2
|
const CONTENT_PANEL_LIST_ROW_GAP = 0.5;
|
|
3
3
|
const CONTENT_PANEL_LIST_ROW_INSET_INLINE = 0.75;
|
|
4
|
+
const CONTENT_PANEL_LIST_ROW_ACTIVE_SECONDARY_INSET = 10;
|
|
4
5
|
const CONTENT_PANEL_LIST_ROW_TITLE_FONT_SIZE = '0.75rem';
|
|
5
6
|
const CONTENT_PANEL_LIST_SECTION_BOTTOM_SPACING = 1;
|
|
6
7
|
|
|
@@ -16,6 +17,24 @@ export const contentPanelListRowPaddingSx = {
|
|
|
16
17
|
...contentPanelInsetPaddingSx,
|
|
17
18
|
};
|
|
18
19
|
|
|
20
|
+
const contentPanelListItemActiveActionsInsetSx = {
|
|
21
|
+
'&& > .MuiListItemButton-root': {
|
|
22
|
+
paddingInlineEnd: CONTENT_PANEL_LIST_ROW_ACTIVE_SECONDARY_INSET,
|
|
23
|
+
paddingRight: 'unset',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export function getContentPanelListItemSx( hasActiveRowActions: boolean ) {
|
|
28
|
+
if ( ! hasActiveRowActions ) {
|
|
29
|
+
return contentPanelListRowPaddingSx;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
...contentPanelListRowPaddingSx,
|
|
34
|
+
...contentPanelListItemActiveActionsInsetSx,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
19
38
|
export const contentPanelHeaderStackSx = {
|
|
20
39
|
width: '100%',
|
|
21
40
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { BrushBigIcon } from '@elementor/icons';
|
|
3
|
+
import { Box, IconButton, type SxProps, type Theme, Tooltip } from '@elementor/ui';
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
ariaLabel: string;
|
|
7
|
+
onClear: () => void;
|
|
8
|
+
sx?: SxProps< Theme >;
|
|
9
|
+
tooltipText: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default function ContentPanelClearFiltersButton( { ariaLabel, onClear, sx, tooltipText }: Props ) {
|
|
13
|
+
return (
|
|
14
|
+
<Tooltip disableInteractive placement="top" title={ tooltipText }>
|
|
15
|
+
<Box>
|
|
16
|
+
<IconButton aria-label={ ariaLabel } onClick={ onClear } size="tiny" sx={ sx }>
|
|
17
|
+
<BrushBigIcon fontSize="tiny" />
|
|
18
|
+
</IconButton>
|
|
19
|
+
</Box>
|
|
20
|
+
</Tooltip>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -4,13 +4,12 @@ import { Box, InputAdornment, TextField } from '@elementor/ui';
|
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
|
|
6
6
|
import { useContentPanelCoordinator } from '../../contexts/content-panel-coordinator';
|
|
7
|
-
import { contentPanelSearchBoxSx } from './content-panel-chrome';
|
|
8
7
|
|
|
9
8
|
export default function ContentPanelSearch() {
|
|
10
9
|
const { searchQuery, setSearchQuery } = useContentPanelCoordinator();
|
|
11
10
|
|
|
12
11
|
return (
|
|
13
|
-
<Box component="search"
|
|
12
|
+
<Box component="search" aria-label={ __( 'Search site content', 'elementor' ) }>
|
|
14
13
|
<TextField
|
|
15
14
|
fullWidth
|
|
16
15
|
size="tiny"
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CheckIcon } from '@elementor/icons';
|
|
3
|
+
import { MenuItem, MenuList, Stack, Typography } from '@elementor/ui';
|
|
4
|
+
|
|
5
|
+
import { useContentPanelCoordinator } from '../../contexts/content-panel-coordinator';
|
|
6
|
+
import useAccessiblePanelPostTypes from '../../hooks/use-accessible-panel-post-types';
|
|
7
|
+
import { useSiteContentStatusFilterCounts } from '../../hooks/use-site-content-status-filter-counts';
|
|
8
|
+
import {
|
|
9
|
+
getSiteContentStatusFilterLabel,
|
|
10
|
+
hasActiveSiteContentStatusFilters,
|
|
11
|
+
shouldShowSiteContentStatusFilterRow,
|
|
12
|
+
SITE_CONTENT_ALL_FILTER_LABEL,
|
|
13
|
+
SITE_CONTENT_SELECTABLE_STATUS_FILTERS,
|
|
14
|
+
} from '../../site-content-status-filter';
|
|
15
|
+
|
|
16
|
+
const renderFilterMenuItemContent = ( label: string, selected: boolean ) => (
|
|
17
|
+
<Stack alignItems="center" direction="row" gap={ 1 } width="100%">
|
|
18
|
+
<Typography sx={ { color: 'text.secondary', flex: 1 } } variant="caption">
|
|
19
|
+
{ label }
|
|
20
|
+
</Typography>
|
|
21
|
+
{ selected ? <CheckIcon aria-hidden fontSize="tiny" /> : null }
|
|
22
|
+
</Stack>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
type Props = {
|
|
26
|
+
loadCounts: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default function ContentPanelStatusFilterList( { loadCounts }: Props ) {
|
|
30
|
+
const { clearStatusFilters, statusFilters, toggleStatusFilter } = useContentPanelCoordinator();
|
|
31
|
+
const { accessiblePostTypes } = useAccessiblePanelPostTypes();
|
|
32
|
+
const { data: statusCounts, isPending: isLoadingCounts } = useSiteContentStatusFilterCounts(
|
|
33
|
+
accessiblePostTypes,
|
|
34
|
+
loadCounts
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const isAllSelected = ! hasActiveSiteContentStatusFilters( statusFilters );
|
|
38
|
+
|
|
39
|
+
const visibleFilters = SITE_CONTENT_SELECTABLE_STATUS_FILTERS.filter( ( filter ) =>
|
|
40
|
+
shouldShowSiteContentStatusFilterRow( statusCounts?.[ filter ], isLoadingCounts, statusFilters[ filter ] )
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<MenuList dense>
|
|
45
|
+
<MenuItem
|
|
46
|
+
aria-checked={ isAllSelected }
|
|
47
|
+
onClick={ clearStatusFilters }
|
|
48
|
+
role="menuitemcheckbox"
|
|
49
|
+
selected={ isAllSelected }
|
|
50
|
+
>
|
|
51
|
+
{ renderFilterMenuItemContent( SITE_CONTENT_ALL_FILTER_LABEL, isAllSelected ) }
|
|
52
|
+
</MenuItem>
|
|
53
|
+
{ visibleFilters.map( ( filter ) => {
|
|
54
|
+
const isSelected = statusFilters[ filter ];
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<MenuItem
|
|
58
|
+
key={ filter }
|
|
59
|
+
aria-checked={ isSelected }
|
|
60
|
+
onClick={ () => toggleStatusFilter( filter ) }
|
|
61
|
+
role="menuitemcheckbox"
|
|
62
|
+
selected={ isSelected }
|
|
63
|
+
>
|
|
64
|
+
{ renderFilterMenuItemContent( getSiteContentStatusFilterLabel( filter ), isSelected ) }
|
|
65
|
+
</MenuItem>
|
|
66
|
+
);
|
|
67
|
+
} ) }
|
|
68
|
+
</MenuList>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PopoverBody, PopoverHeader } from '@elementor/editor-ui';
|
|
3
|
+
import { FilterIcon } from '@elementor/icons';
|
|
4
|
+
import { bindPopover, bindToggle, Divider, Popover, ToggleButton, Tooltip, usePopupState } from '@elementor/ui';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
import { useContentPanelCoordinator } from '../../contexts/content-panel-coordinator';
|
|
8
|
+
import {
|
|
9
|
+
hasActiveSiteContentStatusFilters,
|
|
10
|
+
SITE_CONTENT_FILTER_POPOVER_WIDTH_PX,
|
|
11
|
+
} from '../../site-content-status-filter';
|
|
12
|
+
import ContentPanelClearFiltersButton from './content-panel-clear-filters-button';
|
|
13
|
+
import ContentPanelStatusFilterList from './content-panel-status-filter-list';
|
|
14
|
+
|
|
15
|
+
export default function ContentPanelStatusFilter() {
|
|
16
|
+
const { clearStatusFilters, statusFilters } = useContentPanelCoordinator();
|
|
17
|
+
const popupState = usePopupState( {
|
|
18
|
+
variant: 'popover',
|
|
19
|
+
disableAutoFocus: true,
|
|
20
|
+
} );
|
|
21
|
+
|
|
22
|
+
const hasActiveFilters = hasActiveSiteContentStatusFilters( statusFilters );
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<Tooltip placement="top" title={ __( 'Filters', 'elementor' ) }>
|
|
27
|
+
<ToggleButton
|
|
28
|
+
aria-label={ __( 'Filters', 'elementor' ) }
|
|
29
|
+
selected={ popupState.isOpen || hasActiveFilters }
|
|
30
|
+
size="tiny"
|
|
31
|
+
value="filter"
|
|
32
|
+
{ ...bindToggle( popupState ) }
|
|
33
|
+
>
|
|
34
|
+
<FilterIcon fontSize="tiny" />
|
|
35
|
+
</ToggleButton>
|
|
36
|
+
</Tooltip>
|
|
37
|
+
<Popover
|
|
38
|
+
anchorOrigin={ {
|
|
39
|
+
horizontal: 'right',
|
|
40
|
+
vertical: 'top',
|
|
41
|
+
} }
|
|
42
|
+
sx={ {
|
|
43
|
+
maxWidth: `${ SITE_CONTENT_FILTER_POPOVER_WIDTH_PX }px`,
|
|
44
|
+
} }
|
|
45
|
+
transformOrigin={ {
|
|
46
|
+
horizontal: -21,
|
|
47
|
+
vertical: 'top',
|
|
48
|
+
} }
|
|
49
|
+
{ ...bindPopover( popupState ) }
|
|
50
|
+
>
|
|
51
|
+
<PopoverHeader
|
|
52
|
+
actions={
|
|
53
|
+
hasActiveFilters
|
|
54
|
+
? [
|
|
55
|
+
<ContentPanelClearFiltersButton
|
|
56
|
+
ariaLabel={ __( 'Clear all', 'elementor' ) }
|
|
57
|
+
key="clear-all-filters"
|
|
58
|
+
onClear={ clearStatusFilters }
|
|
59
|
+
tooltipText={ __( 'Clear all', 'elementor' ) }
|
|
60
|
+
/>,
|
|
61
|
+
]
|
|
62
|
+
: []
|
|
63
|
+
}
|
|
64
|
+
icon={ <FilterIcon fontSize="tiny" /> }
|
|
65
|
+
onClose={ popupState.close }
|
|
66
|
+
title={ __( 'Filters', 'elementor' ) }
|
|
67
|
+
/>
|
|
68
|
+
<Divider sx={ { borderWidth: '1px 0 0 0' } } />
|
|
69
|
+
<PopoverBody height="auto" width={ SITE_CONTENT_FILTER_POPOVER_WIDTH_PX }>
|
|
70
|
+
<ContentPanelStatusFilterList loadCounts={ popupState.isOpen } />
|
|
71
|
+
</PopoverBody>
|
|
72
|
+
</Popover>
|
|
73
|
+
</>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Box, Stack } from '@elementor/ui';
|
|
3
|
+
|
|
4
|
+
import ContentPanelActiveFilters from './content-panel-active-filters';
|
|
5
|
+
import { contentPanelSearchBoxSx } from './content-panel-chrome';
|
|
6
|
+
import ContentPanelSearch from './content-panel-search';
|
|
7
|
+
import ContentPanelStatusFilter from './content-panel-status-filter';
|
|
8
|
+
|
|
9
|
+
export default function ContentPanelToolbar() {
|
|
10
|
+
return (
|
|
11
|
+
<Box sx={ contentPanelSearchBoxSx }>
|
|
12
|
+
<Stack gap={ 0.75 } width="100%">
|
|
13
|
+
<Stack alignItems="center" direction="row" gap={ 0.5 } width="100%">
|
|
14
|
+
<Box sx={ { flexGrow: 1, minWidth: 0 } }>
|
|
15
|
+
<ContentPanelSearch />
|
|
16
|
+
</Box>
|
|
17
|
+
<ContentPanelStatusFilter />
|
|
18
|
+
</Stack>
|
|
19
|
+
<ContentPanelActiveFilters />
|
|
20
|
+
</Stack>
|
|
21
|
+
</Box>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
|
|
12
12
|
type Props = {
|
|
13
13
|
count: number;
|
|
14
|
+
countChipLabel?: string;
|
|
14
15
|
headerRef?: Ref< HTMLDivElement >;
|
|
15
16
|
isOpen: boolean;
|
|
16
17
|
onOpenChange: ( isOpen: boolean ) => void;
|
|
@@ -28,12 +29,13 @@ const sectionHeaderListItemButtonSx = {
|
|
|
28
29
|
'&.Mui-focusVisible': { backgroundColor: 'transparent' },
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
function getSectionHeaderAriaLabel( title: string,
|
|
32
|
-
return `${ title } (${
|
|
32
|
+
function getSectionHeaderAriaLabel( title: string, countLabel: string ) {
|
|
33
|
+
return `${ title } (${ countLabel })`;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export default function CollapsibleList( {
|
|
36
37
|
count,
|
|
38
|
+
countChipLabel,
|
|
37
39
|
headerRef,
|
|
38
40
|
isOpen,
|
|
39
41
|
onOpenChange,
|
|
@@ -44,7 +46,8 @@ export default function CollapsibleList( {
|
|
|
44
46
|
const id = useId();
|
|
45
47
|
const labelId = `label-${ id }`;
|
|
46
48
|
const contentId = `content-${ id }`;
|
|
47
|
-
const
|
|
49
|
+
const chipLabel = countChipLabel ?? count.toString();
|
|
50
|
+
const sectionHeaderAriaLabel = getSectionHeaderAriaLabel( title, chipLabel );
|
|
48
51
|
|
|
49
52
|
const handleClick = () => onOpenChange( ! isOpen );
|
|
50
53
|
|
|
@@ -82,7 +85,7 @@ export default function CollapsibleList( {
|
|
|
82
85
|
} }
|
|
83
86
|
sx={ { flexGrow: 0, flexShrink: 1, marginInlineEnd: 1 } }
|
|
84
87
|
/>
|
|
85
|
-
<Chip label={
|
|
88
|
+
<Chip label={ chipLabel } size="tiny" />
|
|
86
89
|
</Stack>
|
|
87
90
|
<CollapseIcon color="secondary" fontSize="tiny" open={ isOpen } sx={ { flexShrink: 0 } } />
|
|
88
91
|
</Stack>
|