Skip to content

Commit 6944eab

Browse files
committed
feat: change block name to title in dialog
1 parent 3005a03 commit 6944eab

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/welcome/admin.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,16 +377,31 @@ const ToggleBlockDialog = ( {
377377
onConfirm,
378378
onCancel,
379379
} ) => {
380+
const DERIVED_BLOCKS = getAllBlocks()
381+
382+
const getBlockTitle = name => {
383+
for ( const category in DERIVED_BLOCKS ) {
384+
for ( const block of DERIVED_BLOCKS[ category ] ) {
385+
if ( block.name === name ) {
386+
return block.title
387+
}
388+
}
389+
}
390+
return name
391+
}
392+
393+
const blockTitle = getBlockTitle( blockName )
394+
380395
return (
381396
<div className="s-toggle-block-dialog">
382397
<div className="s-toggle-block-dialog-content">
383398
{ isDisabled
384-
? <p>{ __( 'Disabling ' + blockName + ' will also disable the blocks that require it:', i18n ) }</p> // eslint-disable-line @wordpress/i18n-no-variables
385-
: <p>{ __( 'Enabling ' + blockName + ' will also enable its required innerblocks:', i18n ) }</p> // eslint-disable-line @wordpress/i18n-no-variables
399+
? <p>{ __( 'Disabling ' + blockTitle + ' will also disable the blocks that require it:', i18n ) }</p> // eslint-disable-line @wordpress/i18n-no-variables
400+
: <p>{ __( 'Enabling ' + blockTitle + ' will also enable its required innerblocks:', i18n ) }</p> // eslint-disable-line @wordpress/i18n-no-variables
386401
}
387402
<ul>
388403
{ blockList.map( ( block, i ) => (
389-
<li key={ i }>{ block }</li>
404+
<li key={ i }>{ getBlockTitle( block ) }</li>
390405
) ) }
391406
</ul>
392407
{ isDisabled

0 commit comments

Comments
 (0)