settings: Add confirmation dialog to delete linkifiers.

Fixes part of #22812.
This commit is contained in:
Ganesh Pawar 2022-09-07 23:59:18 +05:30 committed by GitHub
parent bc317c0d0c
commit 10a0bf4de4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View File

@ -36,6 +36,9 @@ async function test_add_linkifier(page: Page): Promise<void> {
async function test_delete_linkifier(page: Page): Promise<void> { async function test_delete_linkifier(page: Page): Promise<void> {
await page.click(".linkifier_row .delete"); await page.click(".linkifier_row .delete");
await common.wait_for_micromodal_to_open(page);
await page.click("#confirm_delete_linkifiers_modal .dialog_submit_button");
await common.wait_for_micromodal_to_close(page);
await page.waitForSelector(".linkifier_row", {hidden: true}); await page.waitForSelector(".linkifier_row", {hidden: true});
} }

View File

@ -1,9 +1,11 @@
import $ from "jquery"; import $ from "jquery";
import render_confirm_delete_linkifier from "../templates/confirm_dialog/confirm_delete_linkifier.hbs";
import render_admin_linkifier_edit_form from "../templates/settings/admin_linkifier_edit_form.hbs"; import render_admin_linkifier_edit_form from "../templates/settings/admin_linkifier_edit_form.hbs";
import render_admin_linkifier_list from "../templates/settings/admin_linkifier_list.hbs"; import render_admin_linkifier_list from "../templates/settings/admin_linkifier_list.hbs";
import * as channel from "./channel"; import * as channel from "./channel";
import * as confirm_dialog from "./confirm_dialog";
import * as dialog_widget from "./dialog_widget"; import * as dialog_widget from "./dialog_widget";
import {$t_html} from "./i18n"; import {$t_html} from "./i18n";
import * as ListWidget from "./list_widget"; import * as ListWidget from "./list_widget";
@ -181,14 +183,15 @@ export function build_page() {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
const $btn = $(this); const $btn = $(this);
const html_body = render_confirm_delete_linkifier();
const url = "/json/realm/filters/" + encodeURIComponent($btn.attr("data-linkifier-id"));
channel.del({ confirm_dialog.launch({
url: "/json/realm/filters/" + encodeURIComponent($btn.attr("data-linkifier-id")), html_heading: $t_html({defaultMessage: "Delete linkifier?"}),
error(xhr) { html_body,
ui_report.generic_row_button_error(xhr, $btn); id: "confirm_delete_linkifiers_modal",
}, on_click: () => dialog_widget.submit_api_request(channel.del, url),
// There is no need for an on-success action here since the row is removed by loading_spinner: true,
// the `realm_linkifiers` event handler which builds the linkifier list again.
}); });
}); });

View File

@ -0,0 +1,2 @@
<p>{{t "This action cannot be undone."}}</p>