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 { schedule } from "@ember/runloop";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import LoadMore from "discourse/mixins/load-more";
|
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 { getOwner } from "discourse-common/lib/get-owner";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
import { observes } from "discourse-common/utils/decorators";
|
||||||
import { on } from "@ember/object/evented";
|
import { on } from "@ember/object/evented";
|
||||||
|
import bootbox from "bootbox";
|
||||||
|
|
||||||
export default Component.extend(LoadMore, {
|
export default Component.extend(LoadMore, {
|
||||||
_initialize: on("init", function () {
|
_initialize: on("init", function () {
|
||||||
@ -94,13 +96,22 @@ export default Component.extend(LoadMore, {
|
|||||||
|
|
||||||
removeDraft(draft) {
|
removeDraft(draft) {
|
||||||
const stream = this.stream;
|
const stream = this.stream;
|
||||||
Draft.clear(draft.draft_key, draft.sequence)
|
bootbox.confirm(
|
||||||
.then(() => {
|
I18n.t("drafts.remove_confirmation"),
|
||||||
stream.remove(draft);
|
I18n.t("no_value"),
|
||||||
})
|
I18n.t("yes_value"),
|
||||||
.catch((error) => {
|
(confirmed) => {
|
||||||
popupAjaxError(error);
|
if (confirmed) {
|
||||||
});
|
Draft.clear(draft.draft_key, draft.sequence)
|
||||||
|
.then(() => {
|
||||||
|
stream.remove(draft);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
popupAjaxError(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
loadMore() {
|
loadMore() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
|
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { visit } from "@ember/test-helpers";
|
import { visit } from "@ember/test-helpers";
|
||||||
import { test } from "qunit";
|
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";
|
import { click } from "@ember/test-helpers";
|
||||||
|
|
||||||
acceptance("User Drafts", function (needs) {
|
acceptance("User Drafts", function (needs) {
|
||||||
@ -12,6 +12,9 @@ acceptance("User Drafts", function (needs) {
|
|||||||
assert.ok(queryAll(".user-stream-item").length === 3, "has drafts");
|
assert.ok(queryAll(".user-stream-item").length === 3, "has drafts");
|
||||||
|
|
||||||
await click(".user-stream-item:last-child .remove-draft");
|
await click(".user-stream-item:last-child .remove-draft");
|
||||||
|
assert.ok(visible(".bootbox"));
|
||||||
|
|
||||||
|
await click(".bootbox .btn-primary");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
queryAll(".user-stream-item").length === 2,
|
queryAll(".user-stream-item").length === 2,
|
||||||
"draft removed, list length diminished by one"
|
"draft removed, list length diminished by one"
|
||||||
|
@ -337,6 +337,7 @@ en:
|
|||||||
drafts:
|
drafts:
|
||||||
resume: "Resume"
|
resume: "Resume"
|
||||||
remove: "Remove"
|
remove: "Remove"
|
||||||
|
remove_confirmation: "Are you sure you want to delete this draft?"
|
||||||
new_topic: "New topic draft"
|
new_topic: "New topic draft"
|
||||||
new_private_message: "New private message draft"
|
new_private_message: "New private message draft"
|
||||||
topic_reply: "Draft reply"
|
topic_reply: "Draft reply"
|
||||||
|
Loading…
Reference in New Issue
Block a user