Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-15128 - add support for interactive dialogs with no elements #2726

Merged
merged 12 commits into from
May 29, 2019

Conversation

andresoro
Copy link
Contributor

Summary

I think this simple change is what is needed to support interactive dialogs with no elements. Since my react/js knowledge is a little limited, I'm not sure if we need to check if the elements array is non null before we render or not.

Ticket Link

Part of MM-15128

Related Pull Requests

@hanzei
Copy link
Contributor

hanzei commented May 1, 2019

Hi @andresoro,

Thanks for the PR. 👍

I've testing it with the demo plugin. See mattermost/mattermost-plugin-demo#28 for the PR that I used.

After creating the dialog with /dialog no-elements the web app crashes and I see the following error in the dev console:

Unhandled promise rejection TypeError: "props.elements is null"
    InteractiveDialog interactive_dialog.jsx:36

Let me know, if you need further information on how to debug this or have other questions.

@hanzei hanzei added the Work in Progress Not yet ready for review label May 1, 2019
@andresoro
Copy link
Contributor Author

Hey @hanzei it looks like I need to add a check to see if the elements array is null or not. I suspected something like this would happen. I appreciate the update for the demo plugin and I am going to use that to test these changes further. Going to continue to work on this.

@andresoro
Copy link
Contributor Author

I used the plugin mentioned above to test and debug the component. Checking for null in the constructor and the render is what's needed to display the interactive dialog properly. The "Confirm" button wasn't doing anything but I'm not sure if that's by design with the plugin or with the dialog component. Also, it seems like there is a blank space left over from Modal.Body since there are no elements.

It would look cleaner if the Modal.Body was dropped when the elements array is null.

@hanzei
Copy link
Contributor

hanzei commented May 1, 2019

Thanks for the update! The dialog opens now!

The "Confirm" button wasn't doing anything but I'm not sure if that's by design with the plugin or with the dialog component.

The problem is caused by a TypeError:

Unhandled promise rejection TypeError: "elements is null"
    _callee$ interactive_dialog.jsx:56

Would you please fix this? Then we can queue this PR for PM review.

And could you also merge master into this? We did some changes to the build system yesterday. Sorry for the inconvenience.

@andresoro
Copy link
Contributor Author

Went ahead and fixed that error and also changed the Modal.Body to display only if there are elements. I'm not sure if the way I did it was proper or hackish since my react/JS knowledge is rusty.

@hanzei
Copy link
Contributor

hanzei commented May 1, 2019

@andresoro Thanks for the update. This works great! One visual problem I've noticed is that modal-header has a border-bottom and .modal-footer has a border-top. This makes up for a doubled border. Would you be open on changing this that it only shows one border?

@andresoro
Copy link
Contributor Author

andresoro commented May 1, 2019

Two borders would be the expected behavior when we have elements to display, correct? So we should only have one border when there are no elements.

Kind of unsure how to go about this.

@hanzei hanzei requested a review from jasonblais May 1, 2019 17:35
@hanzei hanzei added 1: PM Review Requires review by a product manager Setup Old Test Server Triggers the creation of a test server and removed Work in Progress Not yet ready for review labels May 1, 2019
@hanzei
Copy link
Contributor

hanzei commented May 1, 2019

@andresoro I see your points. Let's ask our Product Manager @jasonblais what he thinks about this.

@jasonblais
Copy link
Contributor

Thanks for the contribution! Happy to take a look at it and see how it looks with two borders when there are no elements.

Looks like the build failed, can you help take a look at it @andresoro when you have the chance?

@andresoro
Copy link
Contributor Author

andresoro commented May 1, 2019

Hey @jasonblais, I ran the commands that the CI ran and it works on my machine. I also did some searching and found that someone else had this same issue on mattermost-mobile #2405. Unsure how to proceed with this one.

Edit: as mentioned below, these were lint errors and I just hadn't pushed yet.

@cpanato cpanato removed the Setup Old Test Server Triggers the creation of a test server label May 2, 2019
@cpanato
Copy link
Contributor

cpanato commented May 2, 2019

some lint errors

