Skip to content

Commit

Permalink
Site and Post Editor: Unify the DocumentBar component (#56778)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Dec 6, 2023
1 parent ddfdcd9 commit efa4b01
Show file tree
Hide file tree
Showing 20 changed files with 237 additions and 406 deletions.
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions packages/commands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ _This package assumes that your code will run in an **ES2015+** environment. If

Store definition for the commands namespace.

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).

_Related_

- <https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore>
Expand Down
2 changes: 0 additions & 2 deletions packages/commands/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ const STORE_NAME = 'core/commands';
/**
* Store definition for the commands namespace.
*
* 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).
*
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
*
* @type {Object}
Expand Down
83 changes: 0 additions & 83 deletions packages/edit-post/src/components/header/document-actions/index.js

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions packages/edit-post/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
PostSavedState,
PostPreviewButton,
store as editorStore,
DocumentBar,
} from '@wordpress/editor';
import { useEffect, useRef, useState } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
Expand All @@ -39,7 +40,6 @@ import { default as DevicePreview } from '../device-preview';
import ViewLink from '../view-link';
import MainDashboardButton from './main-dashboard-button';
import { store as editPostStore } from '../../store';
import DocumentActions from './document-actions';
import { unlock } from '../../lock-unlock';

const { BlockContextualToolbar } = unlock( blockEditorPrivateApis );
Expand Down Expand Up @@ -164,7 +164,7 @@ function Header( {
isLargeViewport,
} ) }
>
{ isEditingTemplate && <DocumentActions /> }
{ isEditingTemplate && <DocumentBar /> }
</div>
</motion.div>
<motion.div
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ export function setIsEditingTemplate() {
export const __unstableSwitchToTemplateMode =
( newTemplate = false ) =>
( { registry, select } ) => {
registry.dispatch( editorStore ).setRenderingMode( 'all' );
registry.dispatch( editorStore ).setRenderingMode( 'template-only' );
const isWelcomeGuideActive = select.isFeatureActive(
'welcomeGuideTemplate'
);
Expand Down
1 change: 0 additions & 1 deletion packages/edit-post/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
@import "./components/header/style.scss";
@import "./components/header/fullscreen-mode-close/style.scss";
@import "./components/header/header-toolbar/style.scss";
@import "./components/header/document-actions/style.scss";
@import "./components/keyboard-shortcut-help-modal/style.scss";
@import "./components/layout/style.scss";
@import "./components/block-manager/style.scss";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ export function useSpecificEditorSettings() {
keepCaretInsideBlock,
canvasMode,
settings,
postWithTemplate,
} = useSelect( ( select ) => {
const {
getEditedPostType,
getEditedPostId,
getEditedPostContext,
getCanvasMode,
getSettings,
} = unlock( select( editSiteStore ) );
Expand All @@ -113,6 +115,7 @@ export function useSpecificEditorSettings() {
usedPostType,
usedPostId
);
const _context = getEditedPostContext();
return {
templateSlug: _record.slug,
focusMode: !! getPreference( 'core/edit-site', 'focusMode' ),
Expand All @@ -130,10 +133,11 @@ export function useSpecificEditorSettings() {
),
canvasMode: getCanvasMode(),
settings: getSettings(),
postWithTemplate: _context?.postId,
};
}, [] );
const archiveLabels = useArchiveLabel( templateSlug );

const defaultRenderingMode = postWithTemplate ? 'template-locked' : 'all';
const defaultEditorSettings = useMemo( () => {
return {
...settings,
Expand All @@ -144,6 +148,7 @@ export function useSpecificEditorSettings() {
isDistractionFree,
hasFixedToolbar,
keepCaretInsideBlock,
defaultRenderingMode,

// I wonder if they should be set in the post editor too
__experimentalArchiveTitleTypeLabel: archiveLabels.archiveTypeLabel,
Expand All @@ -159,6 +164,7 @@ export function useSpecificEditorSettings() {
canvasMode,
archiveLabels.archiveTypeLabel,
archiveLabels.archiveNameLabel,
defaultRenderingMode,
] );

return defaultEditorSettings;
Expand Down
Loading

1 comment on commit efa4b01

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in efa4b01.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7114753396
📝 Reported issues:

Please sign in to comment.