Exemplo n.º 1
0
export const handleTransferSuccess = ( { siteId } ) => [
	successNotice(
		translate( 'Plan purchaser has been changed successfully.' ),
		noticeOptions( siteId )
	),
	refreshSitePlans( siteId ),
];
Exemplo n.º 2
0
const onDeleteSuccess = action => dispatch => {
	const { siteId, siteSlug, orderId } = action;
	dispatch( deleteOrderSuccess( siteId, orderId ) );
	dispatch( fetchCounts( siteId ) );
	dispatch( navigate( `/store/orders/${ siteSlug }` ) );
	dispatch( successNotice( translate( 'Order deleted.' ), { duration: 8000 } ) );
};
Exemplo n.º 3
0
export const success = ( action, { rewind_state } ) => [
	{
		type: JETPACK_CREDENTIALS_UPDATE_SUCCESS,
		siteId: action.siteId,
	},

	{
		type: JETPACK_CREDENTIALS_STORE,
		credentials: {
			main: action.credentials,
		},
		siteId: action.siteId,
	},
	successNotice( i18n.translate( 'Your site is now connected.' ), {
		duration: 4000,
		id: action.noticeId,
	} ),
	// the API transform could fail and the rewind data might
	// be unavailable so if that's the case just let it go
	// for now. we'll improve our rigor as time goes by.
	( () => {
		try {
			return {
				type: REWIND_STATE_UPDATE,
				siteId: action.siteId,
				data: transformApi( rewind_state ),
			};
		} catch ( e ) {}
	} )(),
];
Exemplo n.º 4
0
		const successAction = () => {
			page.redirect( getLink( '/store/products/categories/:site', site ) );
			return successNotice( translate( 'Category successfully updated.' ), {
				displayOnNextPage: true,
				duration: 8000,
			} );
		};
Exemplo n.º 5
0
		const onSuccess = dispatch => {
			dispatch(
				successNotice( translate( 'An invoice has been sent to the customer.' ), {
					duration: 8000,
				} )
			);
		};
Exemplo n.º 6
0
	onSave() {
		const { zone, translate, actions } = this.props;

		const successAction = successNotice(
			isNaN( zone.id ) ? translate( 'Shipping Zone added.' ) : translate( 'Shipping Zone saved.' ),
			{ duration: 4000 }
		);

		const failureAction = errorNotice(
			translate( 'There was a problem saving the Shipping Zone. Please try again.' )
		);

		const locationsFailAction = errorNotice(
			translate( 'Add at least one location to this zone' ),
			{ duration: 4000 }
		);

		const methodsFailAction = errorNotice( translate( 'Add shipping methods to this zone' ), {
			duration: 4000,
		} );

		actions.createShippingZoneSaveActionList(
			successAction,
			failureAction,
			locationsFailAction,
			methodsFailAction
		);
	}
Exemplo n.º 7
0
const handleSuccess = ( { newOwnerWpcomDisplayName, siteId } ) => [
	successNotice(
		translate( 'Site owner changed to %(user)s.', {
			args: { user: newOwnerWpcomDisplayName },
		} )
	),
	requestJetpackUserConnectionData( siteId ),
];
Exemplo n.º 8
0
	test( 'should dispatch `successNotice`', () => {
		const dispatch = sinon.spy();

		announceSuccess( { dispatch }, dummyAction );

		expect( dispatch ).to.have.been.calledWith(
			successNotice( translate( 'Zone feed saved!' ), { id: 'zoninator-save-feed' } )
		);
	} );
Exemplo n.º 9
0
	test( 'should dispatch `successNotice`', () => {
		const dispatch = sinon.spy();

		announceSuccess( { dispatch }, saveAction, apiResponse );

		expect( dispatch ).to.have.been.calledWith(
			successNotice( translate( 'Settings saved!' ), { id: 'wpjm-settings-save' } )
		);
	} );
Exemplo n.º 10
0
		const unitsSaveSuccessNotice = dispatch => {
			this.props.onSaveSuccess( 'units' );

			dispatch(
				successNotice( translate( 'Units settings saved' ), {
					duration: 4000,
				} )
			);
		};
Exemplo n.º 11
0
		.then( data => {
			dispatch( successNotice( translate( 'Order saved.' ), { duration: 5000 } ) );
			dispatch( {
				type: WOOCOMMERCE_ORDER_UPDATE_SUCCESS,
				siteId,
				orderId,
				order: data,
			} );
		} )
Exemplo n.º 12
0
			const successAction = () => {
				debounce( () => {
					page.redirect( getLink( '/store/products/:site/', site ) );
				}, 1000 )();
				return successNotice(
					translate( '%(product)s successfully deleted.', {
						args: { product: product.name },
					} )
				);
			};