/root/mattermost-webapp/components/interactive_dialog/interactive_dialog.jsx
   68:16  error  Trailing spaces not allowed  no-trailing-spaces
   70:1   error  Trailing spaces not allowed  no-trailing-spaces
  192:1   error  Trailing spaces not allowed  no-trailing-spaces

@hanzei hanzei added the Setup Old Test Server Triggers the creation of a test server label May 2, 2019
@jasonblais jasonblais added Setup Old Test Server Triggers the creation of a test server and removed Setup Old Test Server Triggers the creation of a test server labels May 4, 2019
@jasonblais
Copy link
Contributor

jasonblais commented May 4, 2019

@cpanato The generated test server wasn't loading for me when I tried to access it. I've tried to generate a new one, but it seems to fail.

Next week, please help take a look what might be causing it?

@jasonblais jasonblais added Setup Old Test Server Triggers the creation of a test server and removed Setup Old Test Server Triggers the creation of a test server labels May 6, 2019
@andresoro
Copy link
Contributor Author

andresoro commented May 19, 2019

@jasonblais So I did a bit of research on this and found that React allows for inline styling within components. The docs say it is not the best way to style components but it also allows for conditional styling based on the components props. In our case it's whether or not there are elements in the dialog.

So I modified the Modal.Header tag to the following:

<Modal.Header
                    closeButton={true}
                    style={{borderBottom: elements == null && '0px'}}
>

Which essentially changes the border-bottom attribute to not show if there aren't elements. I tested with /dialog no-elements and the output looks like:

Screen Shot 2019-05-18 at 8 12 59 PM

Edit: Update Modal.Header tag to not crash when regular dialogs are called.

Andres Orozco added 2 commits May 18, 2019 20:30
* Fix in line style so regular dialogs do not crash
* fix linting errors
@jasonblais jasonblais added the Setup Old Test Server Triggers the creation of a test server label May 19, 2019
Copy link
Contributor

@jasonblais jasonblais left a comment

Choose a reason for hiding this comment

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

Tested with the demo plugin Hanzei shared using

/dialog - Open an Interactive Dialog with a few elements
/dialog no-elements - Open an Interactive Dialog with no elements
/dialog help - Show this help text

Works for me as expected. Thanks @andresoro!

@jasonblais jasonblais requested review from asaadmahmood and hanzei May 19, 2019 01:51
@jasonblais jasonblais removed their assignment May 19, 2019
@jasonblais jasonblais added 2: Dev Review Requires review by a core commiter and removed 1: PM Review Requires review by a product manager labels May 19, 2019
@hanzei hanzei requested review from cpoile and removed request for hanzei May 21, 2019 05:57
@hanzei hanzei removed the Setup Old Test Server Triggers the creation of a test server label May 21, 2019
@hanzei
Copy link
Contributor

hanzei commented May 27, 2019

@asaadmahmood @cpoile Gentle reminder to review this PR

Copy link
Member

@cpoile cpoile left a comment

Choose a reason for hiding this comment

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

Nice, thank you! Just a little request, otherwise good to go.

<Modal.Title
componentClass='h1'
id='interactiveDialogModalLabel'
>
{icon}{title}
</Modal.Title>
</Modal.Header>
<Modal.Body>
{elements && <Modal.Body>
Copy link
Member

Choose a reason for hiding this comment

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

👍

@andresoro
Copy link
Contributor Author

@cpoile thanks for the review. I'll make the changes and push 👍.

@cpoile
Copy link
Member

cpoile commented May 27, 2019

Great, just remember to click request re-review so I know to come back. Thanks!

@hanzei hanzei requested a review from cpoile May 29, 2019 05:01
Copy link
Member

@cpoile cpoile left a comment

Choose a reason for hiding this comment

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

nice work @andresoro!

@cpoile cpoile merged commit 3f0e901 into mattermost:master May 29, 2019
@hanzei hanzei added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels May 29, 2019
@hanzei hanzei added this to the v5.14.0 milestone May 29, 2019
@amyblais amyblais added Changelog/Done Required changelog entry has been written Docs/Done Required documentation has been written labels Jul 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Done Required changelog entry has been written Docs/Done Required documentation has been written
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants