Skip to content

Commit

Permalink
Enable native editor onboarding features globally (#35201)
Browse files Browse the repository at this point in the history
* Enable new block badge globally

We decided to enable the new block badge for all users.

* Update release notes

* Fix block inserter unit test

Now that block impressions are enabled for all users, we must update the
test expectation to include the `isNew` property set by
`useBlockTypeImpression`. An alternative would be to update this test to
not explicitly check the component prop, but the rendered result which
the user can see.

* Remove editor onboarding bridging methods

The bridging methods are no longer necessary now that we display editor
onboarding features for all users.

* Remove help support articles from release notes

This feature was delivered in a previous release via a beta fix.

* Remove first block editor session flag

* Remove unnecessary trailing comma

* Relocate native-specific fixture setup

Place fixture setup in fixture file rather than within test file.
  • Loading branch information
dcalhoun authored Oct 25, 2021
1 parent cec3b9b commit e6c91b9
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,22 @@ import { setBlockTypeImpressions } from '@wordpress/react-native-bridge';
import { store as blockEditorStore } from '../../../store';

function useBlockTypeImpressions( blockTypes ) {
const { blockTypeImpressions, enableEditorOnboarding } = useSelect(
( select ) => {
const { getSettings: getBlockEditorSettings } = select(
blockEditorStore
);
const { editorOnboarding, impressions } = getBlockEditorSettings();

return {
blockTypeImpressions: impressions,
enableEditorOnboarding: editorOnboarding,
};
},
[]
);
const { blockTypeImpressions } = useSelect( ( select ) => {
const { getSettings: getBlockEditorSettings } = select(
blockEditorStore
);
const { impressions } = getBlockEditorSettings();

return {
blockTypeImpressions: impressions,
};
}, [] );
const { updateSettings } = useDispatch( blockEditorStore );

const items = enableEditorOnboarding
? blockTypes.map( ( blockType ) => ( {
...blockType,
isNew: blockTypeImpressions[ blockType.name ] > 0,
} ) )
: blockTypes;

const items = blockTypes.map( ( blockType ) => ( {
...blockType,
isNew: blockTypeImpressions[ blockType.name ] > 0,
} ) );
const trackBlockTypeSelected = ( { name } ) => {
if ( blockTypeImpressions[ name ] > 0 ) {
const updatedBlockTypeImpressions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const selectMock = {
canInsertBlockType: jest.fn(),
getBlockType: jest.fn(),
getClipboard: jest.fn(),
getSettings: jest.fn( () => ( {} ) ),
getSettings: jest.fn( () => ( { impressions: {} } ) ),
};

describe( 'BlockTypesTab component', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Internal dependencies
*/
import fixtures from './index.js';

export * from './index';

export default fixtures.map( ( filteredItems ) => ( {
...filteredItems,
// Set `isNew` property expected from block type impressions
isNew: false,
} ) );
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ data class GutenbergProps @JvmOverloads constructor(
val editorTheme: Bundle?,
val translations: Bundle,
val isDarkMode: Boolean,
val htmlModeEnabled: Boolean,
val enableEditorOnboarding: Boolean,
var firstGutenbergEditorSession: Boolean
val htmlModeEnabled: Boolean
) {

fun getInitialProps(bundle: Bundle?) = (bundle ?: Bundle()).apply {
Expand Down Expand Up @@ -62,8 +60,6 @@ data class GutenbergProps @JvmOverloads constructor(
putBoolean(PROP_CAPABILITIES_CAN_ENABLE_UNSUPPORTED_BLOCK_EDITOR, canEnableUnsupportedBlockEditor)
putBoolean(PROP_CAPABILITIES_IS_AUDIO_BLOCK_MEDIA_UPLOAD_ENABLED, isAudioBlockMediaUploadEnabled)
putBoolean(PROP_CAPABILITIES_REUSABLE_BLOCK, enableReusableBlock)
putBoolean(PROP_CAPABILITIES_EDITOR_ONBOARDING, enableEditorOnboarding)
putBoolean(PROP_CAPABILITIES_FIRST_GUTENBERG_SESSION, firstGutenbergEditorSession)
putBoolean(PROP_CAPABILITIES_FACEBOOK_EMBED_BLOCK, enableFacebookEmbed)
putBoolean(PROP_CAPABILITIES_INSTAGRAM_EMBED_BLOCK, enableInstagramEmbed)
putBoolean(PROP_CAPABILITIES_LOOM_EMBED_BLOCK, enableLoomEmbed)
Expand Down Expand Up @@ -106,7 +102,5 @@ data class GutenbergProps @JvmOverloads constructor(
const val PROP_CAPABILITIES_CAN_ENABLE_UNSUPPORTED_BLOCK_EDITOR = "canEnableUnsupportedBlockEditor"
const val PROP_CAPABILITIES_IS_AUDIO_BLOCK_MEDIA_UPLOAD_ENABLED = "isAudioBlockMediaUploadEnabled"
const val PROP_CAPABILITIES_REUSABLE_BLOCK = "reusableBlock"
const val PROP_CAPABILITIES_EDITOR_ONBOARDING = "editorOnboarding"
const val PROP_CAPABILITIES_FIRST_GUTENBERG_SESSION = "firstGutenbergEditorSession"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public enum Capabilities: String {
case canEnableUnsupportedBlockEditor
case isAudioBlockMediaUploadEnabled
case reusableBlock
case editorOnboarding
case firstGutenbergEditorSession
case facebookEmbed
case instagramEmbed
case loomEmbed
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ For each user feature we should also add a importance categorization label to i
## Unreleased
- [**] Search block - Text and background color support [#35511]
- [*] [Embed Block] Fix loading glitch with resolver resolution approach [#35798]
- [**] Block inserter indicates newly available block types [#35201]

## 1.64.1
- [**] Fix updating the block list after block removal [#35721]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ protected Bundle getLaunchOptions() {
capabilities.putBoolean(GutenbergProps.PROP_CAPABILITIES_UNSUPPORTED_BLOCK_EDITOR, true);
capabilities.putBoolean(GutenbergProps.PROP_CAPABILITIES_REUSABLE_BLOCK, false);
capabilities.putBoolean(GutenbergProps.PROP_CAPABILITIES_IS_AUDIO_BLOCK_MEDIA_UPLOAD_ENABLED, true);
capabilities.putBoolean(GutenbergProps.PROP_CAPABILITIES_EDITOR_ONBOARDING, false);
capabilities.putBoolean(GutenbergProps.PROP_CAPABILITIES_FIRST_GUTENBERG_SESSION, false);
capabilities.putBoolean(GutenbergProps.PROP_CAPABILITIES_FACEBOOK_EMBED_BLOCK, true);
capabilities.putBoolean(GutenbergProps.PROP_CAPABILITIES_INSTAGRAM_EMBED_BLOCK, true);
capabilities.putBoolean(GutenbergProps.PROP_CAPABILITIES_LOOM_EMBED_BLOCK, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,6 @@ extension GutenbergViewController: GutenbergBridgeDataSource {
.mediaFilesCollectionBlock: true,
.isAudioBlockMediaUploadEnabled: true,
.reusableBlock: false,
.editorOnboarding: false,
.firstGutenbergEditorSession: false,
.facebookEmbed: true,
.instagramEmbed: true,
.loomEmbed: true,
Expand Down

0 comments on commit e6c91b9

Please sign in to comment.