-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace connection success notice with a success modal (#10154)
Co-authored-by: Vlad Olaru <[email protected]> Co-authored-by: Oleksandr Aratovskyi <[email protected]>
- Loading branch information
1 parent
50584f1
commit 6457531
Showing
13 changed files
with
258 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: update | ||
|
||
Replace payments overview page connection success notice with a modal for live accounts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
import { Modal, Button } from '@wordpress/components'; | ||
import { useDispatch } from '@wordpress/data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './style.scss'; | ||
import strings from './strings'; | ||
|
||
/** | ||
* A modal component displayed when a live account is successfully connected. | ||
*/ | ||
export const ConnectionSuccessModal = () => { | ||
const [ isDismissed, setIsDismissed ] = React.useState( | ||
wcpaySettings.isConnectionSuccessModalDismissed | ||
); | ||
const { updateOptions } = useDispatch( 'wc/admin/options' ); | ||
|
||
const onDismiss = async () => { | ||
setIsDismissed( true ); | ||
|
||
// Update the option to mark the modal as dismissed. | ||
await updateOptions( { | ||
wcpay_connection_success_modal_dismissed: true, | ||
} ); | ||
}; | ||
|
||
return ( | ||
<> | ||
{ ! isDismissed && ( | ||
<Modal | ||
title={ strings.heading } | ||
className="woopayments-connection-success-modal" | ||
isDismissible={ true } | ||
onRequestClose={ onDismiss } | ||
> | ||
<div className="woopayments-connection-success-modal__content"> | ||
{ strings.description } | ||
</div> | ||
<div className="woopayments-connection-success-modal__actions"> | ||
<Button | ||
variant="primary" | ||
isBusy={ false } | ||
disabled={ false } | ||
onClick={ onDismiss } | ||
> | ||
{ strings.button } | ||
</Button> | ||
</div> | ||
</Modal> | ||
) } | ||
</> | ||
); | ||
}; | ||
|
||
export default ConnectionSuccessModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-disable max-len */ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
|
||
export default { | ||
button: __( 'Dismiss', 'woocommerce-payments' ), | ||
|
||
heading: __( "You're ready to accept payments!", 'woocommerce-payments' ), | ||
|
||
description: sprintf( | ||
__( | ||
'Great news — your %s account has been activated. You can now start accepting payments on your store.', | ||
'woocommerce-payments' | ||
), | ||
'WooPayments' | ||
), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.components-modal__frame.woopayments-connection-success-modal { | ||
max-width: 512px; | ||
@media screen and ( max-width: 782px ) { | ||
max-width: 343px; | ||
margin: auto; | ||
} | ||
|
||
.components-modal__header { | ||
.components-button.has-icon { | ||
padding: 0; | ||
svg { | ||
width: 30px; | ||
height: 30px; | ||
} | ||
} | ||
|
||
&-heading { | ||
font-size: 20px; | ||
line-height: 28px; | ||
font-weight: 300; | ||
text-wrap: auto; | ||
color: $gray-900; | ||
} | ||
} | ||
|
||
.woopayments-connection-success-modal__content { | ||
display: flex; | ||
gap: $gap-large; | ||
flex-direction: column; | ||
padding: $gap-small 0 $gap 0; | ||
line-height: 20px; | ||
font-weight: 400; | ||
color: $gray-900; | ||
} | ||
|
||
.woopayments-connection-success-modal__actions { | ||
flex-direction: row-reverse; // Use this to force items to start from end. That would require actions to be introduced in reverse order. | ||
padding: $gap-large 0 0 0; | ||
display: flex; | ||
gap: $gap-small; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
client/overview/modal/connection-success/test/index.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import user from '@testing-library/user-event'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import ConnectionSuccessModal from '../index'; | ||
|
||
jest.mock( '@wordpress/data', () => ( { | ||
useDispatch: jest.fn().mockReturnValue( { updateOptions: jest.fn() } ), | ||
} ) ); | ||
|
||
declare const global: { | ||
wcpaySettings: { | ||
isConnectionSuccessModalDismissed: boolean; | ||
}; | ||
}; | ||
|
||
describe( 'Connection Success Modal', () => { | ||
global.wcpaySettings = { | ||
isConnectionSuccessModalDismissed: false, | ||
}; | ||
|
||
it( 'modal is open by default', () => { | ||
render( <ConnectionSuccessModal /> ); | ||
|
||
const queryHeading = () => | ||
screen.queryByRole( 'heading', { | ||
name: "You're ready to accept payments!", | ||
} ); | ||
|
||
expect( queryHeading() ).toBeInTheDocument(); | ||
} ); | ||
|
||
it( 'closes modal when dismiss button is clicked', () => { | ||
global.wcpaySettings = { | ||
isConnectionSuccessModalDismissed: false, | ||
}; | ||
|
||
render( <ConnectionSuccessModal /> ); | ||
|
||
user.click( | ||
screen.getByRole( 'button', { | ||
name: 'Dismiss', | ||
} ) | ||
); | ||
|
||
expect( | ||
screen.queryByRole( 'heading', { | ||
name: "You're ready to accept payments!", | ||
} ) | ||
).not.toBeInTheDocument(); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.