@elementor/editor-app-bar 0.8.0 → 0.9.0
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 +11 -0
- package/dist/index.js +25 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/extensions/documents-indicator/components/__tests__/settings-button.test.tsx +5 -5
- package/src/extensions/documents-indicator/components/settings-button.tsx +4 -4
- package/src/extensions/documents-preview/hooks/__tests__/use-document-preview-props.test.ts +5 -5
- package/src/extensions/documents-preview/hooks/use-action-props.ts +3 -3
- package/src/extensions/documents-save/components/__tests__/primary-action.test.tsx +14 -14
- package/src/extensions/documents-save/components/primary-action.tsx +4 -4
- package/src/extensions/documents-save/hooks/__tests__/use-document-save-draft-props.test.ts +4 -4
- package/src/extensions/documents-save/hooks/__tests__/use-document-save-template-props.test.ts +2 -2
- package/src/extensions/documents-save/hooks/use-document-save-draft-props.ts +3 -3
- package/src/extensions/documents-save/hooks/use-document-save-template-props.ts +2 -2
- package/src/extensions/elements/hooks/__tests__/use-action-props.test.ts +3 -3
- package/src/extensions/elements/hooks/use-action-props.ts +1 -1
- package/src/extensions/elements/sync/__tests__/sync-panel-title.test.ts +2 -2
- package/src/extensions/elements/sync/sync-panel-title.ts +1 -1
- package/src/extensions/finder/hooks/__tests__/use-action-props.test.ts +3 -3
- package/src/extensions/finder/hooks/use-action-props.ts +1 -1
- package/src/extensions/history/hooks/__tests__/use-action-props.test.ts +3 -3
- package/src/extensions/history/hooks/use-action-props.ts +1 -1
- package/src/extensions/keyboard-shortcuts/hooks/__tests__/use-action-props.test.ts +2 -2
- package/src/extensions/keyboard-shortcuts/hooks/use-action-props.ts +1 -1
- package/src/extensions/site-settings/components/__tests__/portalled-primary-action.test.tsx +5 -5
- package/src/extensions/site-settings/components/__tests__/primary-action.test.tsx +7 -7
- package/src/extensions/site-settings/components/portal.tsx +1 -1
- package/src/extensions/site-settings/components/primary-action.tsx +3 -3
- package/src/extensions/site-settings/hooks/__tests__/use-action-props.test.ts +3 -3
- package/src/extensions/site-settings/hooks/use-action-props.ts +1 -1
- package/src/extensions/structure/hooks/__tests__/use-action-props.test.ts +3 -3
- package/src/extensions/structure/hooks/use-action-props.ts +1 -1
- package/src/extensions/theme-builder/hooks/__tests__/use-action-props.test.ts +2 -2
- package/src/extensions/theme-builder/hooks/use-action-props.ts +1 -1
- package/src/extensions/user-preferences/hooks/__tests__/use-action-props.test.ts +3 -3
- package/src/extensions/user-preferences/hooks/use-action-props.ts +1 -1
- package/src/extensions/wordpress/index.ts +2 -2
- package/src/sync/__tests__/redirect-old-menus.test.ts +2 -2
- package/src/sync/redirect-old-menus.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-app-bar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
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": "^0.
|
|
36
|
-
"@elementor/editor-documents": "^0.
|
|
37
|
-
"@elementor/editor-v1-adapters": "^0.
|
|
35
|
+
"@elementor/editor": "^0.10.0",
|
|
36
|
+
"@elementor/editor-documents": "^0.10.0",
|
|
37
|
+
"@elementor/editor-v1-adapters": "^0.6.0",
|
|
38
38
|
"@elementor/icons": "^0.7.0",
|
|
39
39
|
"@elementor/locations": "^0.7.0",
|
|
40
40
|
"@elementor/ui": "^1.4.53",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"elementor": {
|
|
47
47
|
"type": "extension"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "7fe9af3ba0569f3003d2aa148cb4ad0bdf1c419e"
|
|
50
50
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import SettingsButton from '../settings-button';
|
|
3
|
-
import { openRoute, useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateOpenRoute as openRoute, __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
4
4
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
5
|
-
import { __useActiveDocument } from '@elementor/editor-documents';
|
|
5
|
+
import { __useActiveDocument as useActiveDocument } from '@elementor/editor-documents';
|
|
6
6
|
import { createMockDocument } from 'test-utils';
|
|
7
7
|
|
|
8
8
|
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
__privateOpenRoute: jest.fn(),
|
|
10
|
+
__privateUseRouteStatus: jest.fn( () => ( { isActive: false, isBlocked: false } ) ),
|
|
11
11
|
} ) );
|
|
12
12
|
|
|
13
13
|
jest.mock( '@elementor/editor-documents', () => ( {
|
|
@@ -17,7 +17,7 @@ jest.mock( '@elementor/editor-documents', () => ( {
|
|
|
17
17
|
|
|
18
18
|
describe( '@elementor/editor-app-bar - App bar document settings button', () => {
|
|
19
19
|
beforeEach( () => {
|
|
20
|
-
jest.mocked(
|
|
20
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
21
21
|
type: { value: 'wp-page', label: 'Page' },
|
|
22
22
|
} ) );
|
|
23
23
|
} );
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Box, ToggleButton, Tooltip as BaseTooltip, TooltipProps } from '@elementor/ui';
|
|
3
3
|
import { __ } from '@wordpress/i18n';
|
|
4
|
-
import { openRoute, useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
4
|
+
import { __privateOpenRoute as openRoute, __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
5
5
|
import { SettingsIcon } from '@elementor/icons';
|
|
6
|
-
import { __useActiveDocument, __useHostDocument } from '@elementor/editor-documents';
|
|
6
|
+
import { __useActiveDocument as useActiveDocument, __useHostDocument as useHostDocument } from '@elementor/editor-documents';
|
|
7
7
|
|
|
8
8
|
export default function SettingsButton() {
|
|
9
|
-
const activeDocument =
|
|
10
|
-
const hostDocument =
|
|
9
|
+
const activeDocument = useActiveDocument();
|
|
10
|
+
const hostDocument = useHostDocument();
|
|
11
11
|
|
|
12
12
|
const document = activeDocument && activeDocument.type.value !== 'kit'
|
|
13
13
|
? activeDocument
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { renderHook } from '@testing-library/react';
|
|
2
2
|
import useActionProps from '../use-action-props';
|
|
3
|
-
import { runCommand } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
|
|
4
4
|
import { createMockDocument } from 'test-utils';
|
|
5
|
-
import { __useActiveDocument } from '@elementor/editor-documents';
|
|
5
|
+
import { __useActiveDocument as useActiveDocument } from '@elementor/editor-documents';
|
|
6
6
|
|
|
7
7
|
jest.mock( '@elementor/editor-documents', () => ( {
|
|
8
8
|
__useActiveDocument: jest.fn(),
|
|
9
9
|
} ) );
|
|
10
10
|
|
|
11
11
|
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
12
|
-
|
|
12
|
+
__privateRunCommand: jest.fn(),
|
|
13
13
|
} ) );
|
|
14
14
|
|
|
15
15
|
describe( '@elementor/editor-app-bar - useDocumentPreviewProps', () => {
|
|
16
16
|
it( 'should open the document preview', () => {
|
|
17
17
|
// Arrange.
|
|
18
|
-
jest.mocked(
|
|
18
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument() );
|
|
19
19
|
|
|
20
20
|
const command = 'editor/documents/preview';
|
|
21
21
|
const args = { id: 1, force: true };
|
|
@@ -31,7 +31,7 @@ describe( '@elementor/editor-app-bar - useDocumentPreviewProps', () => {
|
|
|
31
31
|
|
|
32
32
|
it( 'should not run the command when there is no document', () => {
|
|
33
33
|
// Arrange.
|
|
34
|
-
jest.mocked(
|
|
34
|
+
jest.mocked( useActiveDocument ).mockReturnValue( null );
|
|
35
35
|
|
|
36
36
|
// Act.
|
|
37
37
|
const { result } = renderHook( () => useActionProps() );
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
import { EyeIcon } from '@elementor/icons';
|
|
3
|
-
import { runCommand } from '@elementor/editor-v1-adapters';
|
|
4
|
-
import { __useActiveDocument } from '@elementor/editor-documents';
|
|
3
|
+
import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
|
|
4
|
+
import { __useActiveDocument as useActiveDocument } from '@elementor/editor-documents';
|
|
5
5
|
|
|
6
6
|
export default function useActionProps() {
|
|
7
|
-
const document =
|
|
7
|
+
const document = useActiveDocument();
|
|
8
8
|
|
|
9
9
|
return {
|
|
10
10
|
icon: EyeIcon,
|
|
@@ -2,8 +2,8 @@ import * as React from 'react';
|
|
|
2
2
|
import PrimaryAction from '../primary-action';
|
|
3
3
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
4
|
import { createMockDocument } from 'test-utils';
|
|
5
|
-
import { __useActiveDocument, __useActiveDocumentActions } from '@elementor/editor-documents';
|
|
6
|
-
import { useIsPreviewMode } from '@elementor/editor-v1-adapters';
|
|
5
|
+
import { __useActiveDocument as useActiveDocument, __useActiveDocumentActions as useActiveDocumentActions } from '@elementor/editor-documents';
|
|
6
|
+
import { __privateUseIsPreviewMode as useIsPreviewMode } from '@elementor/editor-v1-adapters';
|
|
7
7
|
|
|
8
8
|
jest.mock( '@elementor/editor-documents', () => ( {
|
|
9
9
|
__useActiveDocument: jest.fn(),
|
|
@@ -11,7 +11,7 @@ jest.mock( '@elementor/editor-documents', () => ( {
|
|
|
11
11
|
} ) );
|
|
12
12
|
|
|
13
13
|
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
14
|
-
|
|
14
|
+
__privateUseIsPreviewMode: jest.fn(),
|
|
15
15
|
} ) );
|
|
16
16
|
|
|
17
17
|
const actionsMock = {
|
|
@@ -22,7 +22,7 @@ const actionsMock = {
|
|
|
22
22
|
|
|
23
23
|
describe( '@elementor/editor-app-bar - Top Bar Primary Action', () => {
|
|
24
24
|
beforeEach( () => {
|
|
25
|
-
jest.mocked(
|
|
25
|
+
jest.mocked( useActiveDocumentActions ).mockReturnValue( actionsMock );
|
|
26
26
|
jest.mocked( useIsPreviewMode ).mockReturnValue( false );
|
|
27
27
|
} );
|
|
28
28
|
|
|
@@ -32,7 +32,7 @@ describe( '@elementor/editor-app-bar - Top Bar Primary Action', () => {
|
|
|
32
32
|
|
|
33
33
|
it( 'should not render when there is no active document', () => {
|
|
34
34
|
// Arrange.
|
|
35
|
-
jest.mocked(
|
|
35
|
+
jest.mocked( useActiveDocument ).mockReturnValue( null );
|
|
36
36
|
|
|
37
37
|
// Act.
|
|
38
38
|
const { container } = render( <PrimaryAction /> );
|
|
@@ -49,7 +49,7 @@ describe( '@elementor/editor-app-bar - Top Bar Primary Action', () => {
|
|
|
49
49
|
},
|
|
50
50
|
} );
|
|
51
51
|
|
|
52
|
-
jest.mocked(
|
|
52
|
+
jest.mocked( useActiveDocument ).mockReturnValue( mockDocument );
|
|
53
53
|
|
|
54
54
|
// Act.
|
|
55
55
|
render( <PrimaryAction /> );
|
|
@@ -66,7 +66,7 @@ describe( '@elementor/editor-app-bar - Top Bar Primary Action', () => {
|
|
|
66
66
|
},
|
|
67
67
|
} );
|
|
68
68
|
|
|
69
|
-
jest.mocked(
|
|
69
|
+
jest.mocked( useActiveDocument ).mockReturnValue( mockDocument );
|
|
70
70
|
|
|
71
71
|
// Act.
|
|
72
72
|
render( <PrimaryAction /> );
|
|
@@ -85,7 +85,7 @@ describe( '@elementor/editor-app-bar - Top Bar Primary Action', () => {
|
|
|
85
85
|
},
|
|
86
86
|
} );
|
|
87
87
|
|
|
88
|
-
jest.mocked(
|
|
88
|
+
jest.mocked( useActiveDocument ).mockReturnValue( mockDocument );
|
|
89
89
|
|
|
90
90
|
// Act.
|
|
91
91
|
render( <PrimaryAction /> );
|
|
@@ -102,7 +102,7 @@ describe( '@elementor/editor-app-bar - Top Bar Primary Action', () => {
|
|
|
102
102
|
// Arrange.
|
|
103
103
|
const mockDocument = createMockDocument();
|
|
104
104
|
|
|
105
|
-
jest.mocked(
|
|
105
|
+
jest.mocked( useActiveDocument ).mockReturnValue( mockDocument );
|
|
106
106
|
jest.mocked( useIsPreviewMode ).mockReturnValue( true );
|
|
107
107
|
|
|
108
108
|
// Act.
|
|
@@ -120,7 +120,7 @@ describe( '@elementor/editor-app-bar - Top Bar Primary Action', () => {
|
|
|
120
120
|
// Arrange.
|
|
121
121
|
const mockDocument = createMockDocument( { isDirty: false } );
|
|
122
122
|
|
|
123
|
-
jest.mocked(
|
|
123
|
+
jest.mocked( useActiveDocument ).mockReturnValue( mockDocument );
|
|
124
124
|
|
|
125
125
|
// Act.
|
|
126
126
|
render( <PrimaryAction /> );
|
|
@@ -143,7 +143,7 @@ describe( '@elementor/editor-app-bar - Top Bar Primary Action', () => {
|
|
|
143
143
|
},
|
|
144
144
|
} );
|
|
145
145
|
|
|
146
|
-
jest.mocked(
|
|
146
|
+
jest.mocked( useActiveDocument ).mockReturnValue( mockDocument );
|
|
147
147
|
|
|
148
148
|
// Act.
|
|
149
149
|
render( <PrimaryAction /> );
|
|
@@ -160,7 +160,7 @@ describe( '@elementor/editor-app-bar - Top Bar Primary Action', () => {
|
|
|
160
160
|
// Arrange.
|
|
161
161
|
const mockDocument = createMockDocument( { isDirty: true } );
|
|
162
162
|
|
|
163
|
-
jest.mocked(
|
|
163
|
+
jest.mocked( useActiveDocument ).mockReturnValue( mockDocument );
|
|
164
164
|
|
|
165
165
|
// Act.
|
|
166
166
|
render( <PrimaryAction /> );
|
|
@@ -178,7 +178,7 @@ describe( '@elementor/editor-app-bar - Top Bar Primary Action', () => {
|
|
|
178
178
|
isSaving: true,
|
|
179
179
|
} );
|
|
180
180
|
|
|
181
|
-
jest.mocked(
|
|
181
|
+
jest.mocked( useActiveDocument ).mockReturnValue( mockDocument );
|
|
182
182
|
|
|
183
183
|
// Act.
|
|
184
184
|
render( <PrimaryAction /> );
|
|
@@ -204,7 +204,7 @@ describe( '@elementor/editor-app-bar - Top Bar Primary Action', () => {
|
|
|
204
204
|
isSaving: true,
|
|
205
205
|
} );
|
|
206
206
|
|
|
207
|
-
jest.mocked(
|
|
207
|
+
jest.mocked( useActiveDocument ).mockReturnValue( mockDocument );
|
|
208
208
|
|
|
209
209
|
// Act.
|
|
210
210
|
render( <PrimaryAction /> );
|
|
@@ -11,13 +11,13 @@ import {
|
|
|
11
11
|
Tooltip,
|
|
12
12
|
usePopupState,
|
|
13
13
|
} from '@elementor/ui';
|
|
14
|
-
import { Document, __useActiveDocument, __useActiveDocumentActions } from '@elementor/editor-documents';
|
|
14
|
+
import { Document, __useActiveDocument as useActiveDocument, __useActiveDocumentActions as useActiveDocumentActions } from '@elementor/editor-documents';
|
|
15
15
|
import { ChevronDownIcon } from '@elementor/icons';
|
|
16
|
-
import { useIsPreviewMode } from '@elementor/editor-v1-adapters';
|
|
16
|
+
import { __privateUseIsPreviewMode as useIsPreviewMode } from '@elementor/editor-v1-adapters';
|
|
17
17
|
|
|
18
18
|
export default function PrimaryAction() {
|
|
19
|
-
const document =
|
|
20
|
-
const { save } =
|
|
19
|
+
const document = useActiveDocument();
|
|
20
|
+
const { save } = useActiveDocumentActions();
|
|
21
21
|
const isPreviewMode = useIsPreviewMode();
|
|
22
22
|
|
|
23
23
|
const popupState = usePopupState( {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createMockDocument } from 'test-utils';
|
|
2
2
|
import { renderHook } from '@testing-library/react';
|
|
3
3
|
import useDocumentSaveDraftProps from '../use-document-save-draft-props';
|
|
4
|
-
import { __useActiveDocument, __useActiveDocumentActions } from '@elementor/editor-documents';
|
|
4
|
+
import { __useActiveDocument as useActiveDocument, __useActiveDocumentActions as useActiveDocumentActions } from '@elementor/editor-documents';
|
|
5
5
|
|
|
6
6
|
jest.mock( '@elementor/editor-documents', () => ( {
|
|
7
7
|
__useActiveDocument: jest.fn(),
|
|
@@ -17,8 +17,8 @@ const documentActions = {
|
|
|
17
17
|
describe( '@elementor/editor-app-bar - useDocumentSaveDraftProps', () => {
|
|
18
18
|
it( 'should save a draft of the current document', () => {
|
|
19
19
|
// Arrange.
|
|
20
|
-
jest.mocked(
|
|
21
|
-
jest.mocked(
|
|
20
|
+
jest.mocked( useActiveDocumentActions ).mockReturnValue( documentActions );
|
|
21
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument() );
|
|
22
22
|
|
|
23
23
|
// Act.
|
|
24
24
|
const { result } = renderHook( () => useDocumentSaveDraftProps() );
|
|
@@ -53,7 +53,7 @@ describe( '@elementor/editor-app-bar - useDocumentSaveDraftProps', () => {
|
|
|
53
53
|
},
|
|
54
54
|
] )( 'should be disabled when $condition', ( { document } ) => {
|
|
55
55
|
// Arrange.
|
|
56
|
-
jest.mocked(
|
|
56
|
+
jest.mocked( useActiveDocument ).mockReturnValue( document );
|
|
57
57
|
|
|
58
58
|
// Act.
|
|
59
59
|
const { result } = renderHook( () => useDocumentSaveDraftProps() );
|
package/src/extensions/documents-save/hooks/__tests__/use-document-save-template-props.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { renderHook } from '@testing-library/react';
|
|
2
|
-
import { __useActiveDocumentActions } from '@elementor/editor-documents';
|
|
2
|
+
import { __useActiveDocumentActions as useActiveDocumentActions } from '@elementor/editor-documents';
|
|
3
3
|
import useDocumentSaveTemplateProps from '../use-document-save-template-props';
|
|
4
4
|
|
|
5
5
|
jest.mock( '@elementor/editor-documents', () => ( {
|
|
@@ -15,7 +15,7 @@ const documentActions = {
|
|
|
15
15
|
describe( '@elementor/editor-app-bar - useDocumentSaveTemplateProps', () => {
|
|
16
16
|
it( 'should open the "save as template" modal', () => {
|
|
17
17
|
// Arrange.
|
|
18
|
-
jest.mocked(
|
|
18
|
+
jest.mocked( useActiveDocumentActions ).mockReturnValue( documentActions );
|
|
19
19
|
|
|
20
20
|
// Act.
|
|
21
21
|
const { result } = renderHook( () => useDocumentSaveTemplateProps() );
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
import { ActionProps } from '../../../types';
|
|
3
3
|
import { FileReportIcon } from '@elementor/icons';
|
|
4
|
-
import { __useActiveDocument, __useActiveDocumentActions } from '@elementor/editor-documents';
|
|
4
|
+
import { __useActiveDocument as useActiveDocument, __useActiveDocumentActions as useActiveDocumentActions } from '@elementor/editor-documents';
|
|
5
5
|
|
|
6
6
|
export default function useDocumentSaveDraftProps(): ActionProps {
|
|
7
|
-
const document =
|
|
8
|
-
const { saveDraft } =
|
|
7
|
+
const document = useActiveDocument();
|
|
8
|
+
const { saveDraft } = useActiveDocumentActions();
|
|
9
9
|
|
|
10
10
|
return {
|
|
11
11
|
icon: FileReportIcon,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
import { ActionProps } from '../../../types';
|
|
3
3
|
import { FolderIcon } from '@elementor/icons';
|
|
4
|
-
import { __useActiveDocumentActions } from '@elementor/editor-documents';
|
|
4
|
+
import { __useActiveDocumentActions as useActiveDocumentActions } from '@elementor/editor-documents';
|
|
5
5
|
|
|
6
6
|
export default function useDocumentSaveTemplateProps(): ActionProps {
|
|
7
|
-
const { saveTemplate } =
|
|
7
|
+
const { saveTemplate } = useActiveDocumentActions();
|
|
8
8
|
|
|
9
9
|
return {
|
|
10
10
|
icon: FolderIcon,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import useActionProps from '../use-action-props';
|
|
2
2
|
import { renderHook } from '@testing-library/react';
|
|
3
|
-
import { openRoute, useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateOpenRoute as openRoute, __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
5
5
|
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
__privateOpenRoute: jest.fn(),
|
|
7
|
+
__privateUseRouteStatus: jest.fn( () => ( { isActive: true, isBlocked: true } ) ),
|
|
8
8
|
} ) );
|
|
9
9
|
|
|
10
10
|
describe( '@elementor/editor-app-bar - useElementsPanelActionProps', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PlusIcon } from '@elementor/icons';
|
|
2
2
|
import { __ } from '@wordpress/i18n';
|
|
3
|
-
import { openRoute, useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateOpenRoute as openRoute, __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
5
5
|
export default function useActionProps() {
|
|
6
6
|
const { isActive, isBlocked } = useRouteStatus( 'panel/elements' );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import syncPanelTitle from '../sync-panel-title';
|
|
2
|
-
import { isRouteActive } from '@elementor/editor-v1-adapters';
|
|
2
|
+
import { __privateIsRouteActive as isRouteActive } from '@elementor/editor-v1-adapters';
|
|
3
3
|
|
|
4
4
|
type ExtendedWindow = Window & {
|
|
5
5
|
elementor?: {
|
|
@@ -13,7 +13,7 @@ type ExtendedWindow = Window & {
|
|
|
13
13
|
|
|
14
14
|
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
15
15
|
...jest.requireActual( '@elementor/editor-v1-adapters' ),
|
|
16
|
-
|
|
16
|
+
__privateIsRouteActive: jest.fn().mockReturnValue( false ),
|
|
17
17
|
} ) );
|
|
18
18
|
|
|
19
19
|
const mockIsRouteActive = jest.mocked( isRouteActive );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
|
-
import { isRouteActive, listenTo, routeOpenEvent, v1ReadyEvent } from '@elementor/editor-v1-adapters';
|
|
2
|
+
import { __privateIsRouteActive as isRouteActive, __privateListenTo as listenTo, routeOpenEvent, v1ReadyEvent } from '@elementor/editor-v1-adapters';
|
|
3
3
|
|
|
4
4
|
type ExtendedWindow = Window & {
|
|
5
5
|
elementor: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import useActionProps from '../use-action-props';
|
|
2
2
|
import { renderHook } from '@testing-library/react';
|
|
3
|
-
import { runCommand, useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateRunCommand as runCommand, __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
5
5
|
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
__privateRunCommand: jest.fn(),
|
|
7
|
+
__privateUseRouteStatus: jest.fn( () => ( { isActive: true, isBlocked: true } ) ),
|
|
8
8
|
} ) );
|
|
9
9
|
|
|
10
10
|
describe( '@elementor/editor-app-bar - useFinderActionProps', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
import { SearchIcon } from '@elementor/icons';
|
|
3
|
-
import { runCommand, useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateRunCommand as runCommand, __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
5
5
|
export default function useActionProps() {
|
|
6
6
|
const { isBlocked } = useRouteStatus( 'finder', {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import useActionProps from '../use-action-props';
|
|
2
2
|
import { renderHook } from '@testing-library/react';
|
|
3
|
-
import { openRoute, useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateOpenRoute as openRoute, __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
5
5
|
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
__privateOpenRoute: jest.fn(),
|
|
7
|
+
__privateUseRouteStatus: jest.fn( () => ( { isActive: true, isBlocked: true } ) ),
|
|
8
8
|
} ) );
|
|
9
9
|
|
|
10
10
|
describe( '@elementor/editor-app-bar - useHistoryActionProps', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HistoryIcon } from '@elementor/icons';
|
|
2
2
|
import { __ } from '@wordpress/i18n';
|
|
3
|
-
import { openRoute, useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateOpenRoute as openRoute, __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
5
5
|
export default function useActionProps() {
|
|
6
6
|
const { isActive, isBlocked } = useRouteStatus( 'panel/history' );
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { renderHook } from '@testing-library/react';
|
|
2
2
|
import useActionProps from '../use-action-props';
|
|
3
|
-
import { runCommand } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
5
5
|
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
6
|
-
|
|
6
|
+
__privateRunCommand: jest.fn(),
|
|
7
7
|
} ) );
|
|
8
8
|
|
|
9
9
|
describe( '@elementor/editor-app-bar - useKeyboardShortcutsActionProps', () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
import { ActionProps } from '../../../types';
|
|
3
3
|
import { KeyboardIcon } from '@elementor/icons';
|
|
4
|
-
import { runCommand } from '@elementor/editor-v1-adapters';
|
|
4
|
+
import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
|
|
5
5
|
|
|
6
6
|
export default function useActionProps(): ActionProps {
|
|
7
7
|
return {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { act, render, screen } from '@testing-library/react';
|
|
3
|
-
import { isRouteActive } from '@elementor/editor-v1-adapters';
|
|
4
|
-
import { __useActiveDocument, __useActiveDocumentActions } from '@elementor/editor-documents';
|
|
3
|
+
import { __privateIsRouteActive as isRouteActive } from '@elementor/editor-v1-adapters';
|
|
4
|
+
import { __useActiveDocument as useActiveDocument, __useActiveDocumentActions as useActiveDocumentActions } from '@elementor/editor-documents';
|
|
5
5
|
import PortalledPrimaryAction from '../portalled-primary-action';
|
|
6
6
|
import { createMockDocument } from 'test-utils';
|
|
7
7
|
|
|
8
8
|
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
9
9
|
...jest.requireActual( '@elementor/editor-v1-adapters' ),
|
|
10
|
-
|
|
10
|
+
__privateIsRouteActive: jest.fn(),
|
|
11
11
|
} ) );
|
|
12
12
|
|
|
13
13
|
jest.mock( '@elementor/editor-documents', () => ( {
|
|
@@ -17,9 +17,9 @@ jest.mock( '@elementor/editor-documents', () => ( {
|
|
|
17
17
|
|
|
18
18
|
describe( '@elementor/editor-app-bar - Portalled primary action', () => {
|
|
19
19
|
beforeEach( () => {
|
|
20
|
-
jest.mocked(
|
|
20
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument() );
|
|
21
21
|
|
|
22
|
-
jest.mocked(
|
|
22
|
+
jest.mocked( useActiveDocumentActions ).mockReturnValue( {
|
|
23
23
|
save: jest.fn(),
|
|
24
24
|
saveDraft: jest.fn(),
|
|
25
25
|
saveTemplate: jest.fn(),
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
3
|
import PrimaryAction from '../primary-action';
|
|
4
4
|
import { createMockDocument } from 'test-utils';
|
|
5
|
-
import { __useActiveDocument, __useActiveDocumentActions } from '@elementor/editor-documents';
|
|
5
|
+
import { __useActiveDocument as useActiveDocument, __useActiveDocumentActions as useActiveDocumentActions } from '@elementor/editor-documents';
|
|
6
6
|
|
|
7
7
|
jest.mock( '@elementor/editor-documents', () => ( {
|
|
8
8
|
__useActiveDocument: jest.fn(),
|
|
@@ -15,8 +15,8 @@ describe( '@elementor/editor-app-bar - Primary action', () => {
|
|
|
15
15
|
beforeEach( () => {
|
|
16
16
|
saveFn = jest.fn( () => Promise.resolve() );
|
|
17
17
|
|
|
18
|
-
jest.mocked(
|
|
19
|
-
jest.mocked(
|
|
18
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument() );
|
|
19
|
+
jest.mocked( useActiveDocumentActions ).mockReturnValue( {
|
|
20
20
|
save: saveFn,
|
|
21
21
|
saveTemplate: jest.fn(),
|
|
22
22
|
saveDraft: jest.fn(),
|
|
@@ -25,7 +25,7 @@ describe( '@elementor/editor-app-bar - Primary action', () => {
|
|
|
25
25
|
|
|
26
26
|
it( 'should save site settings on click', () => {
|
|
27
27
|
// Arrange.
|
|
28
|
-
jest.mocked(
|
|
28
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument( { isDirty: true } ) );
|
|
29
29
|
|
|
30
30
|
render( <PrimaryAction /> );
|
|
31
31
|
|
|
@@ -51,7 +51,7 @@ describe( '@elementor/editor-app-bar - Primary action', () => {
|
|
|
51
51
|
},
|
|
52
52
|
] )( 'should not save site settings when $title', ( { document } ) => {
|
|
53
53
|
// Arrange.
|
|
54
|
-
jest.mocked(
|
|
54
|
+
jest.mocked( useActiveDocument ).mockReturnValue( document );
|
|
55
55
|
|
|
56
56
|
render( <PrimaryAction /> );
|
|
57
57
|
|
|
@@ -73,7 +73,7 @@ describe( '@elementor/editor-app-bar - Primary action', () => {
|
|
|
73
73
|
},
|
|
74
74
|
] )( 'should be disabled when $title', ( { document } ) => {
|
|
75
75
|
// Arrange.
|
|
76
|
-
jest.mocked(
|
|
76
|
+
jest.mocked( useActiveDocument ).mockReturnValue( document );
|
|
77
77
|
|
|
78
78
|
// Act.
|
|
79
79
|
render( <PrimaryAction /> );
|
|
@@ -84,7 +84,7 @@ describe( '@elementor/editor-app-bar - Primary action', () => {
|
|
|
84
84
|
|
|
85
85
|
it( 'should show a loader when saving site settings', () => {
|
|
86
86
|
// Arrange.
|
|
87
|
-
jest.mocked(
|
|
87
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
88
88
|
isDirty: true,
|
|
89
89
|
isSaving: true,
|
|
90
90
|
} ) );
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Portal as BasePortal, PortalProps } from '@elementor/ui';
|
|
3
|
-
import { isRouteActive, routeCloseEvent, routeOpenEvent, useListenTo } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateIsRouteActive as isRouteActive, routeCloseEvent, routeOpenEvent, __privateUseListenTo as useListenTo } from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
5
5
|
export default function Portal( props: Omit<PortalProps, 'container'> ) {
|
|
6
6
|
const containerRef = useListenTo(
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { __useActiveDocument, __useActiveDocumentActions } from '@elementor/editor-documents';
|
|
2
|
+
import { __useActiveDocument as useActiveDocument, __useActiveDocumentActions as useActiveDocumentActions } from '@elementor/editor-documents';
|
|
3
3
|
import { Button, CircularProgress, Paper } from '@elementor/ui';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
|
|
6
6
|
export default function PrimaryAction() {
|
|
7
|
-
const document =
|
|
8
|
-
const { save } =
|
|
7
|
+
const document = useActiveDocument();
|
|
8
|
+
const { save } = useActiveDocumentActions();
|
|
9
9
|
|
|
10
10
|
return (
|
|
11
11
|
<Paper sx={ {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import useActionProps from '../use-action-props';
|
|
2
2
|
import { renderHook } from '@testing-library/react';
|
|
3
|
-
import { runCommand, useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateRunCommand as runCommand, __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
5
5
|
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
__privateRunCommand: jest.fn(),
|
|
7
|
+
__privateUseRouteStatus: jest.fn(),
|
|
8
8
|
} ) );
|
|
9
9
|
|
|
10
10
|
describe( '@elementor/editor-app-bar - site-settings - useActionProps', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
|
-
import { runCommand, useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
2
|
+
import { __privateRunCommand as runCommand, __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
3
3
|
import { ToggleActionProps } from '../../../types';
|
|
4
4
|
import { AdjustmentsHorizontalIcon } from '@elementor/icons';
|
|
5
5
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import useActionProps from '../use-action-props';
|
|
2
2
|
import { renderHook } from '@testing-library/react';
|
|
3
|
-
import { runCommand, useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateRunCommand as runCommand, __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
5
5
|
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
__privateRunCommand: jest.fn(),
|
|
7
|
+
__privateUseRouteStatus: jest.fn( () => ( { isActive: true, isBlocked: true } ) ),
|
|
8
8
|
} ) );
|
|
9
9
|
|
|
10
10
|
describe( '@elementor/editor-app-bar - useStructureActionProps', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
|
-
import { runCommand, useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
2
|
+
import { __privateRunCommand as runCommand, __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
3
3
|
import { StructureIcon } from '@elementor/icons';
|
|
4
4
|
import { ToggleActionProps } from '../../../types';
|
|
5
5
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { renderHook } from '@testing-library/react';
|
|
2
2
|
import useThemeBuilderActionProps from '../use-action-props';
|
|
3
|
-
import { runCommand } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
5
5
|
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
6
|
-
|
|
6
|
+
__privateRunCommand: jest.fn(),
|
|
7
7
|
} ) );
|
|
8
8
|
|
|
9
9
|
describe( '@elementor/editor-app-bar - useThemeBuilderActionProps', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
import { ThemeBuilderIcon } from '@elementor/icons';
|
|
3
|
-
import { runCommand } from '@elementor/editor-v1-adapters';
|
|
3
|
+
import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
|
|
4
4
|
import { ActionProps } from '../../../types';
|
|
5
5
|
|
|
6
6
|
export default function useActionProps(): ActionProps {
|