@wordpress/editor 12.3.1 → 12.5.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 +4 -0
- package/build/components/entities-saved-states/entity-type-list.js +2 -2
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/local-autosave-monitor/index.js +1 -1
- package/build/components/local-autosave-monitor/index.js.map +1 -1
- package/build/components/post-excerpt/index.js +1 -1
- package/build/components/post-excerpt/index.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +15 -2
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/store/actions.js +27 -26
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +17 -24
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +3 -8
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +0 -30
- package/build/store/reducer.js.map +1 -1
- package/build/store/reducer.native.js +0 -1
- package/build/store/reducer.native.js.map +1 -1
- package/build/store/selectors.js +4 -11
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils/notice-builder.js +5 -4
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js +2 -2
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/local-autosave-monitor/index.js +1 -1
- package/build-module/components/local-autosave-monitor/index.js.map +1 -1
- package/build-module/components/post-excerpt/index.js +1 -1
- package/build-module/components/post-excerpt/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +15 -2
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/store/actions.js +21 -22
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +15 -21
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js +3 -8
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +1 -29
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/reducer.native.js +1 -2
- package/build-module/store/reducer.native.js.map +1 -1
- package/build-module/store/selectors.js +2 -10
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils/notice-builder.js +5 -4
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/package.json +27 -26
- package/src/components/entities-saved-states/entity-type-list.js +6 -3
- package/src/components/local-autosave-monitor/README.md +8 -1
- package/src/components/local-autosave-monitor/index.js +1 -1
- package/src/components/post-excerpt/index.js +3 -1
- package/src/components/provider/use-block-editor-settings.js +22 -3
- package/src/store/actions.js +13 -16
- package/src/store/defaults.js +15 -21
- package/src/store/index.js +2 -8
- package/src/store/reducer.js +1 -28
- package/src/store/reducer.native.js +0 -2
- package/src/store/selectors.js +8 -9
- package/src/store/test/actions.js +61 -1
- package/src/store/test/reducer.js +0 -31
- package/src/store/test/selectors.js +0 -35
- package/src/store/utils/notice-builder.js +4 -3
- package/src/store/utils/test/notice-builder.js +1 -1
|
@@ -61,6 +61,22 @@ function useBlockEditorSettings( settings, hasTemplate ) {
|
|
|
61
61
|
};
|
|
62
62
|
}, [] );
|
|
63
63
|
|
|
64
|
+
const {
|
|
65
|
+
__experimentalBlockPatterns: settingsBlockPatterns,
|
|
66
|
+
__experimentalBlockPatternCategories: settingsBlockPatternCategories,
|
|
67
|
+
} = settings;
|
|
68
|
+
|
|
69
|
+
const { blockPatterns, blockPatternCategories } = useSelect(
|
|
70
|
+
( select ) => ( {
|
|
71
|
+
blockPatterns:
|
|
72
|
+
settingsBlockPatterns ?? select( coreStore ).getBlockPatterns(),
|
|
73
|
+
blockPatternCategories:
|
|
74
|
+
settingsBlockPatternCategories ??
|
|
75
|
+
select( coreStore ).getBlockPatternCategories(),
|
|
76
|
+
} ),
|
|
77
|
+
[ settingsBlockPatterns, settingsBlockPatternCategories ]
|
|
78
|
+
);
|
|
79
|
+
|
|
64
80
|
const { undo } = useDispatch( editorStore );
|
|
65
81
|
|
|
66
82
|
const { saveEntityRecord } = useDispatch( coreStore );
|
|
@@ -85,17 +101,15 @@ function useBlockEditorSettings( settings, hasTemplate ) {
|
|
|
85
101
|
() => ( {
|
|
86
102
|
...pick( settings, [
|
|
87
103
|
'__experimentalBlockDirectory',
|
|
88
|
-
'__experimentalBlockPatternCategories',
|
|
89
|
-
'__experimentalBlockPatterns',
|
|
90
104
|
'__experimentalDiscussionSettings',
|
|
91
105
|
'__experimentalFeatures',
|
|
92
106
|
'__experimentalPreferredStyleVariations',
|
|
93
107
|
'__experimentalSetIsInserterOpened',
|
|
94
|
-
'__experimentalGenerateAnchors',
|
|
95
108
|
'__unstableGalleryWithImageBlocks',
|
|
96
109
|
'alignWide',
|
|
97
110
|
'allowedBlockTypes',
|
|
98
111
|
'bodyPlaceholder',
|
|
112
|
+
'canLockBlocks',
|
|
99
113
|
'codeEditingEnabled',
|
|
100
114
|
'colors',
|
|
101
115
|
'disableCustomColors',
|
|
@@ -107,6 +121,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
|
|
|
107
121
|
'focusMode',
|
|
108
122
|
'fontSizes',
|
|
109
123
|
'gradients',
|
|
124
|
+
'generateAnchors',
|
|
110
125
|
'hasFixedToolbar',
|
|
111
126
|
'hasReducedUI',
|
|
112
127
|
'imageDefaultSize',
|
|
@@ -127,6 +142,8 @@ function useBlockEditorSettings( settings, hasTemplate ) {
|
|
|
127
142
|
] ),
|
|
128
143
|
mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
|
|
129
144
|
__experimentalReusableBlocks: reusableBlocks,
|
|
145
|
+
__experimentalBlockPatterns: blockPatterns,
|
|
146
|
+
__experimentalBlockPatternCategories: blockPatternCategories,
|
|
130
147
|
__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>
|
|
131
148
|
fetchLinkSuggestions( search, searchOptions, settings ),
|
|
132
149
|
__experimentalFetchRichUrlData: fetchUrlData,
|
|
@@ -142,6 +159,8 @@ function useBlockEditorSettings( settings, hasTemplate ) {
|
|
|
142
159
|
settings,
|
|
143
160
|
hasUploadPermissions,
|
|
144
161
|
reusableBlocks,
|
|
162
|
+
blockPatterns,
|
|
163
|
+
blockPatternCategories,
|
|
145
164
|
canUseUnfilteredHTML,
|
|
146
165
|
undo,
|
|
147
166
|
hasTemplate,
|
package/src/store/actions.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import { store as noticesStore } from '@wordpress/notices';
|
|
17
17
|
import { store as coreStore } from '@wordpress/core-data';
|
|
18
18
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
19
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Internal dependencies
|
|
@@ -320,26 +321,22 @@ export function updatePostLock( lock ) {
|
|
|
320
321
|
}
|
|
321
322
|
|
|
322
323
|
/**
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
* @return {Object} Action object
|
|
324
|
+
* Enable the publish sidebar.
|
|
326
325
|
*/
|
|
327
|
-
export
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
326
|
+
export const enablePublishSidebar = () => ( { registry } ) => {
|
|
327
|
+
registry
|
|
328
|
+
.dispatch( preferencesStore )
|
|
329
|
+
.set( 'core/edit-post', 'isPublishSidebarEnabled', true );
|
|
330
|
+
};
|
|
332
331
|
|
|
333
332
|
/**
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
* @return {Object} Action object
|
|
333
|
+
* Disables the publish sidebar.
|
|
337
334
|
*/
|
|
338
|
-
export
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
335
|
+
export const disablePublishSidebar = () => ( { registry } ) => {
|
|
336
|
+
registry
|
|
337
|
+
.dispatch( preferencesStore )
|
|
338
|
+
.set( 'core/edit-post', 'isPublishSidebarEnabled', false );
|
|
339
|
+
};
|
|
343
340
|
|
|
344
341
|
/**
|
|
345
342
|
* Action that locks post saving.
|
package/src/store/defaults.js
CHANGED
|
@@ -3,29 +3,23 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { SETTINGS_DEFAULTS } from '@wordpress/block-editor';
|
|
5
5
|
|
|
6
|
-
export const PREFERENCES_DEFAULTS = {
|
|
7
|
-
insertUsage: {}, // Should be kept for backward compatibility, see: https://github.com/WordPress/gutenberg/issues/14580.
|
|
8
|
-
isPublishSidebarEnabled: true,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
6
|
/**
|
|
12
|
-
* The default post editor settings
|
|
7
|
+
* The default post editor settings.
|
|
13
8
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* supportsLayout boolean Whether the editor supports layouts.
|
|
9
|
+
* @property {boolean|Array} allowedBlockTypes Allowed block types
|
|
10
|
+
* @property {boolean} richEditingEnabled Whether rich editing is enabled or not
|
|
11
|
+
* @property {boolean} codeEditingEnabled Whether code editing is enabled or not
|
|
12
|
+
* @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
|
|
13
|
+
* true = the user has opted to show the Custom Fields panel at the bottom of the editor.
|
|
14
|
+
* false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
|
|
15
|
+
* undefined = the current environment does not support Custom Fields, so the option toggle in Preferences -> Panels to enable the Custom Fields panel is not displayed.
|
|
16
|
+
* @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.
|
|
17
|
+
* @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.
|
|
18
|
+
* @property {Array?} availableTemplates The available post templates
|
|
19
|
+
* @property {boolean} disablePostFormats Whether or not the post formats are disabled
|
|
20
|
+
* @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
|
|
21
|
+
* @property {number} maxUploadFileSize Maximum upload file size
|
|
22
|
+
* @property {boolean} supportsLayout Whether the editor supports layouts.
|
|
29
23
|
*/
|
|
30
24
|
export const EDITOR_SETTINGS_DEFAULTS = {
|
|
31
25
|
...SETTINGS_DEFAULTS,
|
package/src/store/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { createReduxStore,
|
|
4
|
+
import { createReduxStore, register } from '@wordpress/data';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -33,12 +33,6 @@ export const storeConfig = {
|
|
|
33
33
|
*/
|
|
34
34
|
export const store = createReduxStore( STORE_NAME, {
|
|
35
35
|
...storeConfig,
|
|
36
|
-
persist: [ 'preferences' ],
|
|
37
36
|
} );
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
// we'd be able to replace this with a register call.
|
|
41
|
-
registerStore( STORE_NAME, {
|
|
42
|
-
...storeConfig,
|
|
43
|
-
persist: [ 'preferences' ],
|
|
44
|
-
} );
|
|
38
|
+
register( store );
|
package/src/store/reducer.js
CHANGED
|
@@ -11,7 +11,7 @@ import { combineReducers } from '@wordpress/data';
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { EDITOR_SETTINGS_DEFAULTS } from './defaults';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Returns a post attribute value, flattening nested rendered content using its
|
|
@@ -119,32 +119,6 @@ export function template( state = { isValid: true }, action ) {
|
|
|
119
119
|
return state;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
/**
|
|
123
|
-
* Reducer returning the user preferences.
|
|
124
|
-
*
|
|
125
|
-
* @param {Object} state Current state.
|
|
126
|
-
* @param {Object} action Dispatched action.
|
|
127
|
-
*
|
|
128
|
-
* @return {string} Updated state.
|
|
129
|
-
*/
|
|
130
|
-
export function preferences( state = PREFERENCES_DEFAULTS, action ) {
|
|
131
|
-
switch ( action.type ) {
|
|
132
|
-
case 'ENABLE_PUBLISH_SIDEBAR':
|
|
133
|
-
return {
|
|
134
|
-
...state,
|
|
135
|
-
isPublishSidebarEnabled: true,
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
case 'DISABLE_PUBLISH_SIDEBAR':
|
|
139
|
-
return {
|
|
140
|
-
...state,
|
|
141
|
-
isPublishSidebarEnabled: false,
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return state;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
122
|
/**
|
|
149
123
|
* Reducer returning current network request state (whether a request to
|
|
150
124
|
* the WP REST API is in progress, successful, or failed).
|
|
@@ -282,7 +256,6 @@ export function editorSettings( state = EDITOR_SETTINGS_DEFAULTS, action ) {
|
|
|
282
256
|
export default combineReducers( {
|
|
283
257
|
postId,
|
|
284
258
|
postType,
|
|
285
|
-
preferences,
|
|
286
259
|
saving,
|
|
287
260
|
postLock,
|
|
288
261
|
template,
|
|
@@ -9,7 +9,6 @@ import { combineReducers } from '@wordpress/data';
|
|
|
9
9
|
import {
|
|
10
10
|
postId,
|
|
11
11
|
postType,
|
|
12
|
-
preferences,
|
|
13
12
|
saving,
|
|
14
13
|
postLock,
|
|
15
14
|
postSavingLock,
|
|
@@ -84,7 +83,6 @@ export default combineReducers( {
|
|
|
84
83
|
postId,
|
|
85
84
|
postType,
|
|
86
85
|
postTitle,
|
|
87
|
-
preferences,
|
|
88
86
|
saving,
|
|
89
87
|
postLock,
|
|
90
88
|
postSavingLock,
|
package/src/store/selectors.js
CHANGED
|
@@ -20,11 +20,11 @@ import { Platform } from '@wordpress/element';
|
|
|
20
20
|
import { layout } from '@wordpress/icons';
|
|
21
21
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
22
22
|
import { store as coreStore } from '@wordpress/core-data';
|
|
23
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Internal dependencies
|
|
26
27
|
*/
|
|
27
|
-
import { PREFERENCES_DEFAULTS } from './defaults';
|
|
28
28
|
import {
|
|
29
29
|
EDIT_MERGE_PROPERTIES,
|
|
30
30
|
PERMALINK_POSTNAME_REGEX,
|
|
@@ -1093,16 +1093,15 @@ export function canUserUseUnfilteredHTML( state ) {
|
|
|
1093
1093
|
* Returns whether the pre-publish panel should be shown
|
|
1094
1094
|
* or skipped when the user clicks the "publish" button.
|
|
1095
1095
|
*
|
|
1096
|
-
* @param {Object} state Global application state.
|
|
1097
|
-
*
|
|
1098
1096
|
* @return {boolean} Whether the pre-publish panel should be shown or not.
|
|
1099
1097
|
*/
|
|
1100
|
-
export
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1098
|
+
export const isPublishSidebarEnabled = createRegistrySelector(
|
|
1099
|
+
( select ) => () =>
|
|
1100
|
+
!! select( preferencesStore ).get(
|
|
1101
|
+
'core/edit-post',
|
|
1102
|
+
'isPublishSidebarEnabled'
|
|
1103
|
+
)
|
|
1104
|
+
);
|
|
1106
1105
|
|
|
1107
1106
|
/**
|
|
1108
1107
|
* Return the current block list.
|
|
@@ -6,6 +6,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
|
6
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
7
7
|
import { createRegistry } from '@wordpress/data';
|
|
8
8
|
import { store as noticesStore } from '@wordpress/notices';
|
|
9
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
@@ -46,6 +47,7 @@ function createRegistryWithStores() {
|
|
|
46
47
|
registry.register( coreStore );
|
|
47
48
|
registry.register( editorStore );
|
|
48
49
|
registry.register( noticesStore );
|
|
50
|
+
registry.register( preferencesStore );
|
|
49
51
|
|
|
50
52
|
// Register post type entity.
|
|
51
53
|
registry.dispatch( coreStore ).addEntities( [ postTypeConfig ] );
|
|
@@ -83,6 +85,13 @@ describe( 'Post actions', () => {
|
|
|
83
85
|
path.startsWith( `/wp/v2/posts/${ postId }` )
|
|
84
86
|
) {
|
|
85
87
|
return { ...post, ...data };
|
|
88
|
+
} else if (
|
|
89
|
+
// This URL is requested by the actions dispatched in this test.
|
|
90
|
+
// They are safe to ignore and are only listed here to avoid triggeringan error.
|
|
91
|
+
method === 'GET' &&
|
|
92
|
+
path.startsWith( '/wp/v2/types/post' )
|
|
93
|
+
) {
|
|
94
|
+
return {};
|
|
86
95
|
}
|
|
87
96
|
|
|
88
97
|
throw {
|
|
@@ -128,7 +137,7 @@ describe( 'Post actions', () => {
|
|
|
128
137
|
expect( notices ).toMatchObject( [
|
|
129
138
|
{
|
|
130
139
|
status: 'success',
|
|
131
|
-
content: 'Draft saved',
|
|
140
|
+
content: 'Draft saved.',
|
|
132
141
|
},
|
|
133
142
|
] );
|
|
134
143
|
} );
|
|
@@ -163,6 +172,15 @@ describe( 'Post actions', () => {
|
|
|
163
172
|
} else if ( method === 'GET' ) {
|
|
164
173
|
return [];
|
|
165
174
|
}
|
|
175
|
+
} else if ( method === 'GET' ) {
|
|
176
|
+
// These URLs are requested by the actions dispatched in this test.
|
|
177
|
+
// They are safe to ignore and are only listed here to avoid triggeringan error.
|
|
178
|
+
if (
|
|
179
|
+
path.startsWith( '/wp/v2/types/post' ) ||
|
|
180
|
+
path.startsWith( `/wp/v2/posts/${ postId }` )
|
|
181
|
+
) {
|
|
182
|
+
return {};
|
|
183
|
+
}
|
|
166
184
|
}
|
|
167
185
|
|
|
168
186
|
throw {
|
|
@@ -239,6 +257,13 @@ describe( 'Post actions', () => {
|
|
|
239
257
|
...data,
|
|
240
258
|
};
|
|
241
259
|
}
|
|
260
|
+
// This URL is requested by the actions dispatched in this test.
|
|
261
|
+
// They are safe to ignore and are only listed here to avoid triggeringan error.
|
|
262
|
+
} else if (
|
|
263
|
+
method === 'GET' &&
|
|
264
|
+
path.startsWith( '/wp/v2/types/post' )
|
|
265
|
+
) {
|
|
266
|
+
return {};
|
|
242
267
|
}
|
|
243
268
|
|
|
244
269
|
throw {
|
|
@@ -326,4 +351,39 @@ describe( 'Editor actions', () => {
|
|
|
326
351
|
} );
|
|
327
352
|
} );
|
|
328
353
|
} );
|
|
354
|
+
|
|
355
|
+
describe( 'enablePublishSidebar', () => {
|
|
356
|
+
it( 'enables the publish sidebar', () => {
|
|
357
|
+
const registry = createRegistryWithStores();
|
|
358
|
+
|
|
359
|
+
// Starts off as `undefined` as a default hasn't been set.
|
|
360
|
+
expect(
|
|
361
|
+
registry.select( editorStore ).isPublishSidebarEnabled()
|
|
362
|
+
).toBe( false );
|
|
363
|
+
|
|
364
|
+
registry.dispatch( editorStore ).enablePublishSidebar();
|
|
365
|
+
|
|
366
|
+
expect(
|
|
367
|
+
registry.select( editorStore ).isPublishSidebarEnabled()
|
|
368
|
+
).toBe( true );
|
|
369
|
+
} );
|
|
370
|
+
} );
|
|
371
|
+
|
|
372
|
+
describe( 'disablePublishSidebar', () => {
|
|
373
|
+
it( 'disables the publish sidebar', () => {
|
|
374
|
+
const registry = createRegistryWithStores();
|
|
375
|
+
|
|
376
|
+
// Enable it to start with so that can test it flipping from `true` to `false`.
|
|
377
|
+
registry.dispatch( editorStore ).enablePublishSidebar();
|
|
378
|
+
expect(
|
|
379
|
+
registry.select( editorStore ).isPublishSidebarEnabled()
|
|
380
|
+
).toBe( true );
|
|
381
|
+
|
|
382
|
+
registry.dispatch( editorStore ).disablePublishSidebar();
|
|
383
|
+
|
|
384
|
+
expect(
|
|
385
|
+
registry.select( editorStore ).isPublishSidebarEnabled()
|
|
386
|
+
).toBe( false );
|
|
387
|
+
} );
|
|
388
|
+
} );
|
|
329
389
|
} );
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
isUpdatingSamePostProperty,
|
|
12
12
|
shouldOverwriteState,
|
|
13
13
|
getPostRawValue,
|
|
14
|
-
preferences,
|
|
15
14
|
saving,
|
|
16
15
|
postSavingLock,
|
|
17
16
|
postAutosavingLock,
|
|
@@ -163,36 +162,6 @@ describe( 'state', () => {
|
|
|
163
162
|
} );
|
|
164
163
|
} );
|
|
165
164
|
|
|
166
|
-
describe( 'preferences()', () => {
|
|
167
|
-
it( 'should apply all defaults', () => {
|
|
168
|
-
const state = preferences( undefined, {} );
|
|
169
|
-
expect( state ).toEqual( {
|
|
170
|
-
insertUsage: {},
|
|
171
|
-
isPublishSidebarEnabled: true,
|
|
172
|
-
} );
|
|
173
|
-
} );
|
|
174
|
-
|
|
175
|
-
it( 'should disable the publish sidebar', () => {
|
|
176
|
-
const original = deepFreeze( preferences( undefined, {} ) );
|
|
177
|
-
const state = preferences( original, {
|
|
178
|
-
type: 'DISABLE_PUBLISH_SIDEBAR',
|
|
179
|
-
} );
|
|
180
|
-
|
|
181
|
-
expect( state.isPublishSidebarEnabled ).toBe( false );
|
|
182
|
-
} );
|
|
183
|
-
|
|
184
|
-
it( 'should enable the publish sidebar', () => {
|
|
185
|
-
const original = deepFreeze(
|
|
186
|
-
preferences( { isPublishSidebarEnabled: false }, {} )
|
|
187
|
-
);
|
|
188
|
-
const state = preferences( original, {
|
|
189
|
-
type: 'ENABLE_PUBLISH_SIDEBAR',
|
|
190
|
-
} );
|
|
191
|
-
|
|
192
|
-
expect( state.isPublishSidebarEnabled ).toBe( true );
|
|
193
|
-
} );
|
|
194
|
-
} );
|
|
195
|
-
|
|
196
165
|
describe( 'saving()', () => {
|
|
197
166
|
it( 'should update when a request is started', () => {
|
|
198
167
|
const state = saving( null, {
|
|
@@ -22,7 +22,6 @@ import { layout, footer, header } from '@wordpress/icons';
|
|
|
22
22
|
* Internal dependencies
|
|
23
23
|
*/
|
|
24
24
|
import * as _selectors from '../selectors';
|
|
25
|
-
import { PREFERENCES_DEFAULTS } from '../defaults';
|
|
26
25
|
|
|
27
26
|
const selectors = { ..._selectors };
|
|
28
27
|
const selectorNames = Object.keys( selectors );
|
|
@@ -182,7 +181,6 @@ const {
|
|
|
182
181
|
didPostSaveRequestFail,
|
|
183
182
|
getSuggestedPostFormat,
|
|
184
183
|
getEditedPostContent,
|
|
185
|
-
isPublishSidebarEnabled,
|
|
186
184
|
isPermalinkEditable,
|
|
187
185
|
getPermalink,
|
|
188
186
|
getPermalinkParts,
|
|
@@ -2570,39 +2568,6 @@ describe( 'selectors', () => {
|
|
|
2570
2568
|
} );
|
|
2571
2569
|
} );
|
|
2572
2570
|
|
|
2573
|
-
describe( 'isPublishSidebarEnabled', () => {
|
|
2574
|
-
it( 'should return the value on state if it is thruthy', () => {
|
|
2575
|
-
const state = {
|
|
2576
|
-
preferences: {
|
|
2577
|
-
isPublishSidebarEnabled: true,
|
|
2578
|
-
},
|
|
2579
|
-
};
|
|
2580
|
-
expect( isPublishSidebarEnabled( state ) ).toBe(
|
|
2581
|
-
state.preferences.isPublishSidebarEnabled
|
|
2582
|
-
);
|
|
2583
|
-
} );
|
|
2584
|
-
|
|
2585
|
-
it( 'should return the value on state if it is falsy', () => {
|
|
2586
|
-
const state = {
|
|
2587
|
-
preferences: {
|
|
2588
|
-
isPublishSidebarEnabled: false,
|
|
2589
|
-
},
|
|
2590
|
-
};
|
|
2591
|
-
expect( isPublishSidebarEnabled( state ) ).toBe(
|
|
2592
|
-
state.preferences.isPublishSidebarEnabled
|
|
2593
|
-
);
|
|
2594
|
-
} );
|
|
2595
|
-
|
|
2596
|
-
it( 'should return the default value if there is no isPublishSidebarEnabled key on state', () => {
|
|
2597
|
-
const state = {
|
|
2598
|
-
preferences: {},
|
|
2599
|
-
};
|
|
2600
|
-
expect( isPublishSidebarEnabled( state ) ).toBe(
|
|
2601
|
-
PREFERENCES_DEFAULTS.isPublishSidebarEnabled
|
|
2602
|
-
);
|
|
2603
|
-
} );
|
|
2604
|
-
} );
|
|
2605
|
-
|
|
2606
2571
|
describe( 'isPermalinkEditable', () => {
|
|
2607
2572
|
it( 'should be false if there is no permalink', () => {
|
|
2608
2573
|
const state = {
|
|
@@ -39,12 +39,13 @@ export function getNotificationArgumentsForSaveSuccess( data ) {
|
|
|
39
39
|
|
|
40
40
|
let noticeMessage;
|
|
41
41
|
let shouldShowLink = get( postType, [ 'viewable' ], false );
|
|
42
|
+
let isDraft;
|
|
42
43
|
|
|
43
44
|
// Always should a notice, which will be spoken for accessibility.
|
|
44
45
|
if ( ! isPublished && ! willPublish ) {
|
|
45
46
|
// If saving a non-published post, don't show notice.
|
|
46
|
-
noticeMessage = __( 'Draft saved' );
|
|
47
|
-
|
|
47
|
+
noticeMessage = __( 'Draft saved.' );
|
|
48
|
+
isDraft = true;
|
|
48
49
|
} else if ( isPublished && ! willPublish ) {
|
|
49
50
|
// If undoing publish status, show specific notice.
|
|
50
51
|
noticeMessage = postType.labels.item_reverted_to_draft;
|
|
@@ -65,7 +66,7 @@ export function getNotificationArgumentsForSaveSuccess( data ) {
|
|
|
65
66
|
const actions = [];
|
|
66
67
|
if ( shouldShowLink ) {
|
|
67
68
|
actions.push( {
|
|
68
|
-
label: postType.labels.view_item,
|
|
69
|
+
label: isDraft ? __( 'View Preview' ) : postType.labels.view_item,
|
|
69
70
|
url: post.link,
|
|
70
71
|
} );
|
|
71
72
|
}
|
|
@@ -34,7 +34,7 @@ describe( 'getNotificationArgumentsForSaveSuccess()', () => {
|
|
|
34
34
|
[
|
|
35
35
|
'when previous post is not published and post will not be published',
|
|
36
36
|
[ 'draft', 'draft', false ],
|
|
37
|
-
[ 'Draft saved', defaultExpectedAction ],
|
|
37
|
+
[ 'Draft saved.', defaultExpectedAction ],
|
|
38
38
|
],
|
|
39
39
|
[
|
|
40
40
|
'when previous post is published and post will be unpublished',
|