Skip to content

Commit

Permalink
[Edit Post]: Add toggle fullscreen mode and list view commands (#52184)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras authored Jul 3, 2023
1 parent 3bb42ba commit 2479dc4
Showing 1 changed file with 39 additions and 9 deletions.
48 changes: 39 additions & 9 deletions packages/edit-post/src/hooks/commands/use-common-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
drawerRight,
blockDefault,
keyboardClose,
desktop,
listView,
} from '@wordpress/icons';
import { useCommand } from '@wordpress/commands';
import { store as preferencesStore } from '@wordpress/preferences';
Expand All @@ -23,16 +25,24 @@ import { PREFERENCES_MODAL_NAME } from '../../components/preferences-modal';
import { store as editPostStore } from '../../store';

export default function useCommonCommands() {
const { openGeneralSidebar, closeGeneralSidebar, switchEditorMode } =
useDispatch( editPostStore );
const {
openGeneralSidebar,
closeGeneralSidebar,
switchEditorMode,
setIsListViewOpened,
} = useDispatch( editPostStore );
const { openModal } = useDispatch( interfaceStore );
const { editorMode, activeSidebar } = useSelect(
( select ) => ( {
activeSidebar: select( interfaceStore ).getActiveComplementaryArea(
editPostStore.name
),
editorMode: select( editPostStore ).getEditorMode(),
} ),
const { editorMode, activeSidebar, isListViewOpen } = useSelect(
( select ) => {
const { getEditorMode, isListViewOpened } = select( editPostStore );
return {
activeSidebar: select(
interfaceStore
).getActiveComplementaryArea( editPostStore.name ),
editorMode: getEditorMode(),
isListViewOpen: isListViewOpened(),
};
},
[]
);
const { toggle } = useDispatch( preferencesStore );
Expand Down Expand Up @@ -85,6 +95,26 @@ export default function useCommonCommands() {
},
} );

useCommand( {
name: 'core/toggle-fullscreen-mode',
label: __( 'Toggle fullscreen mode' ),
icon: desktop,
callback: ( { close } ) => {
toggle( 'core/edit-post', 'fullscreenMode' );
close();
},
} );

useCommand( {
name: 'core/toggle-list-view',
label: __( 'Toggle list view' ),
icon: listView,
callback: ( { close } ) => {
setIsListViewOpened( ! isListViewOpen );
close();
},
} );

useCommand( {
name: 'core/toggle-top-toolbar',
label: __( 'Toggle top toolbar' ),
Expand Down

1 comment on commit 2479dc4

@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 2479dc4.
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/5441778410
📝 Reported issues:

Please sign in to comment.