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 certain modals to confirm_dialog
module
#18629
Conversation
82b300a
to
4cec136
Compare
</div> | ||
<p> | ||
{{#tr}} | ||
Are you sure you want to resend the invitation to {{email}}? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want the previous formatting to decorate the email address.
static/js/settings_invites.js
Outdated
}, | ||
confirm_dialog.launch({ | ||
parent: modal_parent, | ||
html_heading: $t_html({defaultMessage: "Resend invitation to {email}"}, {email}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The heading might be better as just "Resend invitation", rather than showing the email address twice (here and in the body of the template).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Will add a separate commit for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe same goes for "Revoke invitation" as well ?
</div> | ||
<p> | ||
{{#tr}} | ||
By deactivating <strong>{{username}}</strong> <{{email}}>, they will be logged out immediately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #*inline
z-user
syntax is important for the translation experience (and is why you're getting CI failures).
Please preserve that formatting of the translated strings.
@aryanshridhar thanks for working on this! I'm excited about this cleanup, since it lets us delete a ton of duplicated HTML. Can you fix the issues I noted, and post before/after screenshots for every modal to confirm that they're all visually identical to before the migration. (I guess except for the one I suggested a small wording change to). (BTW, is there something we could have documented better to explain why the Once you have that (and have done a self-review to confirm this has the exact same logic as before; and/or any changes are clearly explained in the commit message or done in prep commits), it'd be great if you can post in #frontend and get a code review on it from another contributor. |
909283a
to
e5b6ed8
Compare
Thanks @timabbott, Yea, I guess documenting the purpose of |
The |
@sahil839 are you up for doing a review / QA pass on this? |
static/js/stream_create.js
Outdated
stream_name, | ||
count: principals.length, | ||
}); | ||
$("#stream-creation").append(invites_warning_modal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for changing the parent element of this modal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment here.
static/js/settings_invites.js
Outdated
$("#do_revoke_invite_button").off("click"); | ||
$("#do_revoke_invite_button").on("click", do_revoke_invite); | ||
const modal_parent = $("#admin_invites_table"); | ||
const html_body = render_settings_revoke_invite_modal(ctx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also, why the modal parent is changed. And if there is a reason we want to use this, we can simply remove the #revoke_invite_modal_holder
element.
I tested it locally and it works fine. |
I guess its better if I modify the parent elements as they were earlier since they were specifically designed for it. Thoughts @sahil839. |
There is no problem with current changes as they look and behave in the same way, but am just not sure how these parent elements are/were decided. |
I think it's worth removing unnecessary elements. We probably mostly want a policy around parent elements for modals to make that not a thing we need to think about; possibly there should just be a single fixed parent element for all modals in the app, since I don't see why it'd matter what their parent is. |
<p> | ||
{{#tr}} | ||
By deactivating <z-user></z-user>, they will be logged out immediately. | ||
{{#*inline "z-user"}}<strong>{{username}}</strong> <{{email}}>{{/inline}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You appear to have removes some of the HTML here for styling the username and email; why?
As a sidenote, it's really harmful to have hidden functional changes like this that are not explained clearly in the commit message; only the most watchful reviewer will notice, and it can lead to significant bugs/regressions.
(The last 3 commits all have this issue with either the content or heading).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Umm, Apologies if I am missing something out here @timabbott.
By "HTML here for styling", I guess you meant the CSS classes like - user_name
and email
?
If that's the case, the classes like user_name
and email
are added so that later they can be populated with respective usernames and email.
Looking at the browser inspector, they don't seem to be really adding any styling for the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this comment contains the before/after screenshots within it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, great; I think the key thing here is that it's really important to explain that sort of reasoning in the commit message, because it's not at all obvious that this is what those are for (though in retrospect it totally makes sense).
confirm_dialog.launch({ | ||
parent: modal_parent, | ||
html_heading: $t_html( | ||
{defaultMessage: "Archive stream {stream}"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stream
name here seems to not have the styling it had previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe similar comment here as the above one ?
<div class="modal-header"> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="{{t 'Close' }}"><span aria-hidden="true">×</span></button> | ||
<h3 id="deactivate_realm_modal_label"> | ||
{{t "Deactivate organization" }} <span class="realm_name"></span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this realm_name
spam display the realm name before this change?
I'm not sure we need it here (we definitely want it in the modal somewhere), but we shouldn't be accidentally changing it in this commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this would have been a key detail to explain in the commit message.
Can you start a #design thread with that screenshot about where we should put the identity of the organization to deactivate? I do think we probably want to display it somewhere in that modal.
I merged the first several commits as the series ending with 68111d9. Thanks @aryanshridhar! There may be a second pass of work worth doing of reading the code surrounding these for things that don't make sense; e.g. with the I'd expect us to just store those values in the closure rather in the DOM, i.e. the |
Cool! Working on it |
e5b6ed8
to
1d93ac2
Compare
@sahil839, I decided these parent elements by using browser inspector and figuring out the parent element for the relevant modal. |
Can you review it again @timabbott ? |
…dule. The "email" span in the old modal was not used for styling, just to support updating the field visually.
…ule. The stream_name CSS class in the heading before this change had no functional effect.
…ule. The realm_name field in the old modal was always empty.
1d93ac2
to
281c7da
Compare
Merged, after extending the commit messages to explain that the CSS class spans that were removed were not functional. Thanks @aryanshridhar! I think we still have a couple modals that can be migrated:
I'll start a #frontend thread about this soon, but we have a goal of moving everything out of I think it could also be a good followup to move all the confirm_dialog templates to |
Refactored multiple UI modals to use the
confirm_dialog
module. Essentially, converted the ones that presented the user with a simple 'Cancel'/'Confirm' type question.These includes:
Maybe @sumanthvrao can have a look at it :)