dialog_widget: Use _html variables in template.

This is done to ensure that variables in HTML string format
which should not be escaped in templates, have a
consistent _html suffix.

The commits that follow do the same style of refactors
in other areas.

Discussion: https://chat.zulip.org/#narrow/channel/6-frontend/topic/Add.20linter.20rule.20to.20denote.20HTML.20string.20in.20template/near/2232128
Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com>
This commit is contained in:
apoorvapendse
2025-07-30 14:09:52 +05:30
committed by Tim Abbott
parent 4d49fa6fbb
commit 370e6765f8
2 changed files with 11 additions and 11 deletions

View File

@@ -194,16 +194,16 @@ export function launch(conf: DialogWidgetConfig): string {
widget_id_counter += 1;
const modal_unique_id = current_dialog_widget_id();
const html_submit_button = conf.html_submit_button ?? $t_html({defaultMessage: "Save changes"});
const html_exit_button = conf.html_exit_button ?? $t_html({defaultMessage: "Cancel"});
const submit_button_html = conf.html_submit_button ?? $t_html({defaultMessage: "Save changes"});
const exit_button_html = conf.html_exit_button ?? $t_html({defaultMessage: "Cancel"});
const html = render_dialog_widget({
modal_unique_id,
html_heading: conf.html_heading,
heading_html: conf.html_heading,
text_heading: conf.text_heading,
link: conf.help_link,
html_submit_button,
html_exit_button,
html_body: conf.html_body,
submit_button_html,
exit_button_html,
body_html: conf.html_body,
id: conf.id,
single_footer_button: conf.single_footer_button,
always_visible_scrollbar: conf.always_visible_scrollbar,

View File

@@ -3,8 +3,8 @@
<div {{#if id}}id="{{id}}" {{/if}}class="modal__container" role="dialog" aria-modal="true" aria-labelledby="dialog_title">
<header class="modal__header">
<h1 class="modal__title dialog_heading">
{{#if html_heading}}
{{{ html_heading }}}
{{#if heading_html}}
{{{ heading_html }}}
{{else}}
{{ text_heading }}
{{/if}}
@@ -16,18 +16,18 @@
</header>
<main class="modal__content" data-simplebar data-simplebar-tab-index="-1" {{#if always_visible_scrollbar}}data-simplebar-auto-hide="false"{{/if}}>
<div class="alert" id="dialog_error"></div>
{{{ html_body }}}
{{{ body_html }}}
</main>
<footer class="modal__footer">
{{#if footer_minor_text }}
<div class="dialog-widget-footer-minor-text">{{footer_minor_text}}</div>
{{/if}}
{{#unless single_footer_button}}
<button class="modal__button dialog_exit_button" aria-label="{{t 'Close this dialog window' }}" data-micromodal-close>{{{ html_exit_button }}}</button>
<button class="modal__button dialog_exit_button" aria-label="{{t 'Close this dialog window' }}" data-micromodal-close>{{{ exit_button_html }}}</button>
{{/unless}}
<div class="dialog_submit_button_container">
<button class="modal__button dialog_submit_button"{{#if single_footer_button}} aria-label="{{t 'Close this dialog window' }}" data-micromodal-close{{/if}}>
<span class="submit-button-text">{{{ html_submit_button }}}</span>
<span class="submit-button-text">{{{ submit_button_html }}}</span>
<div class="modal__spinner"></div>
</button>
</div>