From 7b8a1a396024d1eef2d65ad368aefc2f3b0694b7 Mon Sep 17 00:00:00 2001 From: Jan Cernik <66427541+jancernik@users.noreply.github.com> Date: Thu, 27 Oct 2022 10:16:00 -0300 Subject: [PATCH] DEV: Replace bootbox confirm dialog (#142) --- .../admin/components/channel-details.js | 25 ++++++++----------- .../acceptance/chat-integration-test.js | 6 ++--- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/assets/javascripts/admin/components/channel-details.js b/assets/javascripts/admin/components/channel-details.js index e89b1e8..53b21ba 100644 --- a/assets/javascripts/admin/components/channel-details.js +++ b/assets/javascripts/admin/components/channel-details.js @@ -1,26 +1,23 @@ import Component from "@ember/component"; import { popupAjaxError } from "discourse/lib/ajax-error"; import I18n from "I18n"; -import bootbox from "bootbox"; +import { inject as service } from "@ember/service"; export default Component.extend({ + dialog: service(), classNames: ["channel-details"], actions: { deleteChannel(channel) { - bootbox.confirm( - I18n.t("chat_integration.channel_delete_confirm"), - I18n.t("no_value"), - I18n.t("yes_value"), - (result) => { - if (result) { - channel - .destroyRecord() - .then(() => this.refresh()) - .catch(popupAjaxError); - } - } - ); + this.dialog.deleteConfirm({ + message: I18n.t("chat_integration.channel_delete_confirm"), + didConfirm: () => { + return channel + .destroyRecord() + .then(() => this.refresh()) + .catch(popupAjaxError); + }, + }); }, editRule(rule) { diff --git a/test/javascripts/acceptance/chat-integration-test.js b/test/javascripts/acceptance/chat-integration-test.js index 8fe392f..59f8665 100755 --- a/test/javascripts/acceptance/chat-integration-test.js +++ b/test/javascripts/acceptance/chat-integration-test.js @@ -205,10 +205,10 @@ acceptance("Chat Integration", function (needs) { ); await click(".channel-header .delete-channel"); - assert.ok(exists("div.bootbox"), "modal is displayed"); - await click("div.bootbox .btn-primary"); + assert.ok(exists("div.dialog-content"), "modal is displayed"); + await click("div.dialog-content .btn-danger"); - assert.notOk(exists("div.bootbox"), "modal has closed"); + assert.notOk(exists("div.dialog-content"), "modal has closed"); }); test("Delete rule works", async function (assert) {