Skip to content

Commit

Permalink
updates nomenclature "category" > "tab"
Browse files Browse the repository at this point in the history
update e2e tests
remove `_experimental` Flag for initialTab prop
  • Loading branch information
ramonjd committed Jan 12, 2024
1 parent f995eb3 commit f7f0a92
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 65 deletions.
2 changes: 1 addition & 1 deletion docs/reference-guides/data/data-core-customize-widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ _Parameters_
- _value_ `boolean|Object`: Whether the inserter should be opened (true) or closed (false). To specify an insertion point, use an object.
- _value.rootClientId_ `string`: The root client ID to insert at.
- _value.insertionIndex_ `number`: The index to insert at.
- _value.initialCategory_ `string`: The tab category to display first when the block editor inserter is opened. A category corresponds to one of the tab categories defined in packages/block-editor/src/components/inserter/tabs.js.
- _value.initialTab_ `string`: The id of the tab to display first when the block editor inserter is opened. A category corresponds to one of the tab ids defined in packages/block-editor/src/components/inserter/tabs.js.

_Returns_

Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/data/data-core-edit-widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ _Parameters_
- _value_ `boolean|Object`: Whether the inserter should be opened (true) or closed (false). To specify an insertion point, use an object.
- _value.rootClientId_ `string`: The root client ID to insert at.
- _value.insertionIndex_ `number`: The index to insert at.
- _value.initialCategory_ `string`: The tab category to display first when the block editor inserter is opened. A category corresponds to one of the tab categories defined in packages/block-editor/src/components/inserter/tabs.js.
- _value.initialTab_ `string`: The id of the tab to display first when the block editor inserter is opened. A category corresponds to one of the tab ids defined in packages/block-editor/src/components/inserter/tabs.js.

_Returns_

Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/data/data-core-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ _Parameters_
- _value_ `boolean|Object`: Whether the inserter should be opened (true) or closed (false). To specify an insertion point, use an object.
- _value.rootClientId_ `string`: The root client ID to insert at.
- _value.insertionIndex_ `number`: The index to insert at.
- _value.initialCategory_ `string`: The tab category to display first when the block editor inserter is opened. A category corresponds to one of the tab categories defined in packages/block-editor/src/components/inserter/tabs.js.
- _value.initialTab_ `string`: The id of the tab to display first when the block editor inserter is opened. A category corresponds to one of the tab ids defined in packages/block-editor/src/components/inserter/tabs.js.

