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

Refactor dialog wrapper component #4594

Merged
merged 4 commits into from
Mar 10, 2020
Merged

Conversation

kravets-levko
Copy link
Collaborator

@kravets-levko kravets-levko commented Jan 27, 2020

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Other

Description

  • Stop using promises to get dialog result; use callback instead.
  • Handle async operations on dialog close/dismiss: show spinner on corresponding button (depending on action - close or dismiss) and wait until operation completes; if operation fails - keep modal visible. This pattern was used in a lot of dialogs, so now this feature is "built-in" and makes dialogs UX more consistent.
  • Refactor: update some dialogs to be function-based components (reduced amount of code and simplified code a bit). Updated only dialogs that needed feature from [2].

Also fixed some minor bugs found during working on these changes.

Related Tickets & Documents

Closes #4566

Copy link
Member

@gabrieldutra gabrieldutra left a comment

Choose a reason for hiding this comment

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

Nice @kravets-levko! 😁

Overall I liked the changes, it's not very different from the promises and it's handy to have the loading state for promises abstracted. One single thing I would review: the onClose name can be a bit confusing, wdyt about using something else? (e.g: onOk - the same Antd uses)

client/app/components/DialogWrapper.jsx Outdated Show resolved Hide resolved
client/app/components/users/CreateUserDialog.jsx Outdated Show resolved Hide resolved
@kravets-levko
Copy link
Collaborator Author

@gabrieldutra

One single thing I would review: the onClose name can be a bit confusing, wdyt about using something else? (e.g: onOk - the same Antd uses)

I see your point, but there's one thing that may be confusing in this case: there are two methods to close dialog: dialog.close(...) to accept it and dialog.dismiss(...) to dismiss. And I tried to keep naming consistent. If we'll decide to rename onClose to something else (e.g. onAccept) - then we have to rename dialog.close() method as well (dialog.accept(...) - ?). So WDYT?

@gabrieldutra
Copy link
Member

For the dialog commands it does feels better to have close and dismiss (those look more like actual actions). So I think we can leave as is and just rename it in case it becomes confusing.

@kravets-levko
Copy link
Collaborator Author

So you offer to keep dialog.close()/.dismiss() methods names, but rename handlers to onAccept/onDismiss, right? Looks a bit weird, but why not 🙂

@gabrieldutra
Copy link
Member

So you offer to keep dialog.close()/.dismiss() methods names, but rename handlers to onAccept/onDismiss, right? Looks a bit weird, but why not slightly_smiling_face

I actually meant to leave all names as they are 😅, but I'm good with any of those options.

@kravets-levko
Copy link
Collaborator Author

I actually meant to leave all names as they are , but I'm good with any of those options.

So okay then, let's keep it as is (does this mean that I'm too lazy? 🤔) I addressed other comments and resolved conflicts - can you please take one more look before I merge it?

@kravets-levko kravets-levko merged commit db71ff3 into master Mar 10, 2020
@kravets-levko kravets-levko deleted the refine-dialog-wrapper branch March 10, 2020 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor showModal to avoid having catch everywhere
3 participants