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

SPT: Handle NUX deprecation #38611

Merged
merged 3 commits into from
Dec 30, 2019
Merged
Changes from 1 commit
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 @@ -93,6 +93,11 @@ class PageTemplateModal extends Component {
if ( ! prevState.isOpen && this.state.isOpen ) {
trackView( this.props.segment.id, this.props.vertical.id );
}

// Disable welcome guide right away as it collides with the modal window.
if ( this.props.isWelcomeGuideActive || this.props.areTipsEnabled ) {
this.props.hideWelcomeGuide();
}
}

static getDefaultSelectedTemplate = props => {
Expand Down Expand Up @@ -364,19 +369,13 @@ export const PageTemplatesPlugin = compose(
postContentBlock: select( 'core/editor' )
.getBlocks()
.find( block => block.name === 'a8c/post-content' ),
isWelcomeGuideActive: select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ),
isWelcomeGuideActive: select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ), // Gutenberg 7.2.0 and higher
areTipsEnabled: select( 'core/nux' ).areTipsEnabled
Copons marked this conversation as resolved.
Show resolved Hide resolved
? select( 'core/nux' ).areTipsEnabled()
: false, // Gutenberg 7.1.0 and lower
};
} ),
withDispatch( ( dispatch, ownProps ) => {
// Disable welcome guide right away as it collides with the modal window.
if ( ownProps.isWelcomeGuideActive ) {
// Gutenberg 7.1.0 or higher.
dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' );
} else if ( dispatch( 'core/nux' ).disableTips ) {
// Gutenberg 7.0.0 or lower.
dispatch( 'core/nux' ).disableTips();
}

const editorDispatcher = dispatch( 'core/editor' );
return {
saveTemplateChoice: slug => {
Expand All @@ -403,6 +402,15 @@ export const PageTemplatesPlugin = compose(
false
);
},
hideWelcomeGuide: () => {
if ( ownProps.isWelcomeGuideActive ) {
// Gutenberg 7.2.0 or higher.
dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' );
} else if ( ownProps.areTipsEnabled ) {
// Gutenberg 7.1.0 or lower.
dispatch( 'core/nux' ).disableTips();
}
},
};
} )
)( PageTemplateModal );