@elementor/editor-site-navigation 0.19.0 → 0.19.1
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 +8 -0
- package/dist/index.mjs +16 -16
- package/package.json +5 -5
- package/src/components/panel/actions-menu/actions/delete.tsx +2 -2
- package/src/components/panel/posts-list/__tests__/post-list-item.test.tsx +2 -2
- package/src/components/panel/posts-list/__tests__/posts-collapsible-list.test.tsx +2 -2
- package/src/components/panel/posts-list/list-items/list-item-create.tsx +2 -2
- package/src/components/panel/posts-list/list-items/list-item-duplicate.tsx +2 -2
- package/src/components/panel/posts-list/list-items/list-item-view.tsx +3 -3
- package/src/components/top-bar/__tests__/add-new-page.test.tsx +3 -3
- package/src/components/top-bar/__tests__/recently-edited.test.tsx +13 -13
- package/src/components/top-bar/create-post-list-item.tsx +2 -2
- package/src/components/top-bar/post-list-item.tsx +2 -2
- package/src/components/top-bar/recently-edited.tsx +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.19.1](https://github.com/elementor/elementor-packages/compare/@elementor/editor-site-navigation@0.19.0...@elementor/editor-site-navigation@0.19.1) (2023-09-14)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @elementor/editor-site-navigation
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [0.19.0](https://github.com/elementor/elementor-packages/compare/@elementor/editor-site-navigation@0.18.4...@elementor/editor-site-navigation@0.19.0) (2023-09-11)
|
|
7
15
|
|
|
8
16
|
|
package/dist/index.mjs
CHANGED
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
MenuItem as MenuItem3
|
|
36
36
|
} from "@elementor/ui";
|
|
37
37
|
import { ChevronDownIcon } from "@elementor/icons";
|
|
38
|
-
import { __useActiveDocument, __useHostDocument } from "@elementor/editor-documents";
|
|
38
|
+
import { __useActiveDocument as useActiveDocument, __useHostDocument as useHostDocument } from "@elementor/editor-documents";
|
|
39
39
|
|
|
40
40
|
// src/components/top-bar/indicator.tsx
|
|
41
41
|
import * as React from "react";
|
|
@@ -122,7 +122,7 @@ function DocTypeChip({ postType, docType, label }) {
|
|
|
122
122
|
// src/components/top-bar/post-list-item.tsx
|
|
123
123
|
import { MenuItem, ListItemText } from "@elementor/ui";
|
|
124
124
|
import * as React3 from "react";
|
|
125
|
-
import { __useNavigateToDocument } from "@elementor/editor-documents";
|
|
125
|
+
import { __useNavigateToDocument as useNavigateToDocument } from "@elementor/editor-documents";
|
|
126
126
|
|
|
127
127
|
// src/hooks/use-reverse-html-entities.ts
|
|
128
128
|
import { useMemo } from "react";
|
|
@@ -138,7 +138,7 @@ function useReverseHtmlEntities(escapedHTML = "") {
|
|
|
138
138
|
|
|
139
139
|
// src/components/top-bar/post-list-item.tsx
|
|
140
140
|
function PostListItem({ post, closePopup, ...props }) {
|
|
141
|
-
const navigateToDocument =
|
|
141
|
+
const navigateToDocument = useNavigateToDocument();
|
|
142
142
|
const postTitle = useReverseHtmlEntities(post.title);
|
|
143
143
|
return /* @__PURE__ */ React3.createElement(
|
|
144
144
|
MenuItem,
|
|
@@ -197,10 +197,10 @@ async function addNewPage() {
|
|
|
197
197
|
// src/components/top-bar/create-post-list-item.tsx
|
|
198
198
|
import { PlusIcon } from "@elementor/icons";
|
|
199
199
|
import { __ } from "@wordpress/i18n";
|
|
200
|
-
import { __useNavigateToDocument as
|
|
200
|
+
import { __useNavigateToDocument as useNavigateToDocument2 } from "@elementor/editor-documents";
|
|
201
201
|
function CreatePostListItem({ closePopup, ...props }) {
|
|
202
202
|
const { create, isLoading } = useCreatePage();
|
|
203
|
-
const navigateToDocument =
|
|
203
|
+
const navigateToDocument = useNavigateToDocument2();
|
|
204
204
|
return /* @__PURE__ */ React4.createElement(
|
|
205
205
|
MenuItem2,
|
|
206
206
|
{
|
|
@@ -218,8 +218,8 @@ function CreatePostListItem({ closePopup, ...props }) {
|
|
|
218
218
|
|
|
219
219
|
// src/components/top-bar/recently-edited.tsx
|
|
220
220
|
function RecentlyEdited() {
|
|
221
|
-
const activeDocument =
|
|
222
|
-
const hostDocument =
|
|
221
|
+
const activeDocument = useActiveDocument();
|
|
222
|
+
const hostDocument = useHostDocument();
|
|
223
223
|
const document2 = activeDocument && activeDocument.type.value !== "kit" ? activeDocument : hostDocument;
|
|
224
224
|
const { recentPosts } = useRecentPosts(document2?.id);
|
|
225
225
|
const popupState = usePopupState({
|
|
@@ -578,11 +578,11 @@ function ListItemRename({ post }) {
|
|
|
578
578
|
// src/components/panel/posts-list/list-items/list-item-create.tsx
|
|
579
579
|
import * as React10 from "react";
|
|
580
580
|
import { __ as __5 } from "@wordpress/i18n";
|
|
581
|
-
import { __useNavigateToDocument as
|
|
581
|
+
import { __useNavigateToDocument as useNavigateToDocument3 } from "@elementor/editor-documents";
|
|
582
582
|
function ListItemCreate() {
|
|
583
583
|
const { type, resetEditMode } = usePostListContext();
|
|
584
584
|
const { createPost } = usePostActions(type);
|
|
585
|
-
const navigateToDocument =
|
|
585
|
+
const navigateToDocument = useNavigateToDocument3();
|
|
586
586
|
const createPostCallback = (inputValue) => {
|
|
587
587
|
createPost.mutateAsync({
|
|
588
588
|
title: inputValue,
|
|
@@ -600,10 +600,10 @@ function ListItemCreate() {
|
|
|
600
600
|
// src/components/panel/posts-list/list-items/list-item-duplicate.tsx
|
|
601
601
|
import * as React11 from "react";
|
|
602
602
|
import { __ as __6 } from "@wordpress/i18n";
|
|
603
|
-
import { __useNavigateToDocument as
|
|
603
|
+
import { __useNavigateToDocument as useNavigateToDocument4 } from "@elementor/editor-documents";
|
|
604
604
|
function ListItemDuplicate() {
|
|
605
605
|
const { type, editMode, resetEditMode } = usePostListContext();
|
|
606
|
-
const navigateToDocument =
|
|
606
|
+
const navigateToDocument = useNavigateToDocument4();
|
|
607
607
|
const { duplicatePost } = usePostActions(type);
|
|
608
608
|
if ("duplicate" !== editMode.mode) {
|
|
609
609
|
return null;
|
|
@@ -637,7 +637,7 @@ import {
|
|
|
637
637
|
usePopupState as usePopupState2
|
|
638
638
|
} from "@elementor/ui";
|
|
639
639
|
import { DotsVerticalIcon, HomeIcon as HomeIcon2 } from "@elementor/icons";
|
|
640
|
-
import { __useActiveDocument as
|
|
640
|
+
import { __useActiveDocument as useActiveDocument3, __useNavigateToDocument as useNavigateToDocument5 } from "@elementor/editor-documents";
|
|
641
641
|
|
|
642
642
|
// src/components/shared/page-title-and-status.tsx
|
|
643
643
|
import * as React12 from "react";
|
|
@@ -771,10 +771,10 @@ import {
|
|
|
771
771
|
Divider as Divider3
|
|
772
772
|
} from "@elementor/ui";
|
|
773
773
|
import { useState as useState6 } from "react";
|
|
774
|
-
import { __useActiveDocument as
|
|
774
|
+
import { __useActiveDocument as useActiveDocument2 } from "@elementor/editor-documents";
|
|
775
775
|
function Delete({ post }) {
|
|
776
776
|
const [isDialogOpen, setIsDialogOpen] = useState6(false);
|
|
777
|
-
const activeDocument =
|
|
777
|
+
const activeDocument = useActiveDocument2();
|
|
778
778
|
const isPostActive = activeDocument?.id === post.id;
|
|
779
779
|
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(
|
|
780
780
|
ActionMenuItem,
|
|
@@ -913,8 +913,8 @@ function SetHome({ post }) {
|
|
|
913
913
|
// src/components/panel/posts-list/list-items/list-item-view.tsx
|
|
914
914
|
import { __ as __12 } from "@wordpress/i18n";
|
|
915
915
|
function ListItemView({ post }) {
|
|
916
|
-
const activeDocument =
|
|
917
|
-
const navigateToDocument =
|
|
916
|
+
const activeDocument = useActiveDocument3();
|
|
917
|
+
const navigateToDocument = useNavigateToDocument5();
|
|
918
918
|
const popupState = usePopupState2({
|
|
919
919
|
variant: "popover",
|
|
920
920
|
popupId: "post-actions",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-site-navigation",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@elementor/editor-app-bar": "^0.
|
|
36
|
-
"@elementor/editor-documents": "^0.
|
|
37
|
-
"@elementor/editor-panels": "^0.
|
|
35
|
+
"@elementor/editor-app-bar": "^0.9.0",
|
|
36
|
+
"@elementor/editor-documents": "^0.10.0",
|
|
37
|
+
"@elementor/editor-panels": "^0.4.0",
|
|
38
38
|
"@elementor/env": "^0.3.0",
|
|
39
39
|
"@elementor/icons": "^0.7.0",
|
|
40
40
|
"@elementor/query": "^0.1.1",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"elementor": {
|
|
50
50
|
"type": "extension"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "7fe9af3ba0569f3003d2aa148cb4ad0bdf1c419e"
|
|
53
53
|
}
|
|
@@ -16,11 +16,11 @@ import {
|
|
|
16
16
|
} from '@elementor/ui';
|
|
17
17
|
import { usePostListContext } from '../../../../contexts/post-list-context';
|
|
18
18
|
import { useState } from 'react';
|
|
19
|
-
import { __useActiveDocument } from '@elementor/editor-documents';
|
|
19
|
+
import { __useActiveDocument as useActiveDocument } from '@elementor/editor-documents';
|
|
20
20
|
|
|
21
21
|
export default function Delete( { post }: { post: Post } ) {
|
|
22
22
|
const [ isDialogOpen, setIsDialogOpen ] = useState( false );
|
|
23
|
-
const activeDocument =
|
|
23
|
+
const activeDocument = useActiveDocument();
|
|
24
24
|
|
|
25
25
|
const isPostActive = activeDocument?.id === post.id;
|
|
26
26
|
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { act, fireEvent, screen, waitFor } from '@testing-library/react';
|
|
3
3
|
import { Post } from '../../../../types';
|
|
4
4
|
import PostListItem from '../post-list-item';
|
|
5
|
-
import { __useNavigateToDocument } from '@elementor/editor-documents';
|
|
5
|
+
import { __useNavigateToDocument as useNavigateToDocument } from '@elementor/editor-documents';
|
|
6
6
|
import { renderWithQuery } from 'test-utils';
|
|
7
7
|
import { PostListContextProvider } from '../../../../contexts/post-list-context';
|
|
8
8
|
|
|
@@ -105,7 +105,7 @@ describe( '@elementor/editor-site-navigation - PostListItem', () => {
|
|
|
105
105
|
it( 'should navigate to document on click', () => {
|
|
106
106
|
// Arrange.
|
|
107
107
|
const navigateToDocument = jest.fn();
|
|
108
|
-
jest.mocked(
|
|
108
|
+
jest.mocked( useNavigateToDocument ).mockReturnValue( navigateToDocument );
|
|
109
109
|
|
|
110
110
|
const id = 10;
|
|
111
111
|
|
|
@@ -3,7 +3,7 @@ import { fireEvent, screen, waitFor } from '@testing-library/react';
|
|
|
3
3
|
import PostsCollapsibleList from '../posts-collapsible-list';
|
|
4
4
|
import { createMockDocument, renderWithQuery } from 'test-utils';
|
|
5
5
|
import { PostListContextProvider } from '../../../../contexts/post-list-context';
|
|
6
|
-
import { __useActiveDocument } from '@elementor/editor-documents';
|
|
6
|
+
import { __useActiveDocument as useActiveDocument } from '@elementor/editor-documents';
|
|
7
7
|
|
|
8
8
|
const mockMutateAsync = jest.fn();
|
|
9
9
|
jest.mock( '../../../../hooks/use-posts-actions', () => ( {
|
|
@@ -48,7 +48,7 @@ jest.mock( '@elementor/editor-documents', () => ( {
|
|
|
48
48
|
|
|
49
49
|
describe( '@elementor/editor-site-navigation - PostsCollapsibleList', () => {
|
|
50
50
|
beforeEach( () => {
|
|
51
|
-
jest.mocked(
|
|
51
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument( ( {
|
|
52
52
|
id: 2,
|
|
53
53
|
} ) ) );
|
|
54
54
|
} );
|
|
@@ -3,12 +3,12 @@ import { __ } from '@wordpress/i18n';
|
|
|
3
3
|
import { usePostListContext } from '../../../../contexts/post-list-context';
|
|
4
4
|
import { usePostActions } from '../../../../hooks/use-posts-actions';
|
|
5
5
|
import EditModeTemplate from './edit-mode-template';
|
|
6
|
-
import { __useNavigateToDocument } from '@elementor/editor-documents';
|
|
6
|
+
import { __useNavigateToDocument as useNavigateToDocument } from '@elementor/editor-documents';
|
|
7
7
|
|
|
8
8
|
export default function ListItemCreate() {
|
|
9
9
|
const { type, resetEditMode } = usePostListContext();
|
|
10
10
|
const { createPost } = usePostActions( type );
|
|
11
|
-
const navigateToDocument =
|
|
11
|
+
const navigateToDocument = useNavigateToDocument();
|
|
12
12
|
|
|
13
13
|
const createPostCallback = ( inputValue: string ) => {
|
|
14
14
|
createPost.mutateAsync( {
|
|
@@ -3,11 +3,11 @@ import { __ } from '@wordpress/i18n';
|
|
|
3
3
|
import { usePostListContext } from '../../../../contexts/post-list-context';
|
|
4
4
|
import { usePostActions } from '../../../../hooks/use-posts-actions';
|
|
5
5
|
import EditModeTemplate from './edit-mode-template';
|
|
6
|
-
import { __useNavigateToDocument } from '@elementor/editor-documents';
|
|
6
|
+
import { __useNavigateToDocument as useNavigateToDocument } from '@elementor/editor-documents';
|
|
7
7
|
|
|
8
8
|
export default function ListItemDuplicate() {
|
|
9
9
|
const { type, editMode, resetEditMode } = usePostListContext();
|
|
10
|
-
const navigateToDocument =
|
|
10
|
+
const navigateToDocument = useNavigateToDocument();
|
|
11
11
|
const { duplicatePost } = usePostActions( type );
|
|
12
12
|
|
|
13
13
|
if ( 'duplicate' !== editMode.mode ) {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
usePopupState,
|
|
13
13
|
} from '@elementor/ui';
|
|
14
14
|
import { DotsVerticalIcon, HomeIcon } from '@elementor/icons';
|
|
15
|
-
import { __useActiveDocument, __useNavigateToDocument } from '@elementor/editor-documents';
|
|
15
|
+
import { __useActiveDocument as useActiveDocument, __useNavigateToDocument as useNavigateToDocument } from '@elementor/editor-documents';
|
|
16
16
|
import PageTitleAndStatus from '../../../shared/page-title-and-status';
|
|
17
17
|
import Rename from '../../actions-menu/actions/rename';
|
|
18
18
|
import Duplicate from '../../actions-menu/actions/duplicate';
|
|
@@ -23,8 +23,8 @@ import { Post } from '../../../../types';
|
|
|
23
23
|
import { __ } from '@wordpress/i18n';
|
|
24
24
|
|
|
25
25
|
export default function ListItemView( { post }: { post: Post } ) {
|
|
26
|
-
const activeDocument =
|
|
27
|
-
const navigateToDocument =
|
|
26
|
+
const activeDocument = useActiveDocument();
|
|
27
|
+
const navigateToDocument = useNavigateToDocument();
|
|
28
28
|
|
|
29
29
|
const popupState = usePopupState( {
|
|
30
30
|
variant: 'popover',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import { __useActiveDocument, __useNavigateToDocument } from '@elementor/editor-documents';
|
|
3
|
+
import { __useActiveDocument as useActiveDocument, __useNavigateToDocument as useNavigateToDocument } from '@elementor/editor-documents';
|
|
4
4
|
import RecentlyEdited from '../recently-edited';
|
|
5
5
|
import { createMockDocument } from 'test-utils';
|
|
6
6
|
import useRecentPosts, { Post } from '../../../hooks/use-recent-posts';
|
|
@@ -24,7 +24,7 @@ jest.mock( '../../../hooks/use-create-page', () => ( {
|
|
|
24
24
|
|
|
25
25
|
describe( '@elementor/recently-edited - Top bar add new page', () => {
|
|
26
26
|
beforeEach( () => {
|
|
27
|
-
jest.mocked(
|
|
27
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument() );
|
|
28
28
|
} );
|
|
29
29
|
|
|
30
30
|
it( 'should render add new page button', () => {
|
|
@@ -54,7 +54,7 @@ describe( '@elementor/recently-edited - Top bar add new page', () => {
|
|
|
54
54
|
|
|
55
55
|
jest.mocked( useRecentPosts ).mockReturnValue( { isLoading, recentPosts } );
|
|
56
56
|
jest.mocked( useCreatePage ).mockReturnValue( { isLoading, create } );
|
|
57
|
-
jest.mocked(
|
|
57
|
+
jest.mocked( useNavigateToDocument ).mockReturnValue( navigateToDocument );
|
|
58
58
|
|
|
59
59
|
render( <RecentlyEdited /> );
|
|
60
60
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
-
import { __useHostDocument, __useActiveDocument, __useNavigateToDocument } from '@elementor/editor-documents';
|
|
3
|
+
import { __useHostDocument as useHostDocument, __useActiveDocument as useActiveDocument, __useNavigateToDocument as useNavigateToDocument } from '@elementor/editor-documents';
|
|
4
4
|
import RecentlyEdited from '../recently-edited';
|
|
5
5
|
import { createMockDocument } from 'test-utils';
|
|
6
6
|
import useRecentPosts, { Post } from '../../../hooks/use-recent-posts';
|
|
@@ -21,7 +21,7 @@ jest.mock( '../../../hooks/use-recent-posts', () => (
|
|
|
21
21
|
describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
22
22
|
it( 'should show the title of the active document without its status when the document is published', async () => {
|
|
23
23
|
// Arrange.
|
|
24
|
-
jest.mocked(
|
|
24
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
25
25
|
id: 1,
|
|
26
26
|
title: 'Active Document',
|
|
27
27
|
} ) );
|
|
@@ -36,7 +36,7 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
36
36
|
|
|
37
37
|
it( 'should show the title of the active document with its status when the document is not published', async () => {
|
|
38
38
|
// Arrange.
|
|
39
|
-
jest.mocked(
|
|
39
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
40
40
|
id: 1,
|
|
41
41
|
title: 'Active Document',
|
|
42
42
|
status: {
|
|
@@ -55,9 +55,9 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
55
55
|
|
|
56
56
|
it( 'should show the title of the host document when there is no active document', () => {
|
|
57
57
|
// Arrange.
|
|
58
|
-
jest.mocked(
|
|
58
|
+
jest.mocked( useActiveDocument ).mockReturnValue( null );
|
|
59
59
|
|
|
60
|
-
jest.mocked(
|
|
60
|
+
jest.mocked( useHostDocument ).mockReturnValue( createMockDocument( {
|
|
61
61
|
id: 1,
|
|
62
62
|
title: 'Host Document',
|
|
63
63
|
} ) );
|
|
@@ -71,7 +71,7 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
71
71
|
|
|
72
72
|
it( 'should show the title of the host document when the active document is kit', () => {
|
|
73
73
|
// Arrange.
|
|
74
|
-
jest.mocked(
|
|
74
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
75
75
|
id: 1,
|
|
76
76
|
title: 'Active Document',
|
|
77
77
|
type: {
|
|
@@ -80,7 +80,7 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
80
80
|
},
|
|
81
81
|
} ) );
|
|
82
82
|
|
|
83
|
-
jest.mocked(
|
|
83
|
+
jest.mocked( useHostDocument ).mockReturnValue( createMockDocument( {
|
|
84
84
|
id: 2,
|
|
85
85
|
title: 'Host Document',
|
|
86
86
|
} ) );
|
|
@@ -94,8 +94,8 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
94
94
|
|
|
95
95
|
it( 'should show nothing if there are no documents', () => {
|
|
96
96
|
// Arrange.
|
|
97
|
-
jest.mocked(
|
|
98
|
-
jest.mocked(
|
|
97
|
+
jest.mocked( useActiveDocument ).mockReturnValue( null );
|
|
98
|
+
jest.mocked( useHostDocument ).mockReturnValue( null );
|
|
99
99
|
|
|
100
100
|
// Act.
|
|
101
101
|
render( <RecentlyEdited /> );
|
|
@@ -107,7 +107,7 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
107
107
|
|
|
108
108
|
it( 'should show empty state', () => {
|
|
109
109
|
// Arrange.
|
|
110
|
-
jest.mocked(
|
|
110
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
111
111
|
id: 1,
|
|
112
112
|
title: 'Header',
|
|
113
113
|
type: {
|
|
@@ -134,7 +134,7 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
134
134
|
|
|
135
135
|
it( 'should open the recently edited menu on click', () => {
|
|
136
136
|
// Arrange.
|
|
137
|
-
jest.mocked(
|
|
137
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
138
138
|
id: 1,
|
|
139
139
|
title: 'Header',
|
|
140
140
|
type: {
|
|
@@ -176,7 +176,7 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
176
176
|
|
|
177
177
|
it( 'should render titles with HTML entities', () => {
|
|
178
178
|
// Arrange.
|
|
179
|
-
jest.mocked(
|
|
179
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
180
180
|
id: 1,
|
|
181
181
|
title: 'Header title with special char ¥',
|
|
182
182
|
type: {
|
|
@@ -231,7 +231,7 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
231
231
|
// Arrange.
|
|
232
232
|
const navigateToDocument = jest.fn();
|
|
233
233
|
|
|
234
|
-
jest.mocked(
|
|
234
|
+
jest.mocked( useNavigateToDocument ).mockReturnValue( navigateToDocument );
|
|
235
235
|
|
|
236
236
|
jest.mocked( useRecentPosts ).mockReturnValue( {
|
|
237
237
|
isLoading: false,
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import useCreatePage from '../../hooks/use-create-page';
|
|
4
4
|
import { PlusIcon } from '@elementor/icons';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import { __useNavigateToDocument } from '@elementor/editor-documents';
|
|
6
|
+
import { __useNavigateToDocument as useNavigateToDocument } from '@elementor/editor-documents';
|
|
7
7
|
|
|
8
8
|
type Props = MenuItemProps & {
|
|
9
9
|
closePopup: () => void;
|
|
@@ -11,7 +11,7 @@ type Props = MenuItemProps & {
|
|
|
11
11
|
|
|
12
12
|
export function CreatePostListItem( { closePopup, ...props }: Props ) {
|
|
13
13
|
const { create, isLoading } = useCreatePage();
|
|
14
|
-
const navigateToDocument =
|
|
14
|
+
const navigateToDocument = useNavigateToDocument();
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
<MenuItem
|
|
@@ -2,7 +2,7 @@ import DocTypeChip from './chip-doc-type';
|
|
|
2
2
|
import { MenuItem, MenuItemProps, ListItemText } from '@elementor/ui';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { Post } from '../../hooks/use-recent-posts';
|
|
5
|
-
import { __useNavigateToDocument } from '@elementor/editor-documents';
|
|
5
|
+
import { __useNavigateToDocument as useNavigateToDocument } from '@elementor/editor-documents';
|
|
6
6
|
import { useReverseHtmlEntities } from '../../hooks/use-reverse-html-entities';
|
|
7
7
|
|
|
8
8
|
type Props = MenuItemProps & {
|
|
@@ -11,7 +11,7 @@ type Props = MenuItemProps & {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function PostListItem( { post, closePopup, ...props }: Props ) {
|
|
14
|
-
const navigateToDocument =
|
|
14
|
+
const navigateToDocument = useNavigateToDocument();
|
|
15
15
|
const postTitle = useReverseHtmlEntities( post.title );
|
|
16
16
|
|
|
17
17
|
return (
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
MenuItem,
|
|
12
12
|
} from '@elementor/ui';
|
|
13
13
|
import { ChevronDownIcon } from '@elementor/icons';
|
|
14
|
-
import { __useActiveDocument, __useHostDocument } from '@elementor/editor-documents';
|
|
14
|
+
import { __useActiveDocument as useActiveDocument, __useHostDocument as useHostDocument } from '@elementor/editor-documents';
|
|
15
15
|
import Indicator from './indicator';
|
|
16
16
|
import useRecentPosts from '../../hooks/use-recent-posts';
|
|
17
17
|
import { __ } from '@wordpress/i18n';
|
|
@@ -20,8 +20,8 @@ import { CreatePostListItem } from './create-post-list-item';
|
|
|
20
20
|
import { useReverseHtmlEntities } from '../../hooks/use-reverse-html-entities';
|
|
21
21
|
|
|
22
22
|
export default function RecentlyEdited() {
|
|
23
|
-
const activeDocument =
|
|
24
|
-
const hostDocument =
|
|
23
|
+
const activeDocument = useActiveDocument();
|
|
24
|
+
const hostDocument = useHostDocument();
|
|
25
25
|
const document = activeDocument && activeDocument.type.value !== 'kit'
|
|
26
26
|
? activeDocument
|
|
27
27
|
: hostDocument;
|