_Returns_

Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/inserter/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function InserterLibrary(
showMostUsedBlocks = false,
__experimentalInsertionIndex,
__experimentalFilterValue,
__experimentalInitialCategory,
initialInserterTab,
onSelect = noop,
shouldFocusBlock = false,
},
Expand All @@ -47,7 +47,7 @@ function InserterLibrary(
isAppender={ isAppender }
showInserterHelpPanel={ showInserterHelpPanel }
showMostUsedBlocks={ showMostUsedBlocks }
__experimentalInitialCategory={ __experimentalInitialCategory }
initialInserterTab={ initialInserterTab }
__experimentalInsertionIndex={ __experimentalInsertionIndex }
__experimentalFilterValue={ __experimentalFilterValue }
shouldFocusBlock={ shouldFocusBlock }
Expand Down
6 changes: 3 additions & 3 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function InserterMenu(
showMostUsedBlocks,
__experimentalFilterValue = '',
shouldFocusBlock = true,
__experimentalInitialCategory,
initialInserterTab,
},
ref
) {
Expand All @@ -58,7 +58,7 @@ function InserterMenu(
const [ selectedMediaCategory, setSelectedMediaCategory ] =
useState( null );
const [ selectedTab, setSelectedTab ] = useState(
__experimentalInitialCategory || null
initialInserterTab || null
);
const [ destinationRootClientId, onInsertBlocks, onToggleInsertionPoint ] =
useInsertionPoint( {
Expand Down Expand Up @@ -261,7 +261,7 @@ function InserterMenu(
showMedia={ showMedia }
onSelect={ handleSetSelectedTab }
tabsContents={ inserterTabsContents }
initialTabId={ __experimentalInitialCategory }
initialTabId={ initialInserterTab }
/>
) }
{ ! delayedFilterValue && ! showAsTabs && (
Expand Down
27 changes: 7 additions & 20 deletions packages/block-library/src/post-content/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ import {
Warning,
store as blockEditorStore,
} from '@wordpress/block-editor';
import {
useEntityProp,
useEntityBlockEditor,
store as coreStore,
} from '@wordpress/core-data';
import { useEntityProp, useEntityBlockEditor } from '@wordpress/core-data';
import { useSelect, useDispatch } from '@wordpress/data';
import { Placeholder, Button } from '@wordpress/components';
import { postContent as icon } from '@wordpress/icons';
Expand Down Expand Up @@ -105,23 +101,14 @@ function EditableContent( { context = {}, clientId } ) {
{ id: postId }
);

const { entityRecord, setInserterIsOpened } = useSelect(
( select ) => {
return {
entityRecord: select( coreStore ).getEntityRecord(
'postType',
postType,
postId
),
setInserterIsOpened:
select( blockEditorStore ).getSettings()
.__experimentalSetIsInserterOpened,
};
},
const setInserterIsOpened = useSelect(
( select ) =>
select( blockEditorStore ).getSettings()
.__experimentalSetIsInserterOpened,
[ postType, postId ]
);

const hasInnerBlocks = !! entityRecord?.content?.raw || blocks?.length;
const hasInnerBlocks = blocks?.length;

const { children, ...props } = useInnerBlocksProps(
useBlockProps( {
Expand All @@ -144,7 +131,7 @@ function EditableContent( { context = {}, clientId } ) {

const openInserter = () => {
setInserterIsOpened( {
initialCategory: 'patterns',
initialTab: 'patterns',
rootClientId: clientId,
insertionIndex: 0,
} );
Expand Down
16 changes: 8 additions & 8 deletions packages/customize-widgets/src/store/actions.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* Returns an action object used to open/close the inserter.
*
* @param {boolean|Object} value Whether the inserter should be
* opened (true) or closed (false).
* To specify an insertion point,
* use an object.
* @param {string} value.rootClientId The root client ID to insert at.
* @param {number} value.insertionIndex The index to insert at.
* @param {string} value.initialCategory The tab category to display first when the block editor inserter is opened.
* A category corresponds to one of the tab categories defined in packages/block-editor/src/components/inserter/tabs.js.
* @param {boolean|Object} value Whether the inserter should be
* opened (true) or closed (false).
* To specify an insertion point,
* use an object.
* @param {string} value.rootClientId The root client ID to insert at.
* @param {number} value.insertionIndex The index to insert at.
* @param {string} value.initialTab The id of the tab to display first when the block editor inserter is opened.
* A category corresponds to one of the tab ids defined in packages/block-editor/src/components/inserter/tabs.js.
*
* @example
* ```js
Expand Down
16 changes: 8 additions & 8 deletions packages/edit-widgets/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,14 @@ export function setIsWidgetAreaOpen( clientId, isOpen ) {
/**
* Returns an action object used to open/close the inserter.
*
* @param {boolean|Object} value Whether the inserter should be
* opened (true) or closed (false).
* To specify an insertion point,
* use an object.
* @param {string} value.rootClientId The root client ID to insert at.
* @param {number} value.insertionIndex The index to insert at.
* @param {string} value.initialCategory The tab category to display first when the block editor inserter is opened.
* A category corresponds to one of the tab categories defined in packages/block-editor/src/components/inserter/tabs.js.
* @param {boolean|Object} value Whether the inserter should be
* opened (true) or closed (false).
* To specify an insertion point,
* use an object.
* @param {string} value.rootClientId The root client ID to insert at.
* @param {number} value.insertionIndex The index to insert at.
* @param {string} value.initialTab The id of the tab to display first when the block editor inserter is opened.
* A category corresponds to one of the tab ids defined in packages/block-editor/src/components/inserter/tabs.js.
*
* @return {Object} Action object.
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/editor/src/components/inserter-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import { unlock } from '../../lock-unlock';
import { store as editorStore } from '../../store';

export default function InserterSidebar() {
const { insertionPoint, inserterInitialCategory, showMostUsedBlocks } =
const { insertionPoint, initialInserterTab, showMostUsedBlocks } =
useSelect( ( select ) => {
const { getInsertionPoint, getInserterInitialCategory } = unlock(
const { getInsertionPoint, getInserterInitialTab } = unlock(
select( editorStore )
);
const { get } = select( preferencesStore );
return {
insertionPoint: getInsertionPoint(),
inserterInitialCategory: getInserterInitialCategory(),
initialInserterTab: getInserterInitialTab(),
showMostUsedBlocks: get( 'core', 'mostUsedBlocks' ),
};
}, [] );
Expand Down Expand Up @@ -68,7 +68,7 @@ export default function InserterSidebar() {
__experimentalInsertionIndex={
insertionPoint.insertionIndex
}
__experimentalInitialCategory={ inserterInitialCategory }
initialInserterTab={ initialInserterTab }
__experimentalFilterValue={ insertionPoint.filterValue }
ref={ libraryRef }
/>
Expand Down
16 changes: 8 additions & 8 deletions packages/editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,14 +691,14 @@ export function removeEditorPanel( panelName ) {
/**
* Returns an action object used to open/close the inserter.
*
* @param {boolean|Object} value Whether the inserter should be
* opened (true) or closed (false).
* To specify an insertion point,
* use an object.
* @param {string} value.rootClientId The root client ID to insert at.
* @param {number} value.insertionIndex The index to insert at.
* @param {string} value.initialCategory The tab category to display first when the block editor inserter is opened.
* A category corresponds to one of the tab categories defined in packages/block-editor/src/components/inserter/tabs.js.
* @param {boolean|Object} value Whether the inserter should be
* opened (true) or closed (false).
* To specify an insertion point,
* use an object.
* @param {string} value.rootClientId The root client ID to insert at.
* @param {number} value.insertionIndex The index to insert at.
* @param {string} value.initialTab The id of the tab to display first when the block editor inserter is opened.
* A category corresponds to one of the tab ids defined in packages/block-editor/src/components/inserter/tabs.js.
*
* @return {Object} Action object.
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ export const getInsertionPoint = createRegistrySelector(
);

/**
* Get the initial category for the inserter.
* A category corresponds to one of the tab categories defined in packages/block-editor/src/components/inserter/tabs.js.
* Get the initial tab id for the inserter.
* A category corresponds to one of the tab ids defined in packages/block-editor/src/components/inserter/tabs.js.
*
* @param {Object} state Global application state.
*
* @return {string} The initial tab category to open when the inserter is opened.
*/
export const getInserterInitialCategory = createRegistrySelector(
export const getInserterInitialTab = createRegistrySelector(
() => ( state ) =>
typeof state.blockInserterPanel === 'object'
? state.blockInserterPanel?.initialCategory
? state.blockInserterPanel?.initialTab
: null
);

Expand Down
8 changes: 3 additions & 5 deletions test/e2e/specs/site-editor/pages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ async function addPageContent( editor, page ) {
.getByRole( 'document', {
name: 'Block: Content',
} )
.getByRole( 'document', {
name: 'Empty block; start writing or type forward slash to choose a block',
.getByRole( 'button', {
name: 'Start blank',
} )
.click();

Expand Down Expand Up @@ -124,9 +124,7 @@ test.describe( 'Pages', () => {
editor.canvas.getByRole( 'document', {
name: 'Block: Content',
} )
).toContainText(
'This is the Content block, it will display all the blocks in any single post or page.'
);
).toContainText( 'This block will be replaced with your content.' );
await expect(
page.locator(
'role=button[name="Dismiss this notice"i] >> text="Editing template. Changes made here affect all posts and pages that use the template."'
Expand Down

0 comments on commit f7f0a92

Please sign in to comment.