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

Widgets Editor: add show block bread crumbs feature toggle to more menu #32569

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
10 changes: 9 additions & 1 deletion packages/edit-widgets/src/components/layout/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,19 @@ function Interface( { blockEditorSettings } ) {
);
const { rootClientId, insertionIndex } = useWidgetLibraryInsertionPoint();

const { hasSidebarEnabled, isInserterOpened } = useSelect(
const {
hasBlockBreadCrumbsEnabled,
hasSidebarEnabled,
isInserterOpened,
} = useSelect(
( select ) => ( {
hasSidebarEnabled: !! select(
interfaceStore
).getActiveComplementaryArea( editWidgetsStore.name ),
isInserterOpened: !! select( editWidgetsStore ).isInserterOpened(),
hasBlockBreadCrumbsEnabled: select(
editWidgetsStore
).__unstableIsFeatureActive( 'showBlockBreadcrumbs' ),
} ),
[]
);
Expand Down Expand Up @@ -113,6 +120,7 @@ function Interface( { blockEditorSettings } ) {
/>
}
footer={
hasBlockBreadCrumbsEnabled &&
! isMobileViewport && (
<div className="edit-widgets-layout__footer">
<BlockBreadcrumb rootLabelText={ __( 'Widgets' ) } />
Expand Down
13 changes: 13 additions & 0 deletions packages/edit-widgets/src/components/more-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ export default function MoreMenu() {
'Contain text cursor inside block deactivated'
) }
/>
<FeatureToggle
feature="showBlockBreadcrumbs"
label={ __( 'Display block breadcrumbs' ) }
info={ __(
'Shows block breadcrumbs at the bottom of the editor.'
) }
messageActivated={ __(
'Display block breadcrumbs activated'
) }
messageDeactivated={ __(
'Display block breadcrumbs deactivated'
) }
/>
</MenuGroup>
</>
) }
Expand Down
1 change: 1 addition & 0 deletions packages/edit-widgets/src/store/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export const PREFERENCES_DEFAULTS = {
features: {
fixedToolbar: false,
welcomeGuide: true,
showBlockBreadcrumbs: true,
},
};
29 changes: 29 additions & 0 deletions packages/edit-widgets/src/store/test/selectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Internal dependencies
*/

import { __unstableIsFeatureActive } from '../selectors';

describe( 'selectors', () => {
describe( '__unstableIsFeatureActive', () => {
it( 'should return the feature value when present', () => {
const state = {
preferences: {
features: { isNightVisionActivated: true },
},
};
expect(
__unstableIsFeatureActive( state, 'isNightVisionActivated' )
).toBe( true );
} );

it( 'should return false where feature is not found', () => {
const state = {
preferences: {},
};
expect(
__unstableIsFeatureActive( state, 'didILeaveTheOvenOn' )
).toBe( false );
} );
} );
} );