FIX: Remove 'Open Draft' label after topic draft deleted (#14997)
* FIX: Remove 'Open Draft' label after topic draft deleted
This commit is contained in:
parent
e906596942
commit
97b27a7426
|
@ -59,11 +59,13 @@ export default Component.extend(FilterModeMixin, {
|
|||
|
||||
@discourseComputed("categoryReadOnlyBanner", "hasDraft")
|
||||
createTopicClass(categoryReadOnlyBanner, hasDraft) {
|
||||
if (categoryReadOnlyBanner && !hasDraft) {
|
||||
return "btn-default disabled";
|
||||
} else {
|
||||
return "btn-default";
|
||||
let classNames = ["btn-default"];
|
||||
if (hasDraft) {
|
||||
classNames.push("open-draft");
|
||||
} else if (categoryReadOnlyBanner) {
|
||||
classNames.push("disabled");
|
||||
}
|
||||
return classNames.join(" ");
|
||||
},
|
||||
|
||||
@discourseComputed("hasDraft")
|
||||
|
|
|
@ -5,6 +5,7 @@ import Draft from "discourse/models/draft";
|
|||
import I18n from "I18n";
|
||||
import LoadMore from "discourse/mixins/load-more";
|
||||
import Post from "discourse/models/post";
|
||||
import { NEW_TOPIC_KEY } from "discourse/models/composer";
|
||||
import bootbox from "bootbox";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { observes } from "discourse-common/utils/decorators";
|
||||
|
@ -121,6 +122,9 @@ export default Component.extend(LoadMore, {
|
|||
Draft.clear(draft.draft_key, draft.sequence)
|
||||
.then(() => {
|
||||
stream.remove(draft);
|
||||
if (draft.draft_key === NEW_TOPIC_KEY) {
|
||||
this.currentUser.set("has_topic_draft", false);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
popupAjaxError(error);
|
||||
|
|
|
@ -16,7 +16,7 @@ acceptance("User Drafts", function (needs) {
|
|||
await visit("/u/eviltrout/activity/drafts");
|
||||
assert.strictEqual(count(".user-stream-item"), 3, "has drafts");
|
||||
|
||||
await click(".user-stream-item:last-child .remove-draft");
|
||||
await click(".user-stream-item:first-child .remove-draft");
|
||||
assert.ok(visible(".bootbox"));
|
||||
|
||||
await click(".bootbox .btn-primary");
|
||||
|
@ -25,6 +25,13 @@ acceptance("User Drafts", function (needs) {
|
|||
2,
|
||||
"draft removed, list length diminished by one"
|
||||
);
|
||||
|
||||
await visit("/");
|
||||
assert.ok(visible("#create-topic"));
|
||||
assert.ok(
|
||||
!exists("#create-topic.open-draft"),
|
||||
"Open Draft button is not present"
|
||||
);
|
||||
});
|
||||
|
||||
test("Stream - resume draft", async function (assert) {
|
||||
|
|
|
@ -295,6 +295,7 @@ export default {
|
|||
day_6_end_time: 1020,
|
||||
},
|
||||
timezone: "Australia/Brisbane",
|
||||
has_topic_draft: true
|
||||
},
|
||||
},
|
||||
"/u/eviltrout/card.json": {
|
||||
|
|
Loading…
Reference in New Issue