Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2634 from woocommerce/revert-2596-update/2445-sna…
Browse files Browse the repository at this point in the history
…ckbar

Revert "Update to new Snackbar component and notice store"
  • Loading branch information
psealock authored Jul 11, 2019
2 parents 9c287d7 + a047a97 commit c5ccd0b
Show file tree
Hide file tree
Showing 32 changed files with 438 additions and 339 deletions.
8 changes: 4 additions & 4 deletions client/analytics/settings/historical-data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ class HistoricalData extends Component {
}

makeQuery( path, errorMessage ) {
const { createNotice } = this.props;
const { addNotice } = this.props;
apiFetch( { path, method: 'POST' } )
.then( response => {
if ( 'success' === response.status ) {
createNotice( 'success', response.message );
addNotice( { status: 'success', message: response.message } );
} else {
createNotice( 'error', errorMessage );
addNotice( { status: 'error', message: errorMessage } );
this.setState( {
activeImport: false,
lastImportStopTimestamp: Date.now(),
Expand All @@ -66,7 +66,7 @@ class HistoricalData extends Component {
} )
.catch( error => {
if ( error && error.message ) {
createNotice( 'error', error.message );
addNotice( { status: 'error', message: error.message } );
this.setState( {
activeImport: false,
lastImportStopTimestamp: Date.now(),
Expand Down
29 changes: 16 additions & 13 deletions client/analytics/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,25 @@ class Settings extends Component {
};

componentDidUpdate() {
const { createNotice, isError, isRequesting } = this.props;
const { addNotice, isError, isRequesting } = this.props;
const { saving, isDirty } = this.state;
let newIsDirtyState = isDirty;

if ( saving && ! isRequesting ) {
if ( ! isError ) {
createNotice(
'success',
__( 'Your settings have been successfully saved.', 'woocommerce-admin' )
);
addNotice( {
status: 'success',
message: __( 'Your settings have been successfully saved.', 'woocommerce-admin' ),
} );
newIsDirtyState = false;
} else {
createNotice(
'error',
__( 'There was an error saving your settings. Please try again.', 'woocommerce-admin' )
);
addNotice( {
status: 'error',
message: __(
'There was an error saving your settings. Please try again.',
'woocommerce-admin'
),
} );
}
/* eslint-disable react/no-did-update-set-state */
this.setState( { saving: false, isDirty: newIsDirtyState } );
Expand Down Expand Up @@ -148,7 +151,7 @@ class Settings extends Component {
}

render() {
const { createNotice } = this.props;
const { addNotice } = this.props;
const { hasError } = this.state;
if ( hasError ) {
return null;
Expand All @@ -175,7 +178,7 @@ class Settings extends Component {
</Button>
</div>
</div>
<HistoricalData createNotice={ createNotice } />
<HistoricalData addNotice={ addNotice } />
</Fragment>
);
}
Expand All @@ -192,11 +195,11 @@ export default compose(
return { getSettings, isError, isRequesting, settings };
} ),
withDispatch( dispatch => {
const { createNotice } = dispatch( 'core/notices' );
const { addNotice } = dispatch( 'wc-admin' );
const { updateSettings } = dispatch( 'wc-api' );

return {
createNotice,
addNotice,
updateSettings,
};
} )
Expand Down
8 changes: 4 additions & 4 deletions client/analytics/settings/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ class Setting extends Component {
};

handleInputCallback = () => {
const { createNotice, callback } = this.props;
const { addNotice, callback } = this.props;

if ( 'function' !== typeof callback ) {
return;
}

return new Promise( ( resolve, reject ) => {
this.setState( { disabled: true } );
callback( resolve, reject, createNotice );
callback( resolve, reject, addNotice );
} )
.then( () => {
this.setState( { disabled: false } );
Expand Down Expand Up @@ -197,7 +197,7 @@ Setting.propTypes = {

export default compose(
withDispatch( dispatch => {
const { createNotice } = dispatch( 'core/notices' );
return { createNotice };
const { addNotice } = dispatch( 'wc-admin' );
return { addNotice };
} )
)( Setting );
15 changes: 7 additions & 8 deletions client/dashboard/profile-wizard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class ProfileWizard extends Component {
}

async goToNextStep() {
const { createNotice, isError, updateProfileItems } = this.props;
const { addNotice, isError, updateProfileItems } = this.props;
const currentStep = this.getCurrentStep();
const currentStepIndex = getSteps().findIndex( s => s.key === currentStep.key );
const nextStep = getSteps()[ currentStepIndex + 1 ];
Expand All @@ -102,10 +102,10 @@ class ProfileWizard extends Component {
await updateProfileItems( { completed: true } );

if ( isError ) {
createNotice(
'error',
__( 'There was a problem completing the profiler.', 'woocommerce-admin' )
);
addNotice( {
status: 'error',
message: __( 'There was a problem completing the profiler.', 'woocommerce-admin' ),
} );
}
return;
}
Expand Down Expand Up @@ -142,11 +142,10 @@ export default compose(
return { isError };
} ),
withDispatch( dispatch => {
const { updateProfileItems } = dispatch( 'wc-api' );
const { createNotice } = dispatch( 'core/notices' );
const { addNotice, updateProfileItems } = dispatch( 'wc-api' );

return {
createNotice,
addNotice,
updateProfileItems,
};
} )
Expand Down
15 changes: 7 additions & 8 deletions client/dashboard/profile-wizard/steps/business-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BusinessDetails extends Component {
}

async onContinue() {
const { createNotice, goToNextStep, isError, updateProfileItems } = this.props;
const { addNotice, goToNextStep, isError, updateProfileItems } = this.props;
const { other_platform, product_count, selling_venues } = this.state;
const extensions = keys( pickBy( this.state.extensions ) );

Expand All @@ -62,10 +62,10 @@ class BusinessDetails extends Component {
if ( ! isError ) {
goToNextStep();
} else {
createNotice(
'error',
__( 'There was a problem updating your business details.', 'woocommerce-admin' )
);
addNotice( {
status: 'error',
message: __( 'There was a problem updating your business details.', 'woocommerce-admin' ),
} );
}
}

Expand Down Expand Up @@ -316,11 +316,10 @@ export default compose(
return { isError };
} ),
withDispatch( dispatch => {
const { updateProfileItems } = dispatch( 'wc-api' );
const { createNotice } = dispatch( 'core/notices' );
const { addNotice, updateProfileItems } = dispatch( 'wc-api' );

return {
createNotice,
addNotice,
updateProfileItems,
};
} )
Expand Down
15 changes: 7 additions & 8 deletions client/dashboard/profile-wizard/steps/industry.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ class Industry extends Component {
}

async onContinue() {
const { createNotice, goToNextStep, isError, updateProfileItems } = this.props;
const { addNotice, goToNextStep, isError, updateProfileItems } = this.props;

recordEvent( 'storeprofiler_store_industry_continue', { store_industry: this.state.selected } );
await updateProfileItems( { industry: this.state.selected } );

if ( ! isError ) {
goToNextStep();
} else {
createNotice(
'error',
__( 'There was a problem updating your industries.', 'woocommerce-admin' )
);
addNotice( {
status: 'error',
message: __( 'There was a problem updating your industries.', 'woocommerce-admin' ),
} );
}
}

Expand Down Expand Up @@ -104,11 +104,10 @@ export default compose(
return { isError };
} ),
withDispatch( dispatch => {
const { updateProfileItems } = dispatch( 'wc-api' );
const { createNotice } = dispatch( 'core/notices' );
const { addNotice, updateProfileItems } = dispatch( 'wc-api' );

return {
createNotice,
addNotice,
updateProfileItems,
};
} )
Expand Down
14 changes: 10 additions & 4 deletions client/dashboard/profile-wizard/steps/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ class Plugins extends Component {
} );
return pluginResponse;
} catch ( err ) {
this.props.createNotice( 'error', this.getErrorMessage( action, plugin ) );
this.props.addNotice( {
status: 'error',
message: this.getErrorMessage( action, plugin ),
} );
this.setState( {
isPending: false,
isError: true,
Expand All @@ -138,7 +141,10 @@ class Plugins extends Component {
}
throw new Error();
} catch ( err ) {
this.props.createNotice( 'error', this.getErrorMessage( 'activate', 'jetpack' ) );
this.props.addNotice( {
status: 'error',
message: this.getErrorMessage( 'activate', 'jetpack' ),
} );
this.setState( {
isPending: false,
isError: true,
Expand Down Expand Up @@ -202,9 +208,9 @@ class Plugins extends Component {

export default compose(
withDispatch( dispatch => {
const { createNotice } = dispatch( 'core/notices' );
const { addNotice } = dispatch( 'wc-admin' );
return {
createNotice,
addNotice,
};
} )
)( Plugins );
15 changes: 7 additions & 8 deletions client/dashboard/profile-wizard/steps/product-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ProductTypes extends Component {
}

async onContinue() {
const { createNotice, goToNextStep, isError, updateProfileItems } = this.props;
const { addNotice, goToNextStep, isError, updateProfileItems } = this.props;

recordEvent( 'storeprofiler_store_product_type_continue', {
product_type: this.state.selected,
Expand All @@ -40,10 +40,10 @@ class ProductTypes extends Component {
if ( ! isError ) {
goToNextStep();
} else {
createNotice(
'error',
__( 'There was a problem updating your product types.', 'woocommerce-admin' )
);
addNotice( {
status: 'error',
message: __( 'There was a problem updating your product types.', 'woocommerce-admin' ),
} );
}
}

Expand Down Expand Up @@ -137,11 +137,10 @@ export default compose(
return { isError };
} ),
withDispatch( dispatch => {
const { updateProfileItems } = dispatch( 'wc-api' );
const { createNotice } = dispatch( 'core/notices' );
const { addNotice, updateProfileItems } = dispatch( 'wc-api' );

return {
createNotice,
addNotice,
updateProfileItems,
};
} )
Expand Down
25 changes: 12 additions & 13 deletions client/dashboard/profile-wizard/steps/start/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,23 @@ class Start extends Component {
}

async skipWizard() {
const { createNotice, isProfileItemsError, updateProfileItems, isSettingsError } = this.props;
const { addNotice, isProfileItemsError, updateProfileItems, isSettingsError } = this.props;

recordEvent( 'storeprofiler_welcome_clicked', { proceed_without_install: true } );

await updateProfileItems( { skipped: true } );
await this.updateTracking();

if ( isProfileItemsError || isSettingsError ) {
createNotice(
'error',
__( 'There was a problem updating your preferences.', 'woocommerce-admin' )
);
addNotice( {
status: 'error',
message: __( 'There was a problem updating your preferences.', 'woocommerce-admin' ),
} );
}
}

async startWizard() {
const { createNotice, isSettingsError } = this.props;
const { addNotice, isSettingsError } = this.props;

recordEvent( 'storeprofiler_welcome_clicked', { get_started: true } );

Expand All @@ -101,10 +101,10 @@ class Start extends Component {
if ( ! isSettingsError ) {
this.props.goToNextStep();
} else {
createNotice(
'error',
__( 'There was a problem updating your preferences.', 'woocommerce-admin' )
);
addNotice( {
status: 'error',
message: __( 'There was a problem updating your preferences.', 'woocommerce-admin' ),
} );
}
}

Expand Down Expand Up @@ -217,11 +217,10 @@ export default compose(
return { getSettings, isSettingsError, isProfileItemsError, isSettingsRequesting };
} ),
withDispatch( dispatch => {
const { updateProfileItems, updateSettings } = dispatch( 'wc-api' );
const { createNotice } = dispatch( 'core/notices' );
const { addNotice, updateProfileItems, updateSettings } = dispatch( 'wc-api' );

return {
createNotice,
addNotice,
updateProfileItems,
updateSettings,
};
Expand Down
Loading

0 comments on commit c5ccd0b

Please sign in to comment.