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

Settings: Show message when Visual or Code editor are disabled #52737

Merged
merged 11 commits into from
Jul 31, 2023
22 changes: 19 additions & 3 deletions packages/edit-post/src/components/header/mode-switcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { MenuItemsChoice, MenuGroup } from '@wordpress/components';
import { MenuItemsChoice, MenuGroup, Notice } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
import { store as editorStore } from '@wordpress/editor';
Expand Down Expand Up @@ -55,8 +55,24 @@ function ModeSwitcher() {
return null;
}

if ( ! isRichEditingEnabled || ! isCodeEditingEnabled ) {
return null;
if ( ! isRichEditingEnabled ) {
return (
<MenuGroup label={ __( 'Editor' ) }>
<Notice isDismissible={ false }>
danielbachhuber marked this conversation as resolved.
Show resolved Hide resolved
{ __( 'Visual editor is disabled.' ) }
</Notice>
</MenuGroup>
);
}

if ( ! isCodeEditingEnabled ) {
return (
<MenuGroup label={ __( 'Editor' ) }>
<Notice isDismissible={ false }>
{ __( 'Code editor is disabled.' ) }
</Notice>
</MenuGroup>
);
}

const choices = MODES.map( ( choice ) => {
Expand Down
Loading