@elementor/editor-app-bar 0.7.3 → 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 +27 -0
- package/dist/index.js +146 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +133 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/components/__tests__/top-bar.test.tsx +2 -0
- package/src/components/app-bar.tsx +1 -1
- package/src/components/ui/popover-menu-item.tsx +5 -0
- package/src/components/ui/popover-menu.tsx +1 -1
- package/src/components/ui/toolbar-logo.tsx +10 -6
- package/src/components/ui/toolbar-menu-item.tsx +27 -2
- package/src/components/ui/toolbar-menu-toggle-item.tsx +15 -1
- package/src/components/ui/toolbar-menu.tsx +1 -1
- package/src/extensions/documents-indicator/components/__tests__/settings-button.test.tsx +13 -7
- package/src/extensions/documents-indicator/components/settings-button.tsx +23 -4
- package/src/extensions/documents-preview/hooks/__tests__/use-document-preview-props.test.ts +4 -4
- package/src/extensions/documents-preview/hooks/use-action-props.ts +2 -2
- package/src/extensions/documents-save/components/__tests__/primary-action-menu.test.tsx +1 -3
- package/src/extensions/documents-save/components/__tests__/primary-action.test.tsx +6 -7
- package/src/extensions/documents-save/components/primary-action-menu.tsx +2 -2
- package/src/extensions/documents-save/components/primary-action.tsx +9 -8
- package/src/extensions/documents-save/hooks/__tests__/use-document-save-draft-props.test.ts +3 -3
- 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 +1 -1
- package/src/extensions/documents-save/hooks/use-document-save-template-props.ts +1 -1
- 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 -4
- package/src/extensions/finder/hooks/use-action-props.ts +2 -3
- package/src/extensions/finder/index.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 +12 -8
- package/src/extensions/site-settings/components/__tests__/primary-action.test.tsx +10 -10
- package/src/extensions/site-settings/components/portal.tsx +1 -1
- package/src/extensions/site-settings/components/primary-action.tsx +1 -1
- 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 +1 -1
- package/src/sync/__tests__/redirect-old-menus.test.ts +2 -2
- package/src/sync/redirect-old-menus.ts +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Box, ToggleButton, Tooltip } from '@elementor/ui';
|
|
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
9
|
const activeDocument = useActiveDocument();
|
|
@@ -34,10 +34,29 @@ export default function SettingsButton() {
|
|
|
34
34
|
onChange={ () => openRoute( 'panel/page-settings/settings' ) }
|
|
35
35
|
aria-label={ title }
|
|
36
36
|
size="small"
|
|
37
|
+
sx={ {
|
|
38
|
+
border: 0, // Temp fix until the style of the ToggleButton component will be decided.
|
|
39
|
+
'&.Mui-disabled': {
|
|
40
|
+
border: 0, // Temp fix until the style of the ToggleButton component will be decided.
|
|
41
|
+
},
|
|
42
|
+
} }
|
|
37
43
|
>
|
|
38
|
-
<SettingsIcon />
|
|
44
|
+
<SettingsIcon fontSize="small" />
|
|
39
45
|
</ToggleButton>
|
|
40
46
|
</Box>
|
|
41
47
|
</Tooltip>
|
|
42
48
|
);
|
|
43
49
|
}
|
|
50
|
+
|
|
51
|
+
function Tooltip( props: TooltipProps ) {
|
|
52
|
+
return <BaseTooltip
|
|
53
|
+
PopperProps={ {
|
|
54
|
+
sx: {
|
|
55
|
+
'&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom': {
|
|
56
|
+
mt: 1.7,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
} }
|
|
60
|
+
{ ...props }
|
|
61
|
+
/>;
|
|
62
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
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', () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
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
7
|
const document = useActiveDocument();
|
|
@@ -3,9 +3,7 @@ import { render, screen } from '@testing-library/react';
|
|
|
3
3
|
import PrimaryActionMenu from '../primary-action-menu';
|
|
4
4
|
import { documentOptionsMenu } from '../../../../locations';
|
|
5
5
|
|
|
6
|
-
jest.mock( '@elementor/editor-documents'
|
|
7
|
-
useActiveDocument: jest.fn(),
|
|
8
|
-
} ) );
|
|
6
|
+
jest.mock( '@elementor/editor-documents' );
|
|
9
7
|
|
|
10
8
|
describe( '@elementor/editor-app-bar - Primary action menu', () => {
|
|
11
9
|
it( 'should render the actions ordered properly (save, default)', () => {
|
|
@@ -2,16 +2,16 @@ 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
|
-
|
|
10
|
-
|
|
9
|
+
__useActiveDocument: jest.fn(),
|
|
10
|
+
__useActiveDocumentActions: jest.fn(),
|
|
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 = {
|
|
@@ -20,10 +20,9 @@ const actionsMock = {
|
|
|
20
20
|
saveTemplate: jest.fn(),
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
jest.mocked( useActiveDocumentActions ).mockReturnValue( actionsMock );
|
|
24
|
-
|
|
25
23
|
describe( '@elementor/editor-app-bar - Top Bar Primary Action', () => {
|
|
26
24
|
beforeEach( () => {
|
|
25
|
+
jest.mocked( useActiveDocumentActions ).mockReturnValue( actionsMock );
|
|
27
26
|
jest.mocked( useIsPreviewMode ).mockReturnValue( false );
|
|
28
27
|
} );
|
|
29
28
|
|
|
@@ -31,9 +31,9 @@ export default function PrimaryActionMenu( props: PopoverMenuProps ) {
|
|
|
31
31
|
vertical: 'top',
|
|
32
32
|
horizontal: 'right',
|
|
33
33
|
} }
|
|
34
|
-
marginThreshold={
|
|
34
|
+
marginThreshold={ 4 }
|
|
35
35
|
PaperProps={ {
|
|
36
|
-
sx: { mt:
|
|
36
|
+
sx: { mt: 0.5 },
|
|
37
37
|
} }
|
|
38
38
|
>
|
|
39
39
|
{ saveActions.map( ( { MenuItem, id }, index ) => ( [
|
|
@@ -11,9 +11,9 @@ 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
19
|
const document = useActiveDocument();
|
|
@@ -38,12 +38,12 @@ export default function PrimaryAction() {
|
|
|
38
38
|
|
|
39
39
|
return (
|
|
40
40
|
<>
|
|
41
|
-
<ButtonGroup size="
|
|
41
|
+
<ButtonGroup size="large" variant="contained">
|
|
42
42
|
<Button
|
|
43
43
|
onClick={ () => ! document.isSaving && save() }
|
|
44
44
|
sx={ {
|
|
45
|
-
px: 7,
|
|
46
45
|
height: '100%',
|
|
46
|
+
borderRadius: 0,
|
|
47
47
|
maxWidth: '158px',
|
|
48
48
|
'&.MuiButtonBase-root.MuiButtonGroup-grouped': {
|
|
49
49
|
minWidth: '110px',
|
|
@@ -51,7 +51,7 @@ export default function PrimaryAction() {
|
|
|
51
51
|
} }
|
|
52
52
|
disabled={ isPublishDisabled }
|
|
53
53
|
>
|
|
54
|
-
{ shouldShowSpinner ? <CircularProgress /> : getLabel( document ) }
|
|
54
|
+
{ shouldShowSpinner ? <CircularProgress color="inherit" size="1.5em" /> : getLabel( document ) }
|
|
55
55
|
</Button>
|
|
56
56
|
|
|
57
57
|
<Tooltip
|
|
@@ -59,16 +59,17 @@ export default function PrimaryAction() {
|
|
|
59
59
|
PopperProps={ {
|
|
60
60
|
sx: {
|
|
61
61
|
'&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom': {
|
|
62
|
-
mt:
|
|
63
|
-
mr:
|
|
62
|
+
mt: 1,
|
|
63
|
+
mr: 0.25,
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
66
|
} }
|
|
67
67
|
>
|
|
68
68
|
<Box component="span" aria-label={ undefined }>
|
|
69
69
|
<Button
|
|
70
|
+
size="small"
|
|
70
71
|
{ ...bindTrigger( popupState ) }
|
|
71
|
-
sx={ { px: 0, height: '100%' } }
|
|
72
|
+
sx={ { px: 0, height: '100%', borderRadius: 0 } }
|
|
72
73
|
disabled={ isSaveOptionsDisabled }
|
|
73
74
|
aria-label={ __( 'Save Options', 'elementor' ) }
|
|
74
75
|
>
|
|
@@ -1,11 +1,11 @@
|
|
|
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
|
-
|
|
8
|
-
|
|
7
|
+
__useActiveDocument: jest.fn(),
|
|
8
|
+
__useActiveDocumentActions: jest.fn(),
|
|
9
9
|
} ) );
|
|
10
10
|
|
|
11
11
|
const documentActions = {
|
package/src/extensions/documents-save/hooks/__tests__/use-document-save-template-props.test.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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', () => ( {
|
|
6
|
-
|
|
6
|
+
__useActiveDocumentActions: jest.fn(),
|
|
7
7
|
} ) );
|
|
8
8
|
|
|
9
9
|
const documentActions = {
|
|
@@ -1,7 +1,7 @@
|
|
|
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
7
|
const document = useActiveDocument();
|
|
@@ -1,7 +1,7 @@
|
|
|
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
7
|
const { saveTemplate } = useActiveDocumentActions();
|
|
@@ -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', () => {
|
|
@@ -25,7 +25,6 @@ describe( '@elementor/editor-app-bar - useFinderActionProps', () => {
|
|
|
25
25
|
const { result } = renderHook( () => useActionProps() );
|
|
26
26
|
|
|
27
27
|
// Assert.
|
|
28
|
-
expect( result.current.selected ).toBe( true );
|
|
29
28
|
expect( result.current.disabled ).toBe( true );
|
|
30
29
|
expect( useRouteStatus ).toHaveBeenCalledTimes( 1 );
|
|
31
30
|
expect( useRouteStatus ).toHaveBeenCalledWith( 'finder', {
|
|
@@ -1,9 +1,9 @@
|
|
|
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
|
-
const {
|
|
6
|
+
const { isBlocked } = useRouteStatus( 'finder', {
|
|
7
7
|
blockOnKitRoutes: false,
|
|
8
8
|
blockOnPreviewMode: false,
|
|
9
9
|
} );
|
|
@@ -12,7 +12,6 @@ export default function useActionProps() {
|
|
|
12
12
|
title: __( 'Finder', 'elementor' ),
|
|
13
13
|
icon: SearchIcon,
|
|
14
14
|
onClick: () => runCommand( 'finder/toggle' ),
|
|
15
|
-
selected: isActive,
|
|
16
15
|
disabled: isBlocked,
|
|
17
16
|
};
|
|
18
17
|
}
|
|
@@ -2,7 +2,7 @@ import { utilitiesMenu } from '../../locations';
|
|
|
2
2
|
import useActionProps from './hooks/use-action-props';
|
|
3
3
|
|
|
4
4
|
export function init() {
|
|
5
|
-
utilitiesMenu.
|
|
5
|
+
utilitiesMenu.registerAction( {
|
|
6
6
|
id: 'toggle-finder',
|
|
7
7
|
priority: 10, // Before help.
|
|
8
8
|
useProps: useActionProps,
|
|
@@ -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,25 +1,29 @@
|
|
|
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 } 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', () => ( {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
save: jest.fn(),
|
|
17
|
-
} ) ),
|
|
14
|
+
__useActiveDocument: jest.fn(),
|
|
15
|
+
__useActiveDocumentActions: jest.fn(),
|
|
18
16
|
} ) );
|
|
19
17
|
|
|
20
18
|
describe( '@elementor/editor-app-bar - Portalled primary action', () => {
|
|
21
19
|
beforeEach( () => {
|
|
22
|
-
jest.mocked( useActiveDocument ).
|
|
20
|
+
jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument() );
|
|
21
|
+
|
|
22
|
+
jest.mocked( useActiveDocumentActions ).mockReturnValue( {
|
|
23
|
+
save: jest.fn(),
|
|
24
|
+
saveDraft: jest.fn(),
|
|
25
|
+
saveTemplate: jest.fn(),
|
|
26
|
+
} );
|
|
23
27
|
} );
|
|
24
28
|
|
|
25
29
|
afterEach( () => {
|
|
@@ -2,11 +2,11 @@ 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
|
-
|
|
9
|
-
|
|
8
|
+
__useActiveDocument: jest.fn(),
|
|
9
|
+
__useActiveDocumentActions: jest.fn(),
|
|
10
10
|
} ) );
|
|
11
11
|
|
|
12
12
|
describe( '@elementor/editor-app-bar - Primary action', () => {
|
|
@@ -15,17 +15,17 @@ describe( '@elementor/editor-app-bar - Primary action', () => {
|
|
|
15
15
|
beforeEach( () => {
|
|
16
16
|
saveFn = jest.fn( () => Promise.resolve() );
|
|
17
17
|
|
|
18
|
-
jest.mocked( useActiveDocument ).
|
|
19
|
-
jest.mocked( useActiveDocumentActions ).
|
|
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(),
|
|
23
|
-
} )
|
|
23
|
+
} );
|
|
24
24
|
} );
|
|
25
25
|
|
|
26
26
|
it( 'should save site settings on click', () => {
|
|
27
27
|
// Arrange.
|
|
28
|
-
jest.mocked( useActiveDocument ).
|
|
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( useActiveDocument ).
|
|
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( useActiveDocument ).
|
|
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( useActiveDocument ).
|
|
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,5 +1,5 @@
|
|
|
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
|
|
|
@@ -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 {
|
|
@@ -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 - useUserPreferencesActionProps', () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
import { ToggleActionProps } from '../../../types';
|
|
3
3
|
import { ToggleRightIcon } from '@elementor/icons';
|
|
4
|
-
import { openRoute, useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
4
|
+
import { __privateOpenRoute as openRoute, __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
5
5
|
|
|
6
6
|
export default function useActionProps(): ToggleActionProps {
|
|
7
7
|
const { isActive, isBlocked } = useRouteStatus( 'panel/editor-preferences' );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mainMenu } from '../../locations';
|
|
2
2
|
import { __ } from '@wordpress/i18n';
|
|
3
3
|
import { WordpressIcon } from '@elementor/icons';
|
|
4
|
-
import { useActiveDocument } from '@elementor/editor-documents';
|
|
4
|
+
import { __useActiveDocument as useActiveDocument } from '@elementor/editor-documents';
|
|
5
5
|
|
|
6
6
|
export function init() {
|
|
7
7
|
mainMenu.registerLink( {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { openRoute } from '@elementor/editor-v1-adapters';
|
|
1
|
+
import { __privateOpenRoute as openRoute } from '@elementor/editor-v1-adapters';
|
|
2
2
|
import redirectOldMenus from '../redirect-old-menus';
|
|
3
3
|
|
|
4
4
|
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
5
5
|
...jest.requireActual( '@elementor/editor-v1-adapters' ),
|
|
6
|
-
|
|
6
|
+
__privateOpenRoute: jest.fn(),
|
|
7
7
|
} ) );
|
|
8
8
|
|
|
9
9
|
describe( '@elementor/editor-app-bar - Redirect old menus', () => {
|