Skip to content

Commit c983169

Browse files
committed
Merge remote-tracking branch 'origin/master' into feature/color-refresh-2019
* origin/master: change "expert" to "support" in page route and title (#29459) Add note to concierge upsell page about sessions only being offered in English. (#29461) Jetpack Blocks: Fix webpack warnings due to dynamic import (#29509) Gutenberg: Reset core resolvers on site change (#29445) Signup: Remove Masterbar from Signup (#28886) Fix missing bumpStat call (#29504) Gutenberg Jetpack Preset: Generate imports dynamically from index.json (#29435) Fix the clean:public script to do a better job cleaning public/ folder (#29354) Tiled gallery: Add alignWide support (#29493) Tiled Gallery: Add noResize to block save (#29496) Show G Suite user fields by default (#29458) ColorThemes: Add GA and bumpStat events for scheme picking (#29413) Remove legacy mock for extensions reducer (#29397) Antispam promo card: tweak copy to make it clearer (#29440) prevent 0 as street number for ebanx checkouts (#29487) Gutenberg: Update Related Posts to use the posts endpoint (#29439) remove override on payment methods name in India (#29406) Add a space to separate "the" from the holiday name placeholder. (#29479) Revert "Migrate my-sites/sharing to webpack css pipeline (#28607)" (#29463) Gutenpack Subscription Block (Take two) (#28887)
2 parents f3fe15e + 8343349 commit c983169

File tree

59 files changed

+686
-389
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+686
-389
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ test-results*.xml
3232
/public/*.js.map
3333
/public/*.css
3434
/public/*.css.map
35+
/public/vendors~*
3536
/public/sections/*
3637
/public/sections-rtl/*
38+
/public/images/*.gif
39+
/public/images/*.jpg
40+
/public/images/*.png
3741
/public/images/*.svg
3842
/server/devdocs/search-index.js
3943
/server/devdocs/components-usage-stats.json

assets/stylesheets/_components.scss

+4-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@
179179
@import 'components/select-dropdown/style';
180180
@import 'components/seo/style';
181181
@import 'blocks/upgrade-nudge-expanded/style';
182-
@import 'components/seo/preview-upgrade-nudge/style';
183182
@import 'components/signup-site-title/style';
184183
@import 'components/site-selector/style';
185184
@import 'components/site-title-example/style';
@@ -354,6 +353,10 @@
354353
@import 'my-sites/plugins/plugins-browser-item/style';
355354
@import 'my-sites/plugins/plugins-browser-list/style';
356355
@import 'my-sites/plugins/plugins-browser/style';
356+
@import 'my-sites/sharing/style';
357+
@import 'my-sites/sharing/connections/account-dialog.scss';
358+
@import 'my-sites/sharing/connections/account-dialog-account.scss';
359+
@import 'my-sites/sharing/connections/services-group.scss';
357360
@import 'my-sites/sidebar/style';
358361
@import 'my-sites/sidebar-navigation/style';
359362
@import 'my-sites/site-indicator/style';

assets/stylesheets/shared/_extends-forms.scss

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// SASS placeholder selectors for form styles
1+
/**
2+
* SASS placeholder selectors for form styles
3+
*
4+
* @format
5+
*/
26

37
%form {
48
ul {

client/blocks/inline-help/style.scss

+9
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,15 @@
240240
}
241241
}
242242

243+
// Hide extraneous UI inside secondary view
244+
.is-secondary-view-active {
245+
.checklist-navigation,
246+
.inline-help__gutenberg-editor-toggle,
247+
.inline-help__classic-editor-toggle {
248+
display: none;
249+
}
250+
}
251+
243252
.inline-help__view-heading {
244253
display: block;
245254
font-size: 14px;

client/components/seo/preview-upgrade-nudge/index.jsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ import Banner from 'components/banner';
2222
import { findFirstSimilarPlanKey } from 'lib/plans';
2323
import { TERM_ANNUALLY, TYPE_BUSINESS } from 'lib/plans/constants';
2424

25+
/**
26+
* Style dependencies
27+
*/
28+
import './style.scss';
29+
import upgradeNudgeImage from './preview-upgrade-nudge.png';
30+
2531
export const SeoPreviewNudge = ( { translate, site, isJetpack = false } ) => {
2632
return (
2733
<div className="preview-upgrade-nudge">
@@ -43,7 +49,7 @@ export const SeoPreviewNudge = ( { translate, site, isJetpack = false } ) => {
4349

4450
<div className="preview-upgrade-nudge__features">
4551
<FeatureExample>
46-
<img src="/calypso/images/advanced-seo-nudge.png" />
52+
<img src={ upgradeNudgeImage } alt="" />
4753
</FeatureExample>
4854
<div className="preview-upgrade-nudge__features-details">
4955
<ul className="preview-upgrade-nudge__features-list">

client/components/upgrades/google-apps/google-apps-dialog/index.jsx

+7-35
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
import PropTypes from 'prop-types';
88
import React from 'react';
9-
import TransitionGroup from 'react-transition-group/TransitionGroup';
10-
import CSSTransition from 'react-transition-group/CSSTransition';
119
import { localize } from 'i18n-calypso';
1210
import { connect } from 'react-redux';
1311
import { get } from 'lodash';
@@ -43,7 +41,6 @@ class GoogleAppsDialog extends React.Component {
4341
};
4442

4543
state = {
46-
isAddingEmail: false,
4744
users: null,
4845
validationErrors: null,
4946
};
@@ -85,13 +82,7 @@ class GoogleAppsDialog extends React.Component {
8582
<CompactCard>{ this.header() }</CompactCard>
8683
<CompactCard>
8784
<GoogleAppsProductDetails domain={ this.props.domain } { ...prices } />
88-
<TransitionGroup>
89-
{ this.state.isAddingEmail && (
90-
<CSSTransition classNames="google-apps-dialog__users" timeout={ 200 }>
91-
{ this.renderGoogleAppsUsers() }
92-
</CSSTransition>
93-
) }
94-
</TransitionGroup>
85+
{ this.renderGoogleAppsUsers() }
9586
</CompactCard>
9687
<CompactCard>{ this.footer() }</CompactCard>
9788
</form>
@@ -139,42 +130,23 @@ class GoogleAppsDialog extends React.Component {
139130

140131
footer() {
141132
const { translate } = this.props;
142-
const continueButtonHandler = this.state.isAddingEmail
143-
? this.handleFormSubmit
144-
: this.handleAddEmail;
145-
const continueButtonText = this.state.isAddingEmail
146-
? translate( 'Continue \u00BB' )
147-
: translate( 'Yes, Add Email \u00BB' );
148-
149133
return (
150134
<footer className="google-apps-dialog__footer">
151-
{ ! this.state.isAddingEmail && (
152-
<Button
153-
className="google-apps-dialog__checkout-button"
154-
onClick={ this.handleFormCheckout }
155-
>
156-
{ translate( 'Skip' ) }
157-
</Button>
158-
) }
135+
<Button className="google-apps-dialog__checkout-button" onClick={ this.handleFormCheckout }>
136+
{ translate( 'Skip' ) }
137+
</Button>
138+
159139
<Button
160140
primary
161141
className="google-apps-dialog__continue-button"
162-
onClick={ continueButtonHandler }
142+
onClick={ this.handleFormSubmit }
163143
>
164-
{ continueButtonText }
144+
{ translate( 'Yes, Add Email \u00BB' ) }
165145
</Button>
166146
</footer>
167147
);
168148
}
169149

170-
handleAddEmail = event => {
171-
event.preventDefault();
172-
173-
this.props.recordAddEmailButtonClick( this.props.analyticsSection );
174-
175-
this.setState( { isAddingEmail: true } );
176-
};
177-
178150
handleFormSubmit = event => {
179151
event.preventDefault();
180152

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const setSelectedSiteId = selectedSiteId => ( {
2+
type: 'GUTENLYPSO_SELECTED_SITE_ID_SET',
3+
selectedSiteId,
4+
} );
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* WordPress Dependencies
3+
*/
4+
import { registerStore } from '@wordpress/data';
5+
6+
/**
7+
* Internal dependencies
8+
*/
9+
import reducer from './reducer';
10+
import * as actions from './actions';
11+
import * as selectors from './selectors';
12+
13+
const store = registerStore( 'gutenberg/calypso', {
14+
reducer,
15+
actions,
16+
selectors,
17+
} );
18+
19+
export default store;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* eslint-disable wpcalypso/import-docblock */
2+
/**
3+
* WordPress dependencies
4+
*/
5+
import { combineReducers } from '@wordpress/data';
6+
7+
const selectedSiteId = ( state = null, action ) =>
8+
'GUTENLYPSO_SELECTED_SITE_ID_SET' === action.type ? action.selectedSiteId : state;
9+
10+
export default combineReducers( { selectedSiteId } );
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const getSelectedSiteId = state => state.selectedSiteId;

client/gutenberg/editor/controller.js

+18-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { has, set, uniqueId } from 'lodash';
1212
* WordPress dependencies
1313
*/
1414
import { setLocaleData } from '@wordpress/i18n';
15-
import { dispatch } from '@wordpress/data';
15+
import { dispatch, select } from '@wordpress/data';
1616

1717
/**
1818
* Internal dependencies
@@ -110,6 +110,22 @@ export const loadGutenbergBlockAvailability = store => {
110110
} );
111111
};
112112

113+
export const resetGutenbergState = ( registry, selectedSiteId ) => {
114+
// Always reset core/editor, core/notices, and other UI parts
115+
registry.reset( 'core/editor' );
116+
registry.reset( 'core/notices' );
117+
dispatch( 'core/edit-post' ).closePublishSidebar();
118+
dispatch( 'core/edit-post' ).closeModal();
119+
120+
// Only reset core/data on site change
121+
const previousGutenbergSiteId = select( 'gutenberg/calypso' ).getSelectedSiteId();
122+
123+
if ( !! previousGutenbergSiteId && previousGutenbergSiteId !== selectedSiteId ) {
124+
registry.resetCoreResolvers();
125+
}
126+
dispatch( 'gutenberg/calypso' ).setSelectedSiteId( selectedSiteId );
127+
};
128+
113129
export const redirect = ( { store: { getState } }, next ) => {
114130
const state = getState();
115131
const siteId = getSelectedSiteId( state );
@@ -140,10 +156,7 @@ export const post = async ( context, next ) => {
140156

141157
const { Editor, registry } = initGutenberg( userId, context.store );
142158

143-
// Reset the Gutenberg state
144-
registry.reset();
145-
dispatch( 'core/edit-post' ).closePublishSidebar();
146-
dispatch( 'core/edit-post' ).closeModal();
159+
resetGutenbergState( registry, siteId );
147160

148161
return props => (
149162
<Editor { ...{ siteId, postId, postType, uniqueDraftKey, isDemoContent, ...props } } />

client/gutenberg/editor/init.js

+26-15
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,34 @@ const addResetToRegistry = registry => {
3434
window.gutenbergState = () => mapValues( registry.stores, ( { store } ) => store.getState() );
3535
}
3636

37-
const resettableStores = [ 'core/editor', 'core/notices' ];
38-
3937
const stores = [];
4038
return {
4139
registerStore( namespace, options ) {
42-
let store;
43-
if ( -1 === resettableStores.indexOf( namespace ) ) {
44-
store = registry.registerStore( namespace, options );
45-
} else {
46-
store = registry.registerStore( namespace, {
47-
...options,
48-
reducer: ( state, action ) =>
49-
options.reducer( 'GUTENLYPSO_RESET' === action.type ? undefined : state, action ),
50-
} );
51-
}
40+
const store = registry.registerStore( namespace, {
41+
...options,
42+
reducer: ( state, action ) => {
43+
if ( 'GUTENLYPSO_RESET' === action.type && namespace === action.namespace ) {
44+
debug( `Resetting ${ namespace } store` );
45+
return options.reducer( undefined, action );
46+
}
47+
return options.reducer( state, action );
48+
},
49+
} );
5250
stores.push( store );
5351
return store;
5452
},
55-
reset() {
56-
stores.forEach( store => store.dispatch( { type: 'GUTENLYPSO_RESET' } ) );
53+
reset( namespace ) {
54+
stores.forEach( store => store.dispatch( { type: 'GUTENLYPSO_RESET', namespace } ) );
55+
},
56+
resetCoreResolvers() {
57+
// @see https://github.com/WordPress/gutenberg/blob/e1092c0d0b75fe53ab57bc6c4cc9e32cb2e74e40/packages/data/src/resolvers-cache-middleware.js#L14-L34
58+
const resolvers = registry.select( 'core/data' ).getCachedResolvers( 'core' );
59+
debug( `Resetting core store resolvers: ${ Object.keys( resolvers ).toString() }` );
60+
Object.entries( resolvers ).forEach( ( [ selectorName, resolversByArgs ] ) => {
61+
resolversByArgs.forEach( ( value, args ) => {
62+
registry.dispatch( 'core/data' ).invalidateResolution( 'core', selectorName, args );
63+
} );
64+
} );
5765
},
5866
};
5967
};
@@ -63,12 +71,15 @@ const addResetToRegistry = registry => {
6371
export const initGutenberg = once( ( userId, store ) => {
6472
debug( 'Starting Gutenberg editor initialization...' );
6573

74+
const registry = use( addResetToRegistry );
75+
6676
debug( 'Registering data plugins' );
6777
const storageKey = 'WP_DATA_USER_' + userId;
6878
use( plugins.persistence, { storageKey: storageKey } );
6979
use( plugins.controls );
7080

71-
const registry = use( addResetToRegistry );
81+
debug( 'Initializing gutenberg/calypso store' );
82+
require( 'gutenberg/editor/calypso-store' );
7283

7384
// We need to ensure that core-data is loaded after the data plugins have been registered.
7485
debug( 'Initializing core-data store' );

client/gutenberg/extensions/contact-form/editor.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Internal dependencies
55
*/
66
import registerJetpackBlock from 'gutenberg/extensions/presets/jetpack/utils/register-jetpack-block';
7-
import { fields, name, settings } from '.';
7+
import { childBlocks, name, settings } from '.';
88

99
registerJetpackBlock( name, settings );
10-
fields.forEach( field => registerJetpackBlock( field.name, field.settings ) );
10+
childBlocks.forEach( childBlock => registerJetpackBlock( childBlock.name, childBlock.settings ) );

client/gutenberg/extensions/contact-form/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const editMultiField = type => props => (
193193
/>
194194
);
195195

196-
export const fields = [
196+
export const childBlocks = [
197197
{
198198
name: 'field-text',
199199
settings: {

client/gutenberg/extensions/presets/jetpack/editor.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55
*/
66
import './shared/public-path';
77
import './editor-shared/block-category'; // Register the Jetpack category
8-
9-
// TODO: Generate dyanmically from index.json
10-
// Appending `Block` to the names to keep `Map` from colliding with JS' Map
11-
import * as ContactFormBlock from 'gutenberg/extensions/contact-form';
12-
import * as MarkdownBlock from 'gutenberg/extensions/markdown';
13-
import * as MapBlock from 'gutenberg/extensions/map';
14-
import * as PublicizeBlock from 'gutenberg/extensions/publicize';
15-
import * as RelatedPostsBlock from 'gutenberg/extensions/related-posts';
16-
import * as SimplePaymentsBlock from 'gutenberg/extensions/simple-payments';
17-
import * as TiledGalleryBlock from 'gutenberg/extensions/tiled-gallery';
18-
import * as VRBlock from 'gutenberg/extensions/vr';
8+
import extensionSlugsJson from './index.json';
199
import { isEnabled } from 'config';
2010

21-
export default [
22-
{ name: ContactFormBlock.name, settings: ContactFormBlock.settings },
23-
...ContactFormBlock.fields,
24-
MarkdownBlock,
25-
MapBlock,
26-
PublicizeBlock,
27-
SimplePaymentsBlock,
28-
...( isEnabled( 'jetpack/blocks/beta' )
29-
? [ RelatedPostsBlock, TiledGalleryBlock, VRBlock ]
30-
: [] ),
11+
const extensionSlugs = [
12+
...extensionSlugsJson.production,
13+
...( isEnabled( 'jetpack/blocks/beta' ) ? extensionSlugsJson.beta : [] ),
3114
];
15+
16+
export async function getExtensions() {
17+
const promises = extensionSlugs.map( slug =>
18+
// Need to explicitly look for `index.js` or Webpack will try with
19+
// all files when resolving the dynamic import -- including `README.md`s,
20+
// leading to warnings during startup.
21+
import( /* webpackMode: "eager" */ `../../${ slug }/index.js` ).then(
22+
( { childBlocks, name, settings } ) => ( {
23+
childBlocks,
24+
name,
25+
settings,
26+
} )
27+
)
28+
);
29+
30+
return await Promise.all( promises );
31+
}

client/gutenberg/extensions/presets/jetpack/index.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
],
99
"beta": [
1010
"related-posts",
11+
"subscriptions",
1112
"tiled-gallery",
1213
"vr"
1314
]

0 commit comments

Comments
 (0)