Skip to content

Commit 3d9e99b

Browse files
authored
Rename parentClientId to rootClientId for consistency (#11274)
We refer to the same concept as rootClientId elsewhere in the application.
1 parent 3600c88 commit 3d9e99b

File tree

4 files changed

+29
-37
lines changed

4 files changed

+29
-37
lines changed

docs/data/data-core-editor.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -1074,17 +1074,13 @@ Post content.
10741074

10751075
### canInsertBlockType
10761076

1077-
Determines if the given block type is allowed to be inserted, and, if
1078-
parentClientId is provided, whether it is allowed to be nested within the
1079-
given parent.
1077+
Determines if the given block type is allowed to be inserted into the block list.
10801078

10811079
*Parameters*
10821080

10831081
* state: Editor state.
1084-
* blockName: The name of the given block type, e.g.
1085-
'core/paragraph'.
1086-
* parentClientId: The parent that the given block is to be
1087-
nested within, or null.
1082+
* blockName: The name of the block type, e.g.' core/paragraph'.
1083+
* rootClientId: Optional root client ID of block list.
10881084

10891085
*Returns*
10901086

@@ -1114,7 +1110,7 @@ Items are returned ordered descendingly by their 'utility' and 'frecency'.
11141110
*Parameters*
11151111

11161112
* state: Editor state.
1117-
* parentClientId: The block we are inserting into, if any.
1113+
* rootClientId: Optional root client ID of block list.
11181114

11191115
*Returns*
11201116

packages/editor/src/components/autocompleters/block.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ function defaultGetBlockInsertionParentClientId() {
2323
/**
2424
* Returns the inserter items for the specified parent block.
2525
*
26-
* @param {string} parentClientId Client ID of the block for which to retrieve
27-
* inserter items.
26+
* @param {string} rootClientId Client ID of the block for which to retrieve
27+
* inserter items.
2828
*
2929
* @return {Array<Editor.InserterItem>} The inserter items for the specified
3030
* parent.
3131
*/
32-
function defaultGetInserterItems( parentClientId ) {
33-
return select( 'core/editor' ).getInserterItems( parentClientId );
32+
function defaultGetInserterItems( rootClientId ) {
33+
return select( 'core/editor' ).getInserterItems( rootClientId );
3434
}
3535

3636
/**

packages/editor/src/components/inner-blocks/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ InnerBlocks = compose( [
128128
getTemplateLock,
129129
} = select( 'core/editor' );
130130
const { clientId } = ownProps;
131-
const parentClientId = getBlockRootClientId( clientId );
131+
const rootClientId = getBlockRootClientId( clientId );
132132
return {
133133
isSelectedBlockInRoot: isBlockSelected( clientId ) || hasSelectedInnerBlock( clientId ),
134134
block: getBlock( clientId ),
135135
blockListSettings: getBlockListSettings( clientId ),
136-
parentLock: getTemplateLock( parentClientId ),
136+
parentLock: getTemplateLock( rootClientId ),
137137
};
138138
} ),
139139
withDispatch( ( dispatch, ownProps ) => {

packages/editor/src/store/selectors.js

+19-23
Original file line numberDiff line numberDiff line change
@@ -1506,20 +1506,16 @@ export const getEditedPostContent = createSelector(
15061506
);
15071507

15081508
/**
1509-
* Determines if the given block type is allowed to be inserted, and, if
1510-
* parentClientId is provided, whether it is allowed to be nested within the
1511-
* given parent.
1509+
* Determines if the given block type is allowed to be inserted into the block list.
15121510
*
1513-
* @param {Object} state Editor state.
1514-
* @param {string} blockName The name of the given block type, e.g.
1515-
* 'core/paragraph'.
1516-
* @param {?string} parentClientId The parent that the given block is to be
1517-
* nested within, or null.
1511+
* @param {Object} state Editor state.
1512+
* @param {string} blockName The name of the block type, e.g.' core/paragraph'.
1513+
* @param {?string} rootClientId Optional root client ID of block list.
15181514
*
15191515
* @return {boolean} Whether the given block type is allowed to be inserted.
15201516
*/
15211517
export const canInsertBlockType = createSelector(
1522-
( state, blockName, parentClientId = null ) => {
1518+
( state, blockName, rootClientId = null ) => {
15231519
const checkAllowList = ( list, item, defaultResult = null ) => {
15241520
if ( isBoolean( list ) ) {
15251521
return list;
@@ -1542,17 +1538,17 @@ export const canInsertBlockType = createSelector(
15421538
return false;
15431539
}
15441540

1545-
const isLocked = !! getTemplateLock( state, parentClientId );
1541+
const isLocked = !! getTemplateLock( state, rootClientId );
15461542
if ( isLocked ) {
15471543
return false;
15481544
}
15491545

1550-
const parentBlockListSettings = getBlockListSettings( state, parentClientId );
1546+
const parentBlockListSettings = getBlockListSettings( state, rootClientId );
15511547
const parentAllowedBlocks = get( parentBlockListSettings, [ 'allowedBlocks' ] );
15521548
const hasParentAllowedBlock = checkAllowList( parentAllowedBlocks, blockName );
15531549

15541550
const blockAllowedParentBlocks = blockType.parent;
1555-
const parentName = getBlockName( state, parentClientId );
1551+
const parentName = getBlockName( state, rootClientId );
15561552
const hasBlockAllowedParent = checkAllowList( blockAllowedParentBlocks, parentName );
15571553

15581554
if ( hasParentAllowedBlock !== null && hasBlockAllowedParent !== null ) {
@@ -1565,9 +1561,9 @@ export const canInsertBlockType = createSelector(
15651561

15661562
return true;
15671563
},
1568-
( state, blockName, parentClientId ) => [
1569-
state.blockListSettings[ parentClientId ],
1570-
state.editor.present.blocksByClientId[ parentClientId ],
1564+
( state, blockName, rootClientId ) => [
1565+
state.blockListSettings[ rootClientId ],
1566+
state.editor.present.blocksByClientId[ rootClientId ],
15711567
state.settings.allowedBlockTypes,
15721568
state.settings.templateLock,
15731569
],
@@ -1607,8 +1603,8 @@ function getInsertUsage( state, id ) {
16071603
*
16081604
* Items are returned ordered descendingly by their 'utility' and 'frecency'.
16091605
*
1610-
* @param {Object} state Editor state.
1611-
* @param {?string} parentClientId The block we are inserting into, if any.
1606+
* @param {Object} state Editor state.
1607+
* @param {?string} rootClientId Optional root client ID of block list.
16121608
*
16131609
* @return {Editor.InserterItem[]} Items that appear in inserter.
16141610
*
@@ -1626,7 +1622,7 @@ function getInsertUsage( state, id ) {
16261622
* @property {number} frecency Hueristic that combines frequency and recency.
16271623
*/
16281624
export const getInserterItems = createSelector(
1629-
( state, parentClientId = null ) => {
1625+
( state, rootClientId = null ) => {
16301626
const calculateUtility = ( category, count, isContextual ) => {
16311627
if ( isContextual ) {
16321628
return INSERTER_UTILITY_HIGH;
@@ -1664,7 +1660,7 @@ export const getInserterItems = createSelector(
16641660
return false;
16651661
}
16661662

1667-
return canInsertBlockType( state, blockType.name, parentClientId );
1663+
return canInsertBlockType( state, blockType.name, rootClientId );
16681664
};
16691665

16701666
const buildBlockTypeInserterItem = ( blockType ) => {
@@ -1694,7 +1690,7 @@ export const getInserterItems = createSelector(
16941690
};
16951691

16961692
const shouldIncludeReusableBlock = ( reusableBlock ) => {
1697-
if ( ! canInsertBlockType( state, 'core/block', parentClientId ) ) {
1693+
if ( ! canInsertBlockType( state, 'core/block', rootClientId ) ) {
16981694
return false;
16991695
}
17001696

@@ -1708,7 +1704,7 @@ export const getInserterItems = createSelector(
17081704
return false;
17091705
}
17101706

1711-
if ( ! canInsertBlockType( state, referencedBlockType.name, parentClientId ) ) {
1707+
if ( ! canInsertBlockType( state, referencedBlockType.name, rootClientId ) ) {
17121708
return false;
17131709
}
17141710

@@ -1753,8 +1749,8 @@ export const getInserterItems = createSelector(
17531749
[ 'desc', 'desc' ]
17541750
);
17551751
},
1756-
( state, parentClientId ) => [
1757-
state.blockListSettings[ parentClientId ],
1752+
( state, rootClientId ) => [
1753+
state.blockListSettings[ rootClientId ],
17581754
state.editor.present.blockOrder,
17591755
state.editor.present.blocksByClientId,
17601756
state.preferences.insertUsage,

0 commit comments

Comments
 (0)