Skip to content

Commit

Permalink
Widgets Editor: add show block bread crumbs feature toggle to more me…
Browse files Browse the repository at this point in the history
…nu (#32569)
  • Loading branch information
ramonjd authored and youknowriad committed Jun 14, 2021
1 parent ba70233 commit 74104af
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
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 );
} );
} );
} );

0 comments on commit 74104af

Please sign in to comment.