@elementor/editor-site-navigation 0.22.5 → 0.22.7
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/CHANGELOG.md +38 -328
- package/dist/index.js +147 -156
- package/dist/index.mjs +168 -175
- package/package.json +49 -49
- package/src/api/post.ts +18 -18
- package/src/api/recent-posts.ts +1 -1
- package/src/api/settings.ts +4 -4
- package/src/api/user.ts +4 -4
- package/src/components/panel/actions-menu/action-menu-item.tsx +7 -10
- package/src/components/panel/actions-menu/actions/__tests__/set-home.test.tsx +12 -9
- package/src/components/panel/actions-menu/actions/delete.tsx +27 -25
- package/src/components/panel/actions-menu/actions/duplicate.tsx +5 -7
- package/src/components/panel/actions-menu/actions/rename.tsx +11 -13
- package/src/components/panel/actions-menu/actions/set-home.tsx +6 -8
- package/src/components/panel/actions-menu/actions/view.tsx +3 -5
- package/src/components/panel/error-snackbar.tsx +4 -3
- package/src/components/panel/panel.ts +1 -5
- package/src/components/panel/posts-list/__tests__/posts-collapsible-list.test.tsx +66 -19
- package/src/components/panel/posts-list/collapsible-list.tsx +38 -29
- package/src/components/panel/posts-list/error-state.tsx +35 -27
- package/src/components/panel/posts-list/list-items/edit-mode-template.tsx +18 -40
- package/src/components/panel/posts-list/list-items/list-item-create.tsx +5 -1
- package/src/components/panel/posts-list/list-items/list-item-duplicate.tsx +5 -1
- package/src/components/panel/posts-list/list-items/list-item-rename.tsx +3 -5
- package/src/components/panel/posts-list/list-items/list-item-view.tsx +20 -19
- package/src/components/panel/posts-list/posts-collapsible-list.tsx +22 -24
- package/src/components/shared/page-title-and-status.tsx +4 -2
- package/src/components/top-bar/__tests__/add-new-page.test.tsx +33 -16
- package/src/components/top-bar/__tests__/recently-edited.test.tsx +157 -120
- package/src/components/top-bar/chip-doc-type.tsx +1 -3
- package/src/components/top-bar/create-post-list-item.tsx +1 -1
- package/src/components/top-bar/indicator.tsx +17 -15
- package/src/components/top-bar/post-list-item.tsx +2 -6
- package/src/components/top-bar/recently-edited.tsx +13 -19
- package/src/contexts/post-list-context.tsx +40 -34
- package/src/env.ts +2 -2
- package/src/hooks/__tests__/use-posts.test.ts +19 -3
- package/src/hooks/use-create-page.ts +2 -2
- package/src/hooks/use-homepage.ts +1 -1
- package/src/hooks/use-posts.ts +1 -1
- package/src/hooks/use-toggle-button-props.ts +1 -5
- package/src/hooks/use-user.ts +1 -1
- package/src/icons-map.ts +1 -1
- package/src/types.ts +22 -22
|
@@ -11,7 +11,14 @@ jest.mock( '@wordpress/api-fetch', () => ( {
|
|
|
11
11
|
const pages = [
|
|
12
12
|
{ id: 1, type: 'page', title: { rendered: 'Home' }, status: 'draft', link: 'www.test.demo' },
|
|
13
13
|
{ id: 2, type: 'page', title: { rendered: 'About' }, status: 'publish', link: 'www.test.demo' },
|
|
14
|
-
{
|
|
14
|
+
{
|
|
15
|
+
id: 3,
|
|
16
|
+
type: 'page',
|
|
17
|
+
title: { rendered: 'Services' },
|
|
18
|
+
status: 'publish',
|
|
19
|
+
link: 'www.test.demo',
|
|
20
|
+
isHome: true,
|
|
21
|
+
},
|
|
15
22
|
];
|
|
16
23
|
|
|
17
24
|
const url = new URL( 'http:/example.com' + param.path );
|
|
@@ -51,14 +58,23 @@ describe( '@elementor/site-settings/use-posts', () => {
|
|
|
51
58
|
const pages = [
|
|
52
59
|
{ id: 1, type: 'page', title: { rendered: 'Home' }, status: 'draft', link: 'www.test.demo' },
|
|
53
60
|
{ id: 2, type: 'page', title: { rendered: 'About' }, status: 'publish', link: 'www.test.demo' },
|
|
54
|
-
{
|
|
61
|
+
{
|
|
62
|
+
id: 3,
|
|
63
|
+
type: 'page',
|
|
64
|
+
title: { rendered: 'Services' },
|
|
65
|
+
status: 'publish',
|
|
66
|
+
link: 'www.test.demo',
|
|
67
|
+
isHome: true,
|
|
68
|
+
},
|
|
55
69
|
];
|
|
56
70
|
|
|
57
71
|
// Act.
|
|
58
72
|
const { component } = renderHookWithQuery( () => usePosts( 'page' ) );
|
|
59
73
|
|
|
60
74
|
// Assert.
|
|
61
|
-
const expectedPath = `/wp/v2/pages?status=any&order=asc&page=1&per_page=${ POST_PER_PAGE }&_fields=${ encodeURIComponent(
|
|
75
|
+
const expectedPath = `/wp/v2/pages?status=any&order=asc&page=1&per_page=${ POST_PER_PAGE }&_fields=${ encodeURIComponent(
|
|
76
|
+
'id,type,title,link,status,user_can'
|
|
77
|
+
) }`;
|
|
62
78
|
|
|
63
79
|
expect( apiFetch ).toHaveBeenCalledWith( {
|
|
64
80
|
parse: false,
|
|
@@ -3,7 +3,7 @@ import { getSettings } from '../api/settings';
|
|
|
3
3
|
|
|
4
4
|
export const settingsQueryKey = () => [ 'site-navigation', 'homepage' ];
|
|
5
5
|
|
|
6
|
-
export function useHomepage(
|
|
6
|
+
export function useHomepage() {
|
|
7
7
|
return useQuery( {
|
|
8
8
|
queryKey: settingsQueryKey(),
|
|
9
9
|
queryFn: () => getSettings(),
|
package/src/hooks/use-posts.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Post } from '../types';
|
|
|
4
4
|
|
|
5
5
|
export const postsQueryKey = ( postTypeSlug: string ) => [ 'site-navigation', 'posts', postTypeSlug ];
|
|
6
6
|
|
|
7
|
-
const flattenData = ( data?: {pages: PostsResponse[]} ) => {
|
|
7
|
+
const flattenData = ( data?: { pages: PostsResponse[] } ) => {
|
|
8
8
|
if ( ! data ) {
|
|
9
9
|
return data;
|
|
10
10
|
}
|
|
@@ -9,11 +9,7 @@ export function useToggleButtonProps() {
|
|
|
9
9
|
return {
|
|
10
10
|
title: __( 'Pages', 'elementor' ),
|
|
11
11
|
icon: PagesIcon,
|
|
12
|
-
onClick: () => (
|
|
13
|
-
isOpen
|
|
14
|
-
? close()
|
|
15
|
-
: open()
|
|
16
|
-
),
|
|
12
|
+
onClick: () => ( isOpen ? close() : open() ),
|
|
17
13
|
selected: isOpen,
|
|
18
14
|
disabled: isBlocked,
|
|
19
15
|
};
|
package/src/hooks/use-user.ts
CHANGED
package/src/icons-map.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -14,33 +14,33 @@ export type Post = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export type RecentPost = {
|
|
17
|
-
id: number
|
|
18
|
-
title: string
|
|
19
|
-
edit_url: string
|
|
17
|
+
id: number;
|
|
18
|
+
title: string;
|
|
19
|
+
edit_url: string;
|
|
20
20
|
type: {
|
|
21
|
-
post_type: string
|
|
22
|
-
doc_type: string
|
|
23
|
-
label: string
|
|
24
|
-
}
|
|
25
|
-
date_modified: number
|
|
21
|
+
post_type: string;
|
|
22
|
+
doc_type: string;
|
|
23
|
+
label: string;
|
|
24
|
+
};
|
|
25
|
+
date_modified: number;
|
|
26
26
|
user_can: {
|
|
27
|
-
edit: boolean
|
|
28
|
-
}
|
|
29
|
-
}
|
|
27
|
+
edit: boolean;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
30
|
|
|
31
31
|
export type ExtendedWindow = Window & {
|
|
32
32
|
elementor: {
|
|
33
33
|
editorEvents: {
|
|
34
|
-
dispatchEvent: ( name: string, data: Record<string, string> ) => void
|
|
34
|
+
dispatchEvent: ( name: string, data: Record< string, string > ) => void;
|
|
35
35
|
config: {
|
|
36
|
-
locations: Record<string, string
|
|
37
|
-
secondaryLocations: Record<string, string
|
|
38
|
-
triggers: Record<string, string
|
|
39
|
-
elements: Record<string, string
|
|
36
|
+
locations: Record< string, string >;
|
|
37
|
+
secondaryLocations: Record< string, string >;
|
|
38
|
+
triggers: Record< string, string >;
|
|
39
|
+
elements: Record< string, string >;
|
|
40
40
|
names: {
|
|
41
|
-
topBar: Record<string, string
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
41
|
+
topBar: Record< string, string >;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|