Repository navigation
Overwrite Missing block UI Text #2610
Changes from all commits
0839f3b
95a79a4
f3fb203
ade5c36
abcb7a4
d1f6d44
4263473
dc7e710
722eaae
080938c
6aa0607
841df27
f004c91
130d21f
ee7f083
05aa58e
418df0a
a51a33d
8c575fe
08cab76
6529f3c
577a023
8df9f34
29b8f20
9b7b2eb
0545492
433db5d
2217b1c
cdb0675
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { addStrings } from '@wordpress/components'; | ||
| import { select } from '@wordpress/data'; | ||
| import { __ } from '@wordpress/i18n'; | ||
|
|
||
| export const uiStrings = () => { | ||
| const { getSettings } = select( 'core/block-editor' ); | ||
| const unsupportedBlockEditor = { | ||
| supported: | ||
| getSettings( 'capabilities' ).unsupportedBlockEditor === true, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just asking out of curiosity. We have a lot of explicit bool checks in this file (i.e., Just asking because I tend to use the |
||
| switchable: | ||
| getSettings( 'capabilities' ).canEnableUnsupportedBlockEditor === | ||
| true, | ||
| }; | ||
|
|
||
| let unsupportedBlocksExplanation; | ||
|
|
||
| if ( | ||
| unsupportedBlockEditor.supported === false && | ||
| unsupportedBlockEditor.switchable | ||
| ) { | ||
| unsupportedBlocksExplanation = __( | ||
| 'You can edit this block using the web version of the editor.' | ||
| ); | ||
| const note = __( | ||
| 'Note: You must allow WordPress.com login to edit this block in the mobile editor.' | ||
| ); | ||
| unsupportedBlocksExplanation = | ||
| unsupportedBlocksExplanation + '\n\n' + note; // Translations can not have characters like '\n', so we add the new lines manually. | ||
| } else if ( unsupportedBlockEditor.supported === true ) { | ||
| unsupportedBlocksExplanation = __( | ||
| 'You can edit this block using the web version of the editor.' | ||
| ); | ||
| } else { | ||
| unsupportedBlocksExplanation = undefined; // Show default text. | ||
| } | ||
|
|
||
| const shouldOverwriteButtonTitle = | ||
| unsupportedBlockEditor.supported === false && | ||
| unsupportedBlockEditor.switchable; | ||
| const unsupportedBlocksButton = shouldOverwriteButtonTitle | ||
| ? __( 'Open Jetpack Security settings' ) | ||
| : undefined; | ||
|
Comment on lines
+43
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: It seems like instead of using the extra
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would make us declare Would you say something like this? let unsupportedBlocksButtonTitle = undefined;
if ( unsupportedBlockEditor.supported === false && unsupportedBlockEditor.switchable ) {
unsupportedBlocksButtonTitle = __( 'Open Jetpack Security settings' );
}
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I think I had something like that in mind. |
||
|
|
||
| return { | ||
| 'missing-block-detail': unsupportedBlocksExplanation, | ||
| 'missing-block-action-button': unsupportedBlocksButton, | ||
| }; | ||
| }; | ||
|
|
||
| addStrings( uiStrings ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: I would expect that, given its name, addStrings would accept a list of strings as parameter. The fact that it accepts a function returning a mapping of (string id, string value) makes it a bit hard to grasp imo. |
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: I think just using 2 variables instead of grouping them in an object is just simpler and easier to understand, especially since you're assigning an
unsupportedBlockEditorto asupportedproperty