Skip to content

Commit

Permalink
[Editor]: Unify publish sidebar preference (#60334)
Browse files Browse the repository at this point in the history
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
  • Loading branch information
3 people committed Apr 1, 2024
1 parent d6daa48 commit 7114727
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import { wpDataSelect } from './wp-data-select';
* @return {Promise<boolean>} Boolean which represents the state of prepublish checks.
*/
export async function arePrePublishChecksEnabled() {
return wpDataSelect( 'core/editor', 'isPublishSidebarEnabled' );
return wpDataSelect( 'core', 'isPublishSidebarEnabled' );
}
4 changes: 2 additions & 2 deletions packages/edit-post/src/hooks/commands/use-common-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ export default function useCommonCommands() {
icon: formatListBullets,
callback: ( { close } ) => {
close();
toggle( 'core/edit-post', 'isPublishSidebarEnabled' );
toggle( 'core', 'isPublishSidebarEnabled' );
createInfoNotice(
isPublishSidebarEnabled
? __( 'Pre-publish checks disabled.' )
: __( 'Pre-publish checks enabled.' ),
{
id: 'core/edit-post/publish-sidebar/notice',
id: 'core/editor/publish-sidebar/notice',
type: 'snackbar',
}
);
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export function initializeEditor(

dispatch( preferencesStore ).setDefaults( 'core/edit-post', {
fullscreenMode: true,
isPublishSidebarEnabled: true,
themeStyles: true,
welcomeGuide: true,
welcomeGuideTemplate: true,
Expand All @@ -72,6 +71,7 @@ export function initializeEditor(
showBlockBreadcrumbs: true,
showIconLabels: false,
showListViewByDefault: false,
isPublishSidebarEnabled: true,
} );

dispatch( blocksStore ).reapplyBlockTypeFilters();
Expand Down
5 changes: 1 addition & 4 deletions packages/edit-post/src/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,14 @@ export function initializeEditor( id, postType, postId ) {
editorMode: 'visual',
fullscreenMode: true,
inactivePanels: [],
isPublishSidebarEnabled: true,
openPanels: [ 'post-status' ],
welcomeGuide: true,
} );
dispatch( preferencesStore ).setDefaults( 'core', {
hiddenBlockTypes: [],
inactivePanels: [],
openPanels: [ 'post-status' ],
} );

dispatch( preferencesStore ).setDefaults( 'core', {
isPublishSidebarEnabled: true,
fixedToolbar: false,
} );

Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ export const enablePublishSidebar =
( { registry } ) => {
registry
.dispatch( preferencesStore )
.set( 'core/edit-post', 'isPublishSidebarEnabled', true );
.set( 'core', 'isPublishSidebarEnabled', true );
};

/**
Expand All @@ -417,7 +417,7 @@ export const disablePublishSidebar =
( { registry } ) => {
registry
.dispatch( preferencesStore )
.set( 'core/edit-post', 'isPublishSidebarEnabled', false );
.set( 'core', 'isPublishSidebarEnabled', false );
};

/**
Expand Down
5 changes: 1 addition & 4 deletions packages/editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1107,10 +1107,7 @@ export function canUserUseUnfilteredHTML( state ) {
*/
export const isPublishSidebarEnabled = createRegistrySelector(
( select ) => () =>
!! select( preferencesStore ).get(
'core/edit-post',
'isPublishSidebarEnabled'
)
!! select( preferencesStore ).get( 'core', 'isPublishSidebarEnabled' )
);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ export function convertLegacyData( data ) {
);
data = moveIndividualPreference(
data,
{ from: 'core/editor', to: 'core/edit-post' },
{ from: 'core/editor', to: 'core' },
'isPublishSidebarEnabled'
);
data = moveIndividualPreference(
data,
{ from: 'core/edit-post', to: 'core' },
'isPublishSidebarEnabled'
);
data = moveIndividualPreference(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default function convertEditorSettings( data ) {
'showBlockBreadcrumbs',
'showIconLabels',
'showListViewByDefault',
'isPublishSidebarEnabled',
];

settingsToMoveToCore.forEach( ( setting ) => {
Expand Down
1 change: 1 addition & 0 deletions packages/preferences/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const withDeprecatedKeys = ( originalGet ) => ( state, scope, name ) => {
'showBlockBreadcrumbs',
'showIconLabels',
'showListViewByDefault',
'isPublishSidebarEnabled',
];

if (
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/specs/editor/various/multi-entity-saving.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test.describe( 'Editor - Multi-entity save flow', () => {
} );

// Restore the Publish sidebar.
await editor.setPreferences( 'core/edit-post', {
await editor.setPreferences( 'core', {
isPublishSidebarEnabled: true,
} );
} );
Expand Down Expand Up @@ -154,7 +154,7 @@ test.describe( 'Editor - Multi-entity save flow', () => {
page,
} ) => {
await admin.createNewPost();
await editor.setPreferences( 'core/edit-post', {
await editor.setPreferences( 'core', {
isPublishSidebarEnabled: false,
} );

Expand Down
8 changes: 4 additions & 4 deletions test/e2e/specs/editor/various/publishing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ test.describe( 'Publishing', () => {
test.describe( `a ${ postType } with pre-publish checks disabled`, () => {
test.beforeEach( async ( { admin, editor } ) => {
await admin.createNewPost( { postType } );
await editor.setPreferences( 'core/edit-post', {
await editor.setPreferences( 'core', {
isPublishSidebarEnabled: false,
} );
} );

test.afterEach( async ( { editor } ) => {
await editor.setPreferences( 'core/edit-post', {
await editor.setPreferences( 'core', {
isPublishSidebarEnabled: true,
} );
} );
Expand Down Expand Up @@ -127,14 +127,14 @@ test.describe( 'Publishing', () => {
test.describe( `a ${ postType } in small viewports`, () => {
test.beforeEach( async ( { admin, editor, pageUtils } ) => {
await admin.createNewPost( { postType } );
await editor.setPreferences( 'core/edit-post', {
await editor.setPreferences( 'core', {
isPublishSidebarEnabled: false,
} );
await pageUtils.setBrowserViewport( 'small' );
} );

test.afterEach( async ( { editor, pageUtils } ) => {
await editor.setPreferences( 'core/edit-post', {
await editor.setPreferences( 'core', {
isPublishSidebarEnabled: true,
} );
await pageUtils.setBrowserViewport( 'large' );
Expand Down

0 comments on commit 7114727

Please sign in to comment.