@wordpress/editor 14.47.0 → 14.48.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 +26 -0
- package/build/components/block-removal-warnings/index.cjs +0 -3
- package/build/components/block-removal-warnings/index.cjs.map +2 -2
- package/build/components/collab-sidebar/note-indicator-toolbar.cjs +49 -43
- package/build/components/collab-sidebar/note-indicator-toolbar.cjs.map +3 -3
- package/build/components/collaborators-overlay/use-block-highlighting.cjs +1 -8
- package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +3 -3
- package/build/components/collaborators-overlay/use-render-cursors.cjs +1 -7
- package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
- package/build/components/more-menu/view-more-menu-group.cjs +1 -2
- package/build/components/more-menu/view-more-menu-group.cjs.map +2 -2
- package/build/components/page-attributes/parent.cjs +1 -0
- package/build/components/page-attributes/parent.cjs.map +2 -2
- package/build/components/post-publish-button/index.cjs +114 -157
- package/build/components/post-publish-button/index.cjs.map +3 -3
- package/build/components/post-revisions-preview/block-diff.cjs +21 -9
- package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
- package/build/components/post-revisions-preview/preserve-client-ids.cjs +2 -2
- package/build/components/post-revisions-preview/preserve-client-ids.cjs.map +2 -2
- package/build/components/provider/index.cjs +2 -0
- package/build/components/provider/index.cjs.map +3 -3
- package/build/components/provider/use-block-editor-settings.cjs +1 -1
- package/build/components/provider/use-block-editor-settings.cjs.map +2 -2
- package/build/components/provider/use-network-reconnect.cjs +51 -0
- package/build/components/provider/use-network-reconnect.cjs.map +7 -0
- package/build/components/revision-fields-diff/index.cjs +2 -2
- package/build/components/revision-fields-diff/index.cjs.map +2 -2
- package/build/components/sidebar/index.cjs +1 -4
- package/build/components/sidebar/index.cjs.map +2 -2
- package/build/components/template-actions-panel/block-theme-content.cjs +7 -1
- package/build/components/template-actions-panel/block-theme-content.cjs.map +2 -2
- package/build/components/upload-progress-snackbar/index.cjs +161 -0
- package/build/components/upload-progress-snackbar/index.cjs.map +7 -0
- package/build/components/upload-progress-snackbar/tracker.cjs +90 -0
- package/build/components/upload-progress-snackbar/tracker.cjs.map +7 -0
- package/build/private-apis.cjs +2 -0
- package/build/private-apis.cjs.map +3 -3
- package/build/store/selectors.cjs +1 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/media-upload/index.cjs +16 -0
- package/build/utils/media-upload/index.cjs.map +3 -3
- package/build-module/components/block-removal-warnings/index.mjs +0 -3
- package/build-module/components/block-removal-warnings/index.mjs.map +2 -2
- package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs +53 -44
- package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +1 -8
- package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs +1 -7
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
- package/build-module/components/more-menu/view-more-menu-group.mjs +1 -2
- package/build-module/components/more-menu/view-more-menu-group.mjs.map +2 -2
- package/build-module/components/page-attributes/parent.mjs +1 -0
- package/build-module/components/page-attributes/parent.mjs.map +2 -2
- package/build-module/components/post-publish-button/index.mjs +116 -159
- package/build-module/components/post-publish-button/index.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/block-diff.mjs +20 -8
- package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/preserve-client-ids.mjs +1 -1
- package/build-module/components/post-revisions-preview/preserve-client-ids.mjs.map +1 -1
- package/build-module/components/provider/index.mjs +2 -0
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +1 -1
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/provider/use-network-reconnect.mjs +30 -0
- package/build-module/components/provider/use-network-reconnect.mjs.map +7 -0
- package/build-module/components/revision-fields-diff/index.mjs +2 -2
- package/build-module/components/revision-fields-diff/index.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +2 -11
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/template-actions-panel/block-theme-content.mjs +7 -1
- package/build-module/components/template-actions-panel/block-theme-content.mjs.map +2 -2
- package/build-module/components/upload-progress-snackbar/index.mjs +135 -0
- package/build-module/components/upload-progress-snackbar/index.mjs.map +7 -0
- package/build-module/components/upload-progress-snackbar/tracker.mjs +61 -0
- package/build-module/components/upload-progress-snackbar/tracker.mjs.map +7 -0
- package/build-module/private-apis.mjs +2 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/selectors.mjs +1 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/media-upload/index.mjs +19 -0
- package/build-module/utils/media-upload/index.mjs.map +2 -2
- package/build-style/style-rtl.css +479 -84
- package/build-style/style.css +479 -84
- package/build-types/components/block-removal-warnings/index.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/add-comment.d.ts +6 -0
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comment-author-info.d.ts +8 -0
- package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comment-form.d.ts +9 -0
- package/build-types/components/collab-sidebar/comment-form.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +6 -0
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comment-menu-item.d.ts +6 -0
- package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comments.d.ts +10 -0
- package/build-types/components/collab-sidebar/comments.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts +0 -3
- package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts +2 -2
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/global-styles-provider/index.d.ts +16 -0
- package/build-types/components/global-styles-provider/index.d.ts.map +1 -0
- package/build-types/components/media/index.d.ts +3 -0
- package/build-types/components/media/index.d.ts.map +1 -0
- package/build-types/components/media/metadata-panel.d.ts +12 -0
- package/build-types/components/media/metadata-panel.d.ts.map +1 -0
- package/build-types/components/media/preview.d.ts +9 -0
- package/build-types/components/media/preview.d.ts.map +1 -0
- package/build-types/components/more-menu/view-more-menu-group.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/post-locked-modal/index.d.ts +6 -1
- package/build-types/components/post-publish-button/index.d.ts +9 -9
- package/build-types/components/post-publish-button/index.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/block-diff.d.ts +3 -0
- package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts +6 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +6 -1
- package/build-types/components/post-text-editor/index.d.ts +1 -1
- package/build-types/components/post-text-editor/index.d.ts.map +1 -1
- package/build-types/components/post-text-editor/utils.d.ts +29 -0
- package/build-types/components/post-text-editor/utils.d.ts.map +1 -0
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/provider/use-network-reconnect.d.ts +8 -0
- package/build-types/components/provider/use-network-reconnect.d.ts.map +1 -0
- package/build-types/components/revision-fields-diff/index.d.ts +3 -0
- package/build-types/components/revision-fields-diff/index.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -1
- package/build-types/components/upload-progress-snackbar/index.d.ts +19 -0
- package/build-types/components/upload-progress-snackbar/index.d.ts.map +1 -0
- package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts +28 -0
- package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts.map +1 -0
- package/build-types/components/upload-progress-snackbar/tracker.d.ts +41 -0
- package/build-types/components/upload-progress-snackbar/tracker.d.ts.map +1 -0
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
- package/build-types/utils/media-upload/index.d.ts.map +1 -1
- package/package.json +55 -52
- package/src/components/README.md +1 -1
- package/src/components/block-removal-warnings/index.js +0 -7
- package/src/components/collab-sidebar/note-indicator-toolbar.js +73 -60
- package/src/components/collaborators-overlay/use-block-highlighting.ts +0 -9
- package/src/components/collaborators-overlay/use-render-cursors.ts +0 -8
- package/src/components/collaborators-presence/avatar/test/index.tsx +8 -3
- package/src/components/more-menu/view-more-menu-group.js +1 -2
- package/src/components/page-attributes/parent.js +1 -0
- package/src/components/post-publish-button/index.js +143 -192
- package/src/components/post-publish-button/test/index.js +137 -114
- package/src/components/post-revisions-preview/block-diff.js +63 -19
- package/src/components/post-revisions-preview/preserve-client-ids.js +1 -1
- package/src/components/post-revisions-preview/test/block-diff.js +109 -6
- package/src/components/provider/index.js +4 -0
- package/src/components/provider/test/use-network-reconnect.js +137 -0
- package/src/components/provider/use-block-editor-settings.js +2 -2
- package/src/components/provider/use-network-reconnect.js +44 -0
- package/src/components/revision-fields-diff/index.js +7 -2
- package/src/components/sidebar/index.js +2 -11
- package/src/components/template-actions-panel/block-theme-content.js +10 -1
- package/src/components/upload-progress-snackbar/README.md +26 -0
- package/src/components/upload-progress-snackbar/index.js +216 -0
- package/src/components/upload-progress-snackbar/stories/index.story.tsx +85 -0
- package/src/components/upload-progress-snackbar/style.scss +30 -0
- package/src/components/upload-progress-snackbar/test/index.js +199 -0
- package/src/components/upload-progress-snackbar/tracker.js +105 -0
- package/src/private-apis.js +2 -0
- package/src/store/selectors.js +1 -3
- package/src/style.scss +1 -0
- package/src/utils/media-upload/index.js +27 -0
- package/src/components/commands/index.native.js +0 -2
- package/src/components/deprecated.native.js +0 -47
- package/src/components/editor-help/add-blocks.native.js +0 -40
- package/src/components/editor-help/customize-blocks.native.js +0 -40
- package/src/components/editor-help/help-detail-navigation-screen.native.js +0 -67
- package/src/components/editor-help/help-get-support-button.native.js +0 -38
- package/src/components/editor-help/help-section-title.native.js +0 -29
- package/src/components/editor-help/help-topic-row.native.js +0 -33
- package/src/components/editor-help/icon-move-blocks.native.js +0 -10
- package/src/components/editor-help/index.native.js +0 -208
- package/src/components/editor-help/intro-to-blocks.native.js +0 -91
- package/src/components/editor-help/move-blocks.native.js +0 -55
- package/src/components/editor-help/remove-blocks.native.js +0 -35
- package/src/components/editor-help/style.android.scss +0 -6
- package/src/components/editor-help/style.ios.scss +0 -6
- package/src/components/editor-help/test/index.native.js +0 -81
- package/src/components/editor-help/view-sections.native.js +0 -79
- package/src/components/error-boundary/index.native.js +0 -192
- package/src/components/error-boundary/style.native.scss +0 -116
- package/src/components/index.native.js +0 -15
- package/src/components/offline-status/index.native.js +0 -99
- package/src/components/offline-status/style.native.scss +0 -28
- package/src/components/offline-status/test/index.native.js +0 -108
- package/src/components/post-title/index.native.js +0 -282
- package/src/components/post-title/style.native.scss +0 -13
- package/src/components/post-title/test/__snapshots__/index.native.js.snap +0 -25
- package/src/components/post-title/test/index.native.js +0 -78
- package/src/components/provider/index.native.js +0 -497
- package/src/components/provider/use-block-editor-settings.native.js +0 -48
- package/src/components/template-part-menu-items/index.native.js +0 -3
- package/src/hooks/index.native.js +0 -0
- package/src/index.native.js +0 -16
- package/src/private-apis.native.js +0 -33
- package/src/store/actions.native.js +0 -27
- package/src/store/reducer.native.js +0 -94
- package/src/store/selectors.native.js +0 -57
- package/src/store/test/actions.native.js +0 -16
- package/src/store/test/reducer.native.js +0 -36
- package/src/store/test/selectors.native.js +0 -28
- package/src/utils/index.native.js +0 -6
- package/src/utils/media-sideload/index.native.js +0 -1
- package/src/utils/media-upload/index.native.js +0 -1
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { Button } from '@wordpress/components';
|
|
5
|
-
import {
|
|
6
|
-
import { withSelect, withDispatch } from '@wordpress/data';
|
|
7
|
-
import { compose } from '@wordpress/compose';
|
|
5
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* Internal dependencies
|
|
@@ -14,220 +12,173 @@ import { store as editorStore } from '../../store';
|
|
|
14
12
|
|
|
15
13
|
const noop = () => {};
|
|
16
14
|
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
export function PostPublishButton( {
|
|
16
|
+
forceIsDirty,
|
|
17
|
+
isOpen,
|
|
18
|
+
isToggle,
|
|
19
|
+
onSubmit = noop,
|
|
20
|
+
onToggle,
|
|
21
|
+
setEntitiesSavedStatesCallback,
|
|
22
|
+
} ) {
|
|
23
|
+
const {
|
|
24
|
+
hasPublishAction,
|
|
25
|
+
isBeingScheduled,
|
|
26
|
+
isPostSavingLocked,
|
|
27
|
+
isPublishable,
|
|
28
|
+
isPublished,
|
|
29
|
+
isSaveable,
|
|
30
|
+
isSaving,
|
|
31
|
+
isAutoSaving,
|
|
32
|
+
visibility,
|
|
33
|
+
hasNonPostEntityChanges,
|
|
34
|
+
isSavingNonPostEntityChanges,
|
|
35
|
+
postStatus,
|
|
36
|
+
postStatusHasChanged,
|
|
37
|
+
postType,
|
|
38
|
+
postId,
|
|
39
|
+
} = useSelect( ( select ) => {
|
|
40
|
+
const store = select( editorStore );
|
|
41
|
+
return {
|
|
42
|
+
isSaving: store.isSavingPost(),
|
|
43
|
+
isAutoSaving: store.isAutosavingPost(),
|
|
44
|
+
isBeingScheduled: store.isEditedPostBeingScheduled(),
|
|
45
|
+
visibility: store.getEditedPostVisibility(),
|
|
46
|
+
isSaveable: store.isEditedPostSaveable(),
|
|
47
|
+
isPostSavingLocked: store.isPostSavingLocked(),
|
|
48
|
+
isPublishable: store.isEditedPostPublishable(),
|
|
49
|
+
isPublished: store.isCurrentPostPublished(),
|
|
50
|
+
hasPublishAction:
|
|
51
|
+
store.getCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,
|
|
52
|
+
postType: store.getCurrentPostType(),
|
|
53
|
+
postId: store.getCurrentPostId(),
|
|
54
|
+
postStatus: store.getEditedPostAttribute( 'status' ),
|
|
55
|
+
postStatusHasChanged: store.getPostEdits()?.status,
|
|
56
|
+
hasNonPostEntityChanges: store.hasNonPostEntityChanges(),
|
|
57
|
+
isSavingNonPostEntityChanges: store.isSavingNonPostEntityChanges(),
|
|
58
|
+
};
|
|
59
|
+
}, [] );
|
|
20
60
|
|
|
21
|
-
|
|
22
|
-
this.closeEntitiesSavedStates =
|
|
23
|
-
this.closeEntitiesSavedStates.bind( this );
|
|
61
|
+
const { editPost, savePost } = useDispatch( editorStore );
|
|
24
62
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
63
|
+
const savePostStatus = ( status ) => {
|
|
64
|
+
editPost( { status }, { undoIgnore: true } );
|
|
65
|
+
savePost();
|
|
66
|
+
};
|
|
29
67
|
|
|
30
|
-
createOnClick
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.props;
|
|
68
|
+
const createOnClick =
|
|
69
|
+
( callback ) =>
|
|
70
|
+
( ...args ) => {
|
|
34
71
|
// If a post with non-post entities is published, but the user
|
|
35
72
|
// elects to not save changes to the non-post entities, those
|
|
36
73
|
// entities will still be dirty when the Publish button is clicked.
|
|
37
74
|
// We also need to check that the `setEntitiesSavedStatesCallback`
|
|
38
75
|
// prop was passed. See https://github.com/WordPress/gutenberg/pull/37383
|
|
39
76
|
if ( hasNonPostEntityChanges && setEntitiesSavedStatesCallback ) {
|
|
40
|
-
// The modal for multiple entity saving will open
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
77
|
+
// The modal for multiple entity saving will open. If the post
|
|
78
|
+
// entity is checked when it closes, run the held callback.
|
|
79
|
+
const onClose = ( savedEntities ) => {
|
|
80
|
+
if (
|
|
81
|
+
savedEntities &&
|
|
82
|
+
savedEntities.some(
|
|
83
|
+
( elt ) =>
|
|
84
|
+
elt.kind === 'postType' &&
|
|
85
|
+
elt.name === postType &&
|
|
86
|
+
elt.key === postId
|
|
87
|
+
)
|
|
88
|
+
) {
|
|
89
|
+
callback( ...args );
|
|
90
|
+
}
|
|
91
|
+
};
|
|
46
92
|
|
|
47
93
|
// Open the save panel by setting its callback.
|
|
48
94
|
// To set a function on the useState hook, we must set it
|
|
49
95
|
// with another function (() => myFunction). Passing the
|
|
50
96
|
// function on its own will cause an error when called.
|
|
51
|
-
setEntitiesSavedStatesCallback(
|
|
52
|
-
() => this.closeEntitiesSavedStates
|
|
53
|
-
);
|
|
97
|
+
setEntitiesSavedStatesCallback( () => onClose );
|
|
54
98
|
return noop;
|
|
55
99
|
}
|
|
56
100
|
|
|
57
101
|
return callback( ...args );
|
|
58
102
|
};
|
|
59
|
-
}
|
|
60
103
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
104
|
+
const isButtonDisabled =
|
|
105
|
+
isPostSavingLocked ||
|
|
106
|
+
( ( isSaving ||
|
|
107
|
+
! isSaveable ||
|
|
108
|
+
( ! isPublishable && ! forceIsDirty ) ) &&
|
|
109
|
+
( ! hasNonPostEntityChanges || isSavingNonPostEntityChanges ) );
|
|
110
|
+
|
|
111
|
+
const isToggleDisabled =
|
|
112
|
+
isPostSavingLocked ||
|
|
113
|
+
( ( isPublished ||
|
|
114
|
+
isSaving ||
|
|
115
|
+
! isSaveable ||
|
|
116
|
+
( ! isPublishable && ! forceIsDirty ) ) &&
|
|
117
|
+
( ! hasNonPostEntityChanges || isSavingNonPostEntityChanges ) );
|
|
118
|
+
|
|
119
|
+
// If the new status has not changed explicitly, we derive it from
|
|
120
|
+
// other factors, like having a publish action, etc.. We need to preserve
|
|
121
|
+
// this because it affects when to show the pre and post publish panels.
|
|
122
|
+
// If it has changed though explicitly, we need to respect that.
|
|
123
|
+
let publishStatus = 'publish';
|
|
124
|
+
if ( postStatusHasChanged ) {
|
|
125
|
+
publishStatus = postStatus;
|
|
126
|
+
} else if ( ! hasPublishAction ) {
|
|
127
|
+
publishStatus = 'pending';
|
|
128
|
+
} else if ( visibility === 'private' ) {
|
|
129
|
+
publishStatus = 'private';
|
|
130
|
+
} else if ( isBeingScheduled ) {
|
|
131
|
+
publishStatus = 'future';
|
|
78
132
|
}
|
|
79
133
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
hasPublishAction,
|
|
84
|
-
isBeingScheduled,
|
|
85
|
-
isOpen,
|
|
86
|
-
isPostSavingLocked,
|
|
87
|
-
isPublishable,
|
|
88
|
-
isPublished,
|
|
89
|
-
isSaveable,
|
|
90
|
-
isSaving,
|
|
91
|
-
isAutoSaving,
|
|
92
|
-
isToggle,
|
|
93
|
-
savePostStatus,
|
|
94
|
-
onSubmit = noop,
|
|
95
|
-
onToggle,
|
|
96
|
-
visibility,
|
|
97
|
-
hasNonPostEntityChanges,
|
|
98
|
-
isSavingNonPostEntityChanges,
|
|
99
|
-
postStatus,
|
|
100
|
-
postStatusHasChanged,
|
|
101
|
-
} = this.props;
|
|
102
|
-
|
|
103
|
-
const isButtonDisabled =
|
|
104
|
-
isPostSavingLocked ||
|
|
105
|
-
( ( isSaving ||
|
|
106
|
-
! isSaveable ||
|
|
107
|
-
( ! isPublishable && ! forceIsDirty ) ) &&
|
|
108
|
-
( ! hasNonPostEntityChanges || isSavingNonPostEntityChanges ) );
|
|
109
|
-
|
|
110
|
-
const isToggleDisabled =
|
|
111
|
-
isPostSavingLocked ||
|
|
112
|
-
( ( isPublished ||
|
|
113
|
-
isSaving ||
|
|
114
|
-
! isSaveable ||
|
|
115
|
-
( ! isPublishable && ! forceIsDirty ) ) &&
|
|
116
|
-
( ! hasNonPostEntityChanges || isSavingNonPostEntityChanges ) );
|
|
117
|
-
|
|
118
|
-
// If the new status has not changed explicitly, we derive it from
|
|
119
|
-
// other factors, like having a publish action, etc.. We need to preserve
|
|
120
|
-
// this because it affects when to show the pre and post publish panels.
|
|
121
|
-
// If it has changed though explicitly, we need to respect that.
|
|
122
|
-
let publishStatus = 'publish';
|
|
123
|
-
if ( postStatusHasChanged ) {
|
|
124
|
-
publishStatus = postStatus;
|
|
125
|
-
} else if ( ! hasPublishAction ) {
|
|
126
|
-
publishStatus = 'pending';
|
|
127
|
-
} else if ( visibility === 'private' ) {
|
|
128
|
-
publishStatus = 'private';
|
|
129
|
-
} else if ( isBeingScheduled ) {
|
|
130
|
-
publishStatus = 'future';
|
|
134
|
+
const onClickButton = () => {
|
|
135
|
+
if ( isButtonDisabled ) {
|
|
136
|
+
return;
|
|
131
137
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
className={ `${ componentProps.className } editor-post-publish-button__button` }
|
|
174
|
-
size="compact"
|
|
175
|
-
>
|
|
176
|
-
<PublishButtonLabel />
|
|
177
|
-
</Button>
|
|
178
|
-
</>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
138
|
+
onSubmit();
|
|
139
|
+
savePostStatus( publishStatus );
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// Callback to open the publish panel.
|
|
143
|
+
const onClickToggle = () => {
|
|
144
|
+
if ( isToggleDisabled ) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
onToggle();
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const buttonProps = {
|
|
151
|
+
'aria-disabled': isButtonDisabled,
|
|
152
|
+
className: 'editor-post-publish-button',
|
|
153
|
+
isBusy: ! isAutoSaving && isSaving,
|
|
154
|
+
variant: 'primary',
|
|
155
|
+
onClick: createOnClick( onClickButton ),
|
|
156
|
+
'aria-haspopup': hasNonPostEntityChanges ? 'dialog' : undefined,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const toggleProps = {
|
|
160
|
+
'aria-disabled': isToggleDisabled,
|
|
161
|
+
'aria-expanded': isOpen,
|
|
162
|
+
className: 'editor-post-publish-panel__toggle',
|
|
163
|
+
isBusy: isSaving && isPublished,
|
|
164
|
+
variant: 'primary',
|
|
165
|
+
size: 'compact',
|
|
166
|
+
onClick: createOnClick( onClickToggle ),
|
|
167
|
+
'aria-haspopup': hasNonPostEntityChanges ? 'dialog' : undefined,
|
|
168
|
+
};
|
|
169
|
+
const componentProps = isToggle ? toggleProps : buttonProps;
|
|
170
|
+
return (
|
|
171
|
+
<Button
|
|
172
|
+
{ ...componentProps }
|
|
173
|
+
className={ `${ componentProps.className } editor-post-publish-button__button` }
|
|
174
|
+
size="compact"
|
|
175
|
+
>
|
|
176
|
+
<PublishButtonLabel />
|
|
177
|
+
</Button>
|
|
178
|
+
);
|
|
181
179
|
}
|
|
182
180
|
|
|
183
181
|
/**
|
|
184
182
|
* Renders the publish button.
|
|
185
183
|
*/
|
|
186
|
-
export default
|
|
187
|
-
withSelect( ( select ) => {
|
|
188
|
-
const {
|
|
189
|
-
isSavingPost,
|
|
190
|
-
isAutosavingPost,
|
|
191
|
-
isEditedPostBeingScheduled,
|
|
192
|
-
getEditedPostVisibility,
|
|
193
|
-
isCurrentPostPublished,
|
|
194
|
-
isEditedPostSaveable,
|
|
195
|
-
isEditedPostPublishable,
|
|
196
|
-
isPostSavingLocked,
|
|
197
|
-
getCurrentPost,
|
|
198
|
-
getCurrentPostType,
|
|
199
|
-
getCurrentPostId,
|
|
200
|
-
hasNonPostEntityChanges,
|
|
201
|
-
isSavingNonPostEntityChanges,
|
|
202
|
-
getEditedPostAttribute,
|
|
203
|
-
getPostEdits,
|
|
204
|
-
} = select( editorStore );
|
|
205
|
-
return {
|
|
206
|
-
isSaving: isSavingPost(),
|
|
207
|
-
isAutoSaving: isAutosavingPost(),
|
|
208
|
-
isBeingScheduled: isEditedPostBeingScheduled(),
|
|
209
|
-
visibility: getEditedPostVisibility(),
|
|
210
|
-
isSaveable: isEditedPostSaveable(),
|
|
211
|
-
isPostSavingLocked: isPostSavingLocked(),
|
|
212
|
-
isPublishable: isEditedPostPublishable(),
|
|
213
|
-
isPublished: isCurrentPostPublished(),
|
|
214
|
-
hasPublishAction:
|
|
215
|
-
getCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,
|
|
216
|
-
postType: getCurrentPostType(),
|
|
217
|
-
postId: getCurrentPostId(),
|
|
218
|
-
postStatus: getEditedPostAttribute( 'status' ),
|
|
219
|
-
postStatusHasChanged: getPostEdits()?.status,
|
|
220
|
-
hasNonPostEntityChanges: hasNonPostEntityChanges(),
|
|
221
|
-
isSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),
|
|
222
|
-
};
|
|
223
|
-
} ),
|
|
224
|
-
withDispatch( ( dispatch ) => {
|
|
225
|
-
const { editPost, savePost } = dispatch( editorStore );
|
|
226
|
-
return {
|
|
227
|
-
savePostStatus: ( status ) => {
|
|
228
|
-
editPost( { status }, { undoIgnore: true } );
|
|
229
|
-
savePost();
|
|
230
|
-
},
|
|
231
|
-
};
|
|
232
|
-
} ),
|
|
233
|
-
] )( PostPublishButton );
|
|
184
|
+
export default PostPublishButton;
|