Add a dialog component.

Review Request #14054 — Created July 25, 2024 and updated

Information

Ink
master

Reviewers

This change adds a new dialog component to Ink. It uses the new(ish)
<dialog> element, which comes with a bunch of advantages. It can be
shown as either a modal or non-modal.

The dialog has three areas that can be customized: the title, the body,
and actions. Actions can be separated into primary (right-aligned) and
secondary (left-aligned).

Actions can be specified either as regular buttons (or other elements),
or as a special DialogAction. The DialogAction exists to prevent
boilerplate for common cases, and has two modes: close or callback. If
an action uses a callback and said callback returns a promise, all of
the dialog's actions will be disabled while that promise runs, and the
action that triggered it will be shown as busy.

  • Used dialog in storybook.
  • Used this from some code in Review Board.
Summary ID
Add a dialog component.
This change adds a new dialog component to Ink. It uses the new(ish) `<dialog>` element, which comes with a bunch of advantages. It can be shown as either a modal or non-modal. The dialog has three areas that can be customized: the title, the body, and actions. Actions can be separated into primary (right-aligned) and secondary (left-aligned). Actions can be specified either as regular buttons (or other elements), or as a special `DialogAction`. The `DialogAction` exists to prevent boilerplate for common cases, and has two modes: close or callback. If an action uses a callback and said callback returns a promise, all of the dialog's actions will be disabled while that promise runs, and the action that triggered it will be shown as busy. Testing Done: - Used dialog in storybook. - Used this from some code in Review Board.
1de317270b5a8beea40749113d095841a409cf3a

Description From Last Updated

I feel like this blends far too muhc. We may need to enhance those edges or tone down the backdrop …

chipx86chipx86

Not seeing any usage of NON_MODAL, and it looks like the only usage of MODAL isn't really needed given the …

chipx86chipx86

I learned this the hard way recently. We actually would want to make sure we've set this in preinitialize or …

chipx86chipx86

Let's pull out this.el. We reference it multiple times.

chipx86chipx86

Do we want to just embed all the above straight into here? Unless we want to hide the actions areas/subareas …

chipx86chipx86

These are missing docs.

chipx86chipx86

This doesn't seem necessary.

chipx86chipx86

Let's document each of these. It's unclear from the enums what they really do.

chipx86chipx86

Can we move these to option-based arguments? We're bound to want to add to this in time (or have subclasses …

chipx86chipx86

Call sites to this are super confusing. Can we move to option-based arguments?

chipx86chipx86

Do we want to handle any cases where this is something other than a DialogActionView? If this is explicitly allowed, …

chipx86chipx86

This is missing docs.

chipx86chipx86

The ordering all throughout this is inconsistent with other components. It should be alphabetical order. I see that it's in …

chipx86chipx86

Missing docs.

chipx86chipx86

These are also missing docs.

chipx86chipx86
chipx86
  1. Thanks for taking this on and getting it all in shape!

  2. Show all issues

    I feel like this blends far too muhc. We may need to enhance those edges or tone down the backdrop a bit.

  3. src/ink/js/components/views/dialogView.ts (Diff revision 1)
     
     
     
    Show all issues

    Not seeing any usage of NON_MODAL, and it looks like the only usage of MODAL isn't really needed given the boolean nature of the argument in question.

    1. These are really just there as sugar so callers can do dialogView.open(DialogView.MODAL) instead of dialogView.open(true)

    2. Maybe we should take arbitrary options then, giving us some room for expansion?

  4. Show all issues

    I learned this the hard way recently. We actually would want to make sure we've set this in preinitialize or it won't make it to the element.

    Order of construction is:

    1. Set cid
    2. Call preinitialize()
    3. Initialize element and set attributes
    4. Call initialize().
  5. src/ink/js/components/views/dialogView.ts (Diff revision 1)
     
     
     
    Show all issues

    Let's pull out this.el. We reference it multiple times.

  6. src/ink/js/components/views/dialogView.ts (Diff revision 1)
     
     
     
     
     
     
     
     
    Show all issues

    Do we want to just embed all the above straight into here?

    Unless we want to hide the actions areas/subareas based on the content.

  7. src/ink/less/components/schemas/dialog.schema.less (Diff revision 1)
     
     
     
     
     
     
     
     
    Show all issues

    These are missing docs.

  8. 
      
david
maubin
  1. Ship It!
  2. 
      
david
maubin
  1. Ship It!
  2. 
      
david
david
chipx86
  1. 
      
  2. src/ink/js/components/views/dialogView.ts (Diff revision 5)
     
     
     
     
    Show all issues

    This doesn't seem necessary.

  3. src/ink/js/components/views/dialogView.ts (Diff revision 5)
     
     
     
     
     
     
    Show all issues

    Let's document each of these. It's unclear from the enums what they really do.

  4. Show all issues

    Can we move these to option-based arguments? We're bound to want to add to this in time (or have subclasses add to it).

    At that point, I'd also prefer just a boolean for the modal support, since the readability issue is covered.

  5. src/ink/js/components/views/dialogView.ts (Diff revision 5)
     
     
     
     
     
    Show all issues

    Call sites to this are super confusing. Can we move to option-based arguments?

  6. src/ink/js/components/views/dialogView.ts (Diff revision 5)
     
     
     
    Show all issues

    Do we want to handle any cases where this is something other than a DialogActionView? If this is explicitly allowed, let's document that.

  7. Show all issues

    This is missing docs.

  8. src/ink/less/components/schemas/dialog.schema.less (Diff revision 5)
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    The ordering all throughout this is inconsistent with other components. It should be alphabetical order. I see that it's in rough structural order, but not all components work that way, so alphabetical provides the best consistency and makes it easier to find the right part.

  9. Show all issues

    Missing docs.

  10. src/ink/less/themes/default/components/dialog.theme.less (Diff revision 5)
     
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    These are also missing docs.

  11. 
      
david
Review request changed
Commits:
Summary ID
Add a dialog component.
This change adds a new dialog component to Ink. It uses the new(ish) `<dialog>` element, which comes with a bunch of advantages. It can be shown as either a modal or non-modal. The dialog has three areas that can be customized: the title, the body, and actions. Actions can be separated into primary (right-aligned) and secondary (left-aligned). Actions can be specified either as regular buttons (or other elements), or as a special `DialogAction`. The `DialogAction` exists to prevent boilerplate for common cases, and has two modes: close or callback. If an action uses a callback and said callback returns a promise, all of the dialog's actions will be disabled while that promise runs, and the action that triggered it will be shown as busy. Testing Done: - Used dialog in storybook. - Used this from some code in Review Board.
e8639dca34d99ae0c040b9bbf3861d2d98e19bd9
Add a dialog component.
This change adds a new dialog component to Ink. It uses the new(ish) `<dialog>` element, which comes with a bunch of advantages. It can be shown as either a modal or non-modal. The dialog has three areas that can be customized: the title, the body, and actions. Actions can be separated into primary (right-aligned) and secondary (left-aligned). Actions can be specified either as regular buttons (or other elements), or as a special `DialogAction`. The `DialogAction` exists to prevent boilerplate for common cases, and has two modes: close or callback. If an action uses a callback and said callback returns a promise, all of the dialog's actions will be disabled while that promise runs, and the action that triggered it will be shown as busy. Testing Done: - Used dialog in storybook. - Used this from some code in Review Board.
1de317270b5a8beea40749113d095841a409cf3a

Checks run (2 succeeded)

flake8 passed.
JSHint passed.