Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable native editor onboarding features globally #35201

Merged
merged 9 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 All @@ -48,10 +48,14 @@ describe( 'BlockTypesTab component', () => {
it( 'shows block items', () => {
selectMock.getInserterItems.mockReturnValue( items );

const blockItems = items.filter(
( { id, category } ) =>
category !== 'reusable' && id !== 'core-embed/a-paragraph-embed'
);
const blockItems = items
.filter(
( { id, category } ) =>
category !== 'reusable' &&
id !== 'core-embed/a-paragraph-embed'
)
// Set `isNew` property expected from block type impressions
.map( ( filteredItems ) => ( { ...filteredItems, isNew: false } ) );
dcalhoun marked this conversation as resolved.
Show resolved Hide resolved
const component = shallow(
<BlockTypesTab
rootClientId={ 0 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ data class GutenbergProps @JvmOverloads constructor(
val translations: Bundle,
val isDarkMode: Boolean,
val htmlModeEnabled: Boolean,
val enableEditorOnboarding: Boolean,
var firstGutenbergEditorSession: Boolean
dcalhoun marked this conversation as resolved.
Show resolved Hide resolved
) {

Expand Down Expand Up @@ -58,7 +57,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)
}

Expand Down Expand Up @@ -94,7 +92,6 @@ 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,7 +25,6 @@ public enum Capabilities: String {
case canEnableUnsupportedBlockEditor
case isAudioBlockMediaUploadEnabled
case reusableBlock
case editorOnboarding
case firstGutenbergEditorSession
}

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
- [**] [Embed block] Add the top 5 specific embed blocks to the Block inserter list [#34967]
- [*] [Embed block] Fix inline preview cut-off when editing URL [#35321]
- [**] Block inserter indicates newly available block types [#35201]

1.62.2
------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +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);
bundle.putBundle(GutenbergProps.PROP_CAPABILITIES, capabilities);
return bundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ extension GutenbergViewController: GutenbergBridgeDataSource {
.mediaFilesCollectionBlock: true,
.isAudioBlockMediaUploadEnabled: true,
.reusableBlock: false,
.editorOnboarding: false,
.firstGutenbergEditorSession: false,
]
}
Expand Down