Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
default_language: Migrate modal to dialog_widget.
Ganesh Paware7b9173ef5b1
diff --git a/frontend_tests/puppeteer_tests/settings.ts b/frontend_tests/puppeteer_tests/settings.tsindex c7f153807db..18df1b5178a 100644--- a/frontend_tests/puppeteer_tests/settings.ts+++ b/frontend_tests/puppeteer_tests/settings.ts@@ -301,7 +301,7 @@ async function test_alert_words_section(page: Page): Promise<void> {async function change_language(page: Page, language_data_code: string): Promise<void> {await page.waitForSelector("#user-display-settings .setting_default_language", {visible: true});await page.click("#user-display-settings .setting_default_language");- await page.waitForSelector("#user_default_language_modal", {visible: true});+ await common.wait_for_micromodal_to_open(page);const language_selector = `a[data-code="${CSS.escape(language_data_code)}"]`;await page.click(language_selector);}diff --git a/static/js/settings.js b/static/js/settings.jsindex 977dc3bdecd..49463330690 100644--- a/static/js/settings.js+++ b/static/js/settings.js@@ -8,7 +8,7 @@ import render_settings_tab from "../templates/settings_tab.hbs";import * as admin from "./admin";import * as blueslip from "./blueslip";import * as common from "./common";-import {$t, $t_html, get_language_list_columns} from "./i18n";+import {$t, $t_html} from "./i18n";import * as overlays from "./overlays";import {page_params} from "./page_params";import * as people from "./people";@@ -99,7 +99,6 @@ export function build_page() {user_can_change_avatar: settings_data.user_can_change_avatar(),user_role_text: people.get_user_type(page_params.user_id),default_language_name: settings_display.user_default_language_name,- language_list_dbl_col: get_language_list_columns(user_settings.default_language),settings_object: user_settings,});diff --git a/static/js/settings_display.js b/static/js/settings_display.jsindex 1c96e317fe5..12f0783fc7f 100644--- a/static/js/settings_display.js+++ b/static/js/settings_display.js@@ -1,8 +1,11 @@import $ from "jquery";+import render_dialog_default_language from "../templates/default_language_modal.hbs";+import * as channel from "./channel";+import * as dialog_widget from "./dialog_widget";import * as emojisets from "./emojisets";-import {$t_html, get_language_name} from "./i18n";+import {$t_html, get_language_list_columns, get_language_name} from "./i18n";import * as loading from "./loading";import * as overlays from "./overlays";import * as settings_org from "./settings_org";@@ -65,10 +68,6 @@ export function set_up(settings_panel) {return;}- $("#user_default_language_modal [data-dismiss]").on("click", () => {- overlays.close_modal("#user_default_language_modal");- });-// Common handler for sending requests to the server when an input// element is changed.container.on("change", "input[type=checkbox], select", function (e) {@@ -96,38 +95,55 @@ export function set_up(settings_panel) {}});- $("#user_default_language_modal")- .find(".language")- .on("click", (e) => {- e.preventDefault();- e.stopPropagation();- overlays.close_modal("#user_default_language_modal");-- const $link = $(e.target).closest("a[data-code]");- const setting_value = $link.attr("data-code");- const data = {default_language: setting_value};-- const new_language = $link.attr("data-name");- container.find(".default_language_name").text(new_language);-- change_display_setting(- data,- container.find(".lang-time-settings-status"),- $t_html(- {- defaultMessage:- "Saved. Please <z-link>reload</z-link> for the change to take effect.",- },- {"z-link": (content_html) => `<a class='reload_link'>${content_html}</a>`},- ),- true,- );- });+ function default_language_modal_post_render() {+ $("#user_default_language_modal")+ .find(".language")+ .on("click", (e) => {+ e.preventDefault();+ e.stopPropagation();+ dialog_widget.close_modal();++ const $link = $(e.target).closest("a[data-code]");+ const setting_value = $link.attr("data-code");+ const data = {default_language: setting_value};++ const new_language = $link.attr("data-name");+ container.find(".default_language_name").text(new_language);++ change_display_setting(+ data,+ container.find(".lang-time-settings-status"),+ $t_html(+ {+ defaultMessage:+ "Saved. Please <z-link>reload</z-link> for the change to take effect.",+ },+ {"z-link": (content_html) => `<a class='reload_link'>${content_html}</a>`},+ ),+ true,+ );+ });+ }container.find(".setting_default_language").on("click", (e) => {e.preventDefault();e.stopPropagation();- overlays.open_modal("#user_default_language_modal");++ const html_body = render_dialog_default_language({+ language_list: get_language_list_columns(user_settings.default_language),+ });++ dialog_widget.launch({+ html_heading: $t_html({defaultMessage: "Select default language"}),+ html_body,+ html_submit_button: $t_html({defaultMessage: "Close"}),+ id: "user_default_language_modal",+ close_on_submit: true,+ focus_submit_on_open: true,+ single_footer_button: true,+ post_render: default_language_modal_post_render,+ on_click: () => {},+ });});$("body").on("click", ".reload_link", () => {diff --git a/static/styles/settings.css b/static/styles/settings.cssindex af3a853b5d9..0ed57bb3253 100644--- a/static/styles/settings.css+++ b/static/styles/settings.css@@ -354,7 +354,7 @@ td .button {text-decoration: none;}- .default_language_modal {+ #user_default_language_modal {table {width: 90%;margin-top: 20px;diff --git a/static/templates/default_language_modal.hbs b/static/templates/default_language_modal.hbsindex a6c48988eea..e160303811c 100644--- a/static/templates/default_language_modal.hbs+++ b/static/templates/default_language_modal.hbs@@ -1,52 +1,38 @@-<div id="{{prefix}}default_language_modal" class="modal hide modal-bg fade default_language_modal" tabindex="-1" role="dialog"- aria-labelledby="{{prefix}}default_language_modal_label" aria-hidden="true">- <div class="modal-header">- <button type="button" class="close" data-dismiss="modal" aria-label="{{t 'Close' }}"><span aria-hidden="true">×</span></button>- <h3 id="{{prefix}}default_language_modal_label">{{t "Select default language" }}</h3>- </div>- <div class="modal-body">- <p>- {{#tr}}- A language is marked as 100% translated only if every string in the web, desktop,- and mobile apps is translated, including administrative UI and error messages.- {{/tr}}- </p>- <p>- {{#tr}}- Zulip's translations are contributed by our amazing community of volunteer- translators. If you'd like to help, see the- <z-link>Zulip translation guidelines</z-link>.- {{#*inline "z-link"}}<a target="_blank" rel="noopener noreferrer" href="https://zulip.readthedocs.io/en/latest/translating/translating.html">{{> @partial-block}}</a>{{/inline}}- {{/tr}}- </p>- <div>- <table>- {{#each language_list}}- <tr>- <td>- <a class="language" data-code="{{this.first.code}}" data-name="{{this.first.name}}">- {{#if this.first.selected}}- <b>{{this.first.name_with_percent}}</b>- {{else}}- {{this.first.name_with_percent}}- {{/if}}- </a>- </td>- <td>- <a class="language" data-code="{{this.second.code}}" data-name="{{this.second.name}}">- {{#if this.second.selected}}- <b>{{this.second.name_with_percent}}</b>- {{else}}- {{this.second.name_with_percent}}- {{/if}}- </a>- </td>- </tr>- {{/each}}- </table>- </div>- </div>- <div class="modal-footer">- <button class="btn btn-primary" data-dismiss="modal">{{t "Close" }}</button>- </div>-</div>+<p>+ {{#tr}}+ A language is marked as 100% translated only if every string in the web, desktop,+ and mobile apps is translated, including administrative UI and error messages.+ {{/tr}}+</p>+<p>+ {{#tr}}+ Zulip's translations are contributed by our amazing community of volunteer+ translators. If you'd like to help, see the+ <z-link>Zulip translation guidelines</z-link>.+ {{#*inline "z-link"}}<a target="_blank" rel="noopener noreferrer" href="https://zulip.readthedocs.io/en/latest/translating/translating.html">{{> @partial-block}}</a>{{/inline}}+ {{/tr}}+</p>+<table>+ {{#each language_list}}+ <tr>+ <td>+ <a class="language" data-code="{{this.first.code}}" data-name="{{this.first.name}}">+ {{#if this.first.selected}}+ <b>{{this.first.name_with_percent}}</b>+ {{else}}+ {{this.first.name_with_percent}}+ {{/if}}+ </a>+ </td>+ <td>+ <a class="language" data-code="{{this.second.code}}" data-name="{{this.second.name}}">+ {{#if this.second.selected}}+ <b>{{this.second.name_with_percent}}</b>+ {{else}}+ {{this.second.name_with_percent}}+ {{/if}}+ </a>+ </td>+ </tr>+ {{/each}}+</table>diff --git a/static/templates/settings/display_settings.hbs b/static/templates/settings/display_settings.hbsindex e1b4bac1bef..821671f6b1e 100644--- a/static/templates/settings/display_settings.hbs+++ b/static/templates/settings/display_settings.hbs@@ -18,8 +18,6 @@<i class="fa fa-pencil"></i></button></div>-- {{> ../default_language_modal language_list=language_list_dbl_col prefix=prefix}}{{/unless}}<div class="input-group">