Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
Added `showBlockBreadcrumbs` feature to the more menu in the Widgets Editor.
Importing it into the Widgets interface, but waiting on WordPress#32498 to merge before final integration.
  • Loading branch information
ramonjd committed Jun 11, 2021
1 parent 10c3200 commit a950a79
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
9 changes: 8 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
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
2 changes: 1 addition & 1 deletion packages/edit-widgets/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,5 @@ export const canInsertBlockInWidgetArea = createRegistrySelector(
* @return {boolean} Is active.
*/
export function __unstableIsFeatureActive( state, feature ) {
return get( state.preferences.features, [ feature ], false );
return get( state.preferences, [ 'features', feature ], false );
}
36 changes: 36 additions & 0 deletions packages/edit-widgets/src/store/test/selectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* 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 );
} );

it( 'should return false where the state is empty', () => {
const state = {};
expect(
__unstableIsFeatureActive( state, 'didILeaveTheOvenOn' )
).toBe( false );
} );
} );
} );

0 comments on commit a950a79

Please sign in to comment.