mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 03:09:29 +08:00
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")
|
@discourseComputed("categoryReadOnlyBanner", "hasDraft")
|
||||||
createTopicClass(categoryReadOnlyBanner, hasDraft) {
|
createTopicClass(categoryReadOnlyBanner, hasDraft) {
|
||||||
if (categoryReadOnlyBanner && !hasDraft) {
|
let classNames = ["btn-default"];
|
||||||
return "btn-default disabled";
|
if (hasDraft) {
|
||||||
} else {
|
classNames.push("open-draft");
|
||||||
return "btn-default";
|
} else if (categoryReadOnlyBanner) {
|
||||||
|
classNames.push("disabled");
|
||||||
}
|
}
|
||||||
|
return classNames.join(" ");
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("hasDraft")
|
@discourseComputed("hasDraft")
|
||||||
|
|
|
@ -5,6 +5,7 @@ import Draft from "discourse/models/draft";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import LoadMore from "discourse/mixins/load-more";
|
import LoadMore from "discourse/mixins/load-more";
|
||||||
import Post from "discourse/models/post";
|
import Post from "discourse/models/post";
|
||||||
|
import { NEW_TOPIC_KEY } from "discourse/models/composer";
|
||||||
import bootbox from "bootbox";
|
import bootbox from "bootbox";
|
||||||
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";
|
||||||
|
@ -121,6 +122,9 @@ export default Component.extend(LoadMore, {
|
||||||
Draft.clear(draft.draft_key, draft.sequence)
|
Draft.clear(draft.draft_key, draft.sequence)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
stream.remove(draft);
|
stream.remove(draft);
|
||||||
|
if (draft.draft_key === NEW_TOPIC_KEY) {
|
||||||
|
this.currentUser.set("has_topic_draft", false);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
popupAjaxError(error);
|
popupAjaxError(error);
|
||||||
|
|
|
@ -16,7 +16,7 @@ acceptance("User Drafts", function (needs) {
|
||||||
await visit("/u/eviltrout/activity/drafts");
|
await visit("/u/eviltrout/activity/drafts");
|
||||||
assert.strictEqual(count(".user-stream-item"), 3, "has 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"));
|
assert.ok(visible(".bootbox"));
|
||||||
|
|
||||||
await click(".bootbox .btn-primary");
|
await click(".bootbox .btn-primary");
|
||||||
|
@ -25,6 +25,13 @@ acceptance("User Drafts", function (needs) {
|
||||||
2,
|
2,
|
||||||
"draft removed, list length diminished by one"
|
"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) {
|
test("Stream - resume draft", async function (assert) {
|
||||||
|
|
|
@ -295,6 +295,7 @@ export default {
|
||||||
day_6_end_time: 1020,
|
day_6_end_time: 1020,
|
||||||
},
|
},
|
||||||
timezone: "Australia/Brisbane",
|
timezone: "Australia/Brisbane",
|
||||||
|
has_topic_draft: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"/u/eviltrout/card.json": {
|
"/u/eviltrout/card.json": {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user