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

Replace the rest of the dialog components #2340

Draft
wants to merge 31 commits into
base: trunk
Choose a base branch
from
Draft

Conversation

c-shultz
Copy link
Contributor

@c-shultz c-shultz commented Feb 25, 2021

Description

Removes the rest of the Calypso Dialog components. To limit the amount of changes I would need to make for each use of the Dialog component, I created a wrapper for the Button from @wordpress/components called ButtonModal that emulates the Dialog component. Mostly this new component is just a vanilla Modal plus a buttons prop that takes an array of buttons to be displayed at the bottom of the modal.

Related issue(s)

#2333

Steps to reproduce & screenshots/GIFs

The reviewer should double check all of the dialogs. Let me know if I can help with accessing them.

Checklist

  • unit tests

Base automatically changed from replace-modal-component to calypso-cleanup February 25, 2021 18:41
@c-shultz c-shultz marked this pull request as ready for review February 25, 2021 19:17
@c-shultz c-shultz changed the title Replace the rest of the modal components Replace the rest of the dialog components Mar 1, 2021
@waclawjacek waclawjacek self-requested a review March 2, 2021 14:52
Copy link
Contributor

@waclawjacek waclawjacek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 👍

I noticed some issues and left some suggestions. I am not sure if all of the design-related ones should be addressed at this stage.

client/components/button-modal/index.js Outdated Show resolved Hide resolved
client/components/button-modal/index.js Outdated Show resolved Hide resolved
Comment on lines -114 to -124
<div className="carrier-accounts__settings-cancel-dialog-header">
<h2 className="carrier-accounts__settings-cancel-dialog-title">
{translate('Cancel connection')}
</h2>
<button
className="carrier-accounts__settings-cancel-dialog-close-button"
onClick={onCancel}
>
<Gridicon icon="cross"/>
</button>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how things got simplified here! 🚀

@@ -46,13 +45,13 @@ const ReprintDialog = props => {
];

return (
<Dialog
<ButtonModal
isVisible={ Boolean( reprintDialog && reprintDialog.labelId === labelId ) }
onClose={ onClose }
buttons={ buttons }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of the buttons is switched between the calypso-cleanup branch and this one.

On calypso-cleanup, the dialog looks as follows:

Markup on 2021-03-04 at 14:21:36

Whereas on this branch:

Markup on 2021-03-04 at 14:22:01

I noticed the buttons now have the float: right rule which they didn't have before which is likely causing this issue.

Comment on lines +37 to +55
describe( 'when buttons are passed as generic objects', () => {
const props = {
isVisible: true,
buttons: [ { label: '1', action: 'yes' }, { label: '2', action: 'no' } ],
}
const wrapper = mount( <ButtonModal { ...props } /> );
it( '2 buttons rendered', () => {
expect( wrapper.find( 'button' ).length ).toBe( 2 );
} );
} );
describe( 'when buttons are passed as Button components', () => {
const props = {
isVisible: true,
buttons: [ <Button />, <Button /> ],
}
const wrapper = mount( <ButtonModal { ...props } /> );
it( '2 buttons rendered', () => {
expect( wrapper.find( 'button' ).length ).toBe( 2 );
} );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be useful to check if the keys are (re)mapped as expected when the buttons are created, or if the props are passed to child components.

@@ -79,7 +78,7 @@ const RefundDialog = props => {
<dt>{ translate( 'Amount eligible for refund' ) }</dt>
<dd>{ getRefundableAmount() }</dd>
</dl>
</Dialog>
</ButtonModal>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The button order is different in this dialog too.

client/components/button-modal/index.js Outdated Show resolved Hide resolved
c-shultz and others added 5 commits March 5, 2021 07:37
Use double quotes

Co-authored-by: Waclaw Jacek <waclaw.jacek@automattic.com>
…ges/predefined-packages.js


Use double quotes

Co-authored-by: Waclaw Jacek <waclaw.jacek@automattic.com>
…ges/package-dialog.js


Use double quotes

Co-authored-by: Waclaw Jacek <waclaw.jacek@automattic.com>
Co-authored-by: Waclaw Jacek <waclaw.jacek@automattic.com>
…er-accounts/list-item.js

Co-authored-by: Waclaw Jacek <waclaw.jacek@automattic.com>
@c-shultz
Copy link
Contributor Author

There's some good issues here found by @waclawjacek. I need to rework some style conflicts which has increased the scope a good amount. I'm going to pause on this, leave the branch, and plan on returning to this once our team is focusing on shipping again.

@c-shultz c-shultz marked this pull request as draft March 15, 2021 19:49
Base automatically changed from calypso-cleanup to trunk June 29, 2021 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants