mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 12:43:54 -06:00
UX: add a confirmation dialog for draft deletion (#11198)
This commit is contained in:
parent
6ea9eb0260
commit
80759c9619
@ -1,3 +1,4 @@
|
||||
import I18n from "I18n";
|
||||
import { schedule } from "@ember/runloop";
|
||||
import Component from "@ember/component";
|
||||
import LoadMore from "discourse/mixins/load-more";
|
||||
@ -9,6 +10,7 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { observes } from "discourse-common/utils/decorators";
|
||||
import { on } from "@ember/object/evented";
|
||||
import bootbox from "bootbox";
|
||||
|
||||
export default Component.extend(LoadMore, {
|
||||
_initialize: on("init", function () {
|
||||
@ -94,13 +96,22 @@ export default Component.extend(LoadMore, {
|
||||
|
||||
removeDraft(draft) {
|
||||
const stream = this.stream;
|
||||
Draft.clear(draft.draft_key, draft.sequence)
|
||||
.then(() => {
|
||||
stream.remove(draft);
|
||||
})
|
||||
.catch((error) => {
|
||||
popupAjaxError(error);
|
||||
});
|
||||
bootbox.confirm(
|
||||
I18n.t("drafts.remove_confirmation"),
|
||||
I18n.t("no_value"),
|
||||
I18n.t("yes_value"),
|
||||
(confirmed) => {
|
||||
if (confirmed) {
|
||||
Draft.clear(draft.draft_key, draft.sequence)
|
||||
.then(() => {
|
||||
stream.remove(draft);
|
||||
})
|
||||
.catch((error) => {
|
||||
popupAjaxError(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
loadMore() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance, visible } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click } from "@ember/test-helpers";
|
||||
|
||||
acceptance("User Drafts", function (needs) {
|
||||
@ -12,6 +12,9 @@ acceptance("User Drafts", function (needs) {
|
||||
assert.ok(queryAll(".user-stream-item").length === 3, "has drafts");
|
||||
|
||||
await click(".user-stream-item:last-child .remove-draft");
|
||||
assert.ok(visible(".bootbox"));
|
||||
|
||||
await click(".bootbox .btn-primary");
|
||||
assert.ok(
|
||||
queryAll(".user-stream-item").length === 2,
|
||||
"draft removed, list length diminished by one"
|
||||
|
@ -337,6 +337,7 @@ en:
|
||||
drafts:
|
||||
resume: "Resume"
|
||||
remove: "Remove"
|
||||
remove_confirmation: "Are you sure you want to delete this draft?"
|
||||
new_topic: "New topic draft"
|
||||
new_private_message: "New private message draft"
|
||||
topic_reply: "Draft reply"
|
||||
|
Loading…
Reference in New Issue
Block a user