Exemplo n.º 13
0
			const successAction = () => {
				debounce( () => {
					page.redirect( getLink( '/store/products/categories/:site/', site ) );
				}, 2000 )();
				return successNotice(
					translate( '%(name)s successfully deleted.', {
						args: { name: category.name },
					} )
				);
			};
Exemplo n.º 14
0
	const showSuccessNotice = () => {
		dispatch( NoticeActions.successNotice( translate(
			'Your shipping label was purchased successfully',
			'Your %(count)d shipping labels were purchased successfully',
			{
				count: labels.length,
				args: { count: labels.length },
			}
		) ) );
	};
Exemplo n.º 15
0
		const onSuccess = () => {
			this.setState( { isSaving: false, pristine: true } );
			if ( onSuccessExtra ) {
				onSuccessExtra();
			}
			return successNotice( translate( 'Settings updated successfully.' ), {
				duration: 4000,
				displayOnNextPage: true,
			} );
		};
Exemplo n.º 16
0
		const successAction = () => {
			if ( ! finishedInitialSetup ) {
				page.redirect( getLink( '/store/:site', site ) );
			}

			return successNotice(
				translate( 'Payment settings saved.' ),
				{ duration: 4000, displayOnNextPage: true }
			);
		};
Exemplo n.º 17
0
		const getSuccessNotice = () => {
			return successNotice(
				translate( 'Promotion successfully created.', {
					args: { promotion: promotion.name },
				} ),
				{
					displayOnNextPage: true,
					duration: 8000,
				}
			);
		};
Exemplo n.º 18
0
	onSaveSuccess = dispatch => {
		const { translate } = this.props;

		this.props.onSaveSuccess( 'shipping' );

		dispatch(
			successNotice( translate( 'Shipping settings saved' ), {
				duration: 4000,
			} )
		);
	};
Exemplo n.º 19
0
	triggerInvoice = () => {
		const { siteId, orderId, translate } = this.props;
		if ( siteId && orderId ) {
			const onSuccess = successNotice( translate( 'Order invoice sent.' ), { duration: 8000 } );
			const onFailure = errorNotice( translate( 'Unable to send order invoice.' ), {
				duration: 8000,
			} );

			recordTrack( 'calypso_woocommerce_order_manual_invoice' );
			this.props.sendOrderInvoice( siteId, orderId, onSuccess, onFailure );
		}
	};
Exemplo n.º 20
0
						dispatch( requestSite( siteId ) ).then( () => {
							page( domainManagementEdit( newAddress, newAddress ) );

							dispatch(
								successNotice( translate( 'Your new site address is ready to go!' ), {
									id: 'siteAddressChangeSuccessful',
									duration: 5000,
									showDismiss: true,
									isPersistent: true,
								} )
							);
						} );
Exemplo n.º 21
0
export const receiveBlogStickerAdd = action => {
	return successNotice(
		translate( 'The sticker {{i}}%s{{/i}} has been successfully added.', {
			args: action.payload.stickerName,
			components: {
				i: <i />,
			},
		} ),
		{
			duration: 5000,
		}
	);
};
Exemplo n.º 22
0
		wpcom.undocumented().sendInvites( siteId, usernamesOrEmails, role, message, ( error, data ) => {
			const validationErrors = get( data, 'errors' );
			const isErrored = !! error || ! isEmpty( validationErrors );

			Dispatcher.handleServerAction( {
				type: isErrored ? ActionTypes.RECEIVE_SENDING_INVITES_ERROR : ActionTypes.RECEIVE_SENDING_INVITES_SUCCESS,
				error,
				siteId,
				usernamesOrEmails,
				role,
				message,
				formId,
				data
			} );

			if ( isErrored ) {
				// If there are no validation errors but the form errored, assume that all errored
				const countErrors = ( error || isEmpty( validationErrors ) || 'object' !== typeof validationErrors )
					? usernamesOrEmails.length
					: Object.keys( data.errors ).length;

				if ( countErrors === usernamesOrEmails.length ) {
					message = i18n.translate(
						'Invitation failed to send',
						'Invitations failed to send', {
							count: countErrors,
							context: 'Displayed in a notice when all invitations failed to send.'
						}
					);
				} else {
					message = i18n.translate(
						'An invitation failed to send',
						'Some invitations failed to send', {
							count: countErrors,
							context: 'Displayed in a notice when some invitations failed to send.'
						}
					);
				}

				dispatch( errorNotice( message ) );
				analytics.tracks.recordEvent( 'calypso_invite_send_failed' );
			} else {
				dispatch( successNotice( i18n.translate(
					'Invitation sent successfully',
					'Invitations sent successfully', {
						count: usernamesOrEmails.length
					}
				) ) );
				analytics.tracks.recordEvent( 'calypso_invite_send_success' );
			}
		} );
