Skip to content

Commit efa4b01

Browse files
authored
Site and Post Editor: Unify the DocumentBar component (WordPress#56778)
1 parent ddfdcd9 commit efa4b01

File tree

20 files changed

+237
-406
lines changed

20 files changed

+237
-406
lines changed

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/commands/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ _This package assumes that your code will run in an **ES2015+** environment. If
6262

6363
Store definition for the commands namespace.
6464

65-
See how the Commands Store is being used in components like [site-hub](https://github.com/WordPress/gutenberg/blob/HEAD/packages/edit-site/src/components/site-hub/index.js#L23) and [document-actions](https://github.com/WordPress/gutenberg/blob/HEAD/packages/edit-post/src/components/header/document-actions/index.js#L14).
66-
6765
_Related_
6866

6967
- <https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore>

packages/commands/src/store/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ const STORE_NAME = 'core/commands';
1717
/**
1818
* Store definition for the commands namespace.
1919
*
20-
* See how the Commands Store is being used in components like [site-hub](https://github.com/WordPress/gutenberg/blob/HEAD/packages/edit-site/src/components/site-hub/index.js#L23) and [document-actions](https://github.com/WordPress/gutenberg/blob/HEAD/packages/edit-post/src/components/header/document-actions/index.js#L14).
21-
*
2220
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
2321
*
2422
* @type {Object}

packages/edit-post/src/components/header/document-actions/index.js

Lines changed: 0 additions & 83 deletions
This file was deleted.

packages/edit-post/src/components/header/document-actions/style.scss

Lines changed: 0 additions & 64 deletions
This file was deleted.

packages/edit-post/src/components/header/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
PostSavedState,
1515
PostPreviewButton,
1616
store as editorStore,
17+
DocumentBar,
1718
} from '@wordpress/editor';
1819
import { useEffect, useRef, useState } from '@wordpress/element';
1920
import { useSelect } from '@wordpress/data';
@@ -39,7 +40,6 @@ import { default as DevicePreview } from '../device-preview';
3940
import ViewLink from '../view-link';
4041
import MainDashboardButton from './main-dashboard-button';
4142
import { store as editPostStore } from '../../store';
42-
import DocumentActions from './document-actions';
4343
import { unlock } from '../../lock-unlock';
4444

4545
const { BlockContextualToolbar } = unlock( blockEditorPrivateApis );
@@ -164,7 +164,7 @@ function Header( {
164164
isLargeViewport,
165165
} ) }
166166
>
167-
{ isEditingTemplate && <DocumentActions /> }
167+
{ isEditingTemplate && <DocumentBar /> }
168168
</div>
169169
</motion.div>
170170
<motion.div

packages/edit-post/src/store/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ export function setIsEditingTemplate() {
531531
export const __unstableSwitchToTemplateMode =
532532
( newTemplate = false ) =>
533533
( { registry, select } ) => {
534-
registry.dispatch( editorStore ).setRenderingMode( 'all' );
534+
registry.dispatch( editorStore ).setRenderingMode( 'template-only' );
535535
const isWelcomeGuideActive = select.isFeatureActive(
536536
'welcomeGuideTemplate'
537537
);

packages/edit-post/src/style.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
@import "./components/header/style.scss";
33
@import "./components/header/fullscreen-mode-close/style.scss";
44
@import "./components/header/header-toolbar/style.scss";
5-
@import "./components/header/document-actions/style.scss";
65
@import "./components/keyboard-shortcut-help-modal/style.scss";
76
@import "./components/layout/style.scss";
87
@import "./components/block-manager/style.scss";

packages/edit-site/src/components/block-editor/use-site-editor-settings.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ export function useSpecificEditorSettings() {
9797
keepCaretInsideBlock,
9898
canvasMode,
9999
settings,
100+
postWithTemplate,
100101
} = useSelect( ( select ) => {
101102
const {
102103
getEditedPostType,
103104
getEditedPostId,
105+
getEditedPostContext,
104106
getCanvasMode,
105107
getSettings,
106108
} = unlock( select( editSiteStore ) );
@@ -113,6 +115,7 @@ export function useSpecificEditorSettings() {
113115
usedPostType,
114116
usedPostId
115117
);
118+
const _context = getEditedPostContext();
116119
return {
117120
templateSlug: _record.slug,
118121
focusMode: !! getPreference( 'core/edit-site', 'focusMode' ),
@@ -130,10 +133,11 @@ export function useSpecificEditorSettings() {
130133
),
131134
canvasMode: getCanvasMode(),
132135
settings: getSettings(),
136+
postWithTemplate: _context?.postId,
133137
};
134138
}, [] );
135139
const archiveLabels = useArchiveLabel( templateSlug );
136-
140+
const defaultRenderingMode = postWithTemplate ? 'template-locked' : 'all';
137141
const defaultEditorSettings = useMemo( () => {
138142
return {
139143
...settings,
@@ -144,6 +148,7 @@ export function useSpecificEditorSettings() {
144148
isDistractionFree,
145149
hasFixedToolbar,
146150
keepCaretInsideBlock,
151+
defaultRenderingMode,
147152

148153
// I wonder if they should be set in the post editor too
149154
__experimentalArchiveTitleTypeLabel: archiveLabels.archiveTypeLabel,
@@ -159,6 +164,7 @@ export function useSpecificEditorSettings() {
159164
canvasMode,
160165
archiveLabels.archiveTypeLabel,
161166
archiveLabels.archiveNameLabel,
167+
defaultRenderingMode,
162168
] );
163169

164170
return defaultEditorSettings;

0 commit comments

Comments
 (0)