Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site and Post Editor: Unify the DocumentBar component #56778

Merged
merged 8 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this because it gets out of sync very quickly as the code evolves.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could replace the reference to specific instances with a search query like https://github.com/search?q=repo%3AWordPress%2Fgutenberg+commandsStore+language%3AJavaScript&type=code&l=JavaScript which should always return relevant results.

*
* @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 @@ -160,7 +160,7 @@ function Header( {
isEditingTemplate,
} ) }
>
{ 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
Loading