Exemplo n.º 23
0
	test( 'should dispatch `successNotice`', () => {
		const dispatch = sinon.spy();
		const action = {
			type: 'DUMMY_ACTION',
			siteId: 123456,
			form: 'form',
		};

		announceZoneSaved( dispatch, action, zone );

		expect( dispatch ).to.have.been.calledWith(
			successNotice( translate( 'Zone saved!' ), { id: 'zoninator-zone-create' } )
		);
	} );
Exemplo n.º 24
0
	onDelete() {
		const { translate, actions } = this.props;

		const successAction = successNotice(
			translate( 'Shipping Zone deleted.' ),
			{ duration: 4000, displayOnNextPage: true }
		);

		const failureAction = errorNotice(
			translate( 'There was a problem deleting the Shipping Zone. Please try again.' )
		);

		actions.createShippingZoneDeleteActionList( successAction, failureAction );
	}
Exemplo n.º 25
0
export function receiveConversationFollow( store, action, response ) {
	// validate that it worked
	const isFollowing = !! ( response && response.success );
	if ( ! isFollowing ) {
		receiveConversationFollowError( store, action );
		return;
	}

	store.dispatch(
		successNotice( translate( 'The conversation has been successfully followed.' ), {
			duration: 5000,
		} )
	);
}
Exemplo n.º 26
0
		const getSuccessNotice = newProduct => {
			if ( ! finishedInitialSetup ) {
				return successNotice(
					translate( '%(product)s successfully created. {{productLink}}View{{/productLink}}', {
						args: {
							product: newProduct.name,
						},
						components: {
							productLink: (
								<a href={ newProduct.permalink } target="_blank" rel="noopener noreferrer" />
							),
						},
					} ),
					{
						displayOnNextPage: true,
						showDismiss: false,
						button: translate( 'Back to dashboard' ),
						href: getLink( '/store/:site', site ),
					}
				);
			}

			return successNotice(
				translate( '%(product)s successfully created.', {
					args: { product: product.name },
				} ),
				{
					displayOnNextPage: true,
					duration: 8000,
					button: translate( 'View' ),
					onClick: () => {
						window.open( newProduct.permalink );
					},
				}
			);
		};
Exemplo n.º 27
0
	const setIsSaving = ( saving ) => {
		if ( saving ) {
			dispatch( { type: WOOCOMMERCE_SERVICES_SHIPPING_LABEL_REFUND_REQUEST, orderId, siteId } );
		} else {
			dispatch( { type: WOOCOMMERCE_SERVICES_SHIPPING_LABEL_REFUND_RESPONSE, response, error, orderId, siteId } );
			if ( error ) {
				dispatch( NoticeActions.errorNotice( error.toString() ) );
			} else {
				dispatch( NoticeActions.successNotice(
					translate( 'The refund request has been sent successfully.' ),
					{ duration: 5000 }
				) );
			}
		}
	};
Exemplo n.º 28
0
	test( 'should dispatch `successNotice`', () => {
		const dispatch = sinon.spy();
		const action = {
			type: 'DUMMY_ACTION',
			siteId: 123,
			siteSlug: 'test.dev',
			zoneId: 456,
		};

		announceZoneDeleted( { dispatch }, action );

		expect( dispatch ).to.have.been.calledWith(
			successNotice( translate( 'The zone has been deleted.' ), { id: 'zoninator-zone-delete' } )
		);
	} );
Exemplo n.º 29
0
	test( 'should dispatch `successNotice`', () => {
		const dispatch = sinon.spy();
		const action = {
			type: 'DUMMY_ACTION',
			siteId: 123,
			form: 'form',
			data: { name: 'Test Zone' },
		};

		handleZoneCreated( { dispatch }, action, { data: zone } );

		expect( dispatch ).to.have.been.calledWith(
			successNotice( translate( 'Zone saved!' ), { id: 'zoninator-zone-create' } )
		);
	} );
Exemplo n.º 30
0
export function onPostSaveSuccess( dispatch, action ) {
	let text;
	switch ( action.post.status ) {
		case 'trash':
			text = translate( 'Post successfully moved to trash' );
			break;

		case 'publish':
			text = translate( 'Post successfully published' );
			break;
	}

	if ( text ) {
		dispatch( successNotice( text ) );
	}
}