FIX: Bypass draft check when switching to shared draft. (#6782)

This commit is contained in:
Bianca Nenciu
2018-12-19 11:25:33 +02:00
committed by Régis Hanol
parent 0ce5f05b2a
commit 7050ce4638
3 changed files with 17 additions and 1 deletions

View File

@ -786,7 +786,14 @@ export default Ember.Controller.extend({
// or get a draft sequence number
if (!opts.draft || opts.draftSequence === undefined) {
return Draft.get(opts.draftKey)
.then(data => self.confirmDraftAbandon(data))
.then(data => {
if (opts.skipDraftCheck) {
data.draft = undefined;
return data;
}
return self.confirmDraftAbandon(data);
})
.then(data => {
opts.draft = opts.draft || data.draft;

View File

@ -298,6 +298,7 @@ export default DropdownSelectBoxComponent.extend({
options.action = action;
options.categoryId = this.get("composerModel.categoryId");
options.topicTitle = this.get("composerModel.title");
options.skipDraftCheck = true;
this._openComposer(options);
},

View File

@ -1,5 +1,6 @@
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
import { _clearSnapshots } from "select-kit/components/composer-actions";
import { toggleCheckDraftPopup } from "discourse/controllers/composer";
acceptance("Composer Actions", {
loggedIn: true,
@ -125,11 +126,16 @@ QUnit.test("replying to post - reply_as_new_topic", async assert => {
});
QUnit.test("shared draft", async assert => {
toggleCheckDraftPopup(true);
const composerActions = selectKit(".composer-actions");
await visit("/");
await click("#create-topic");
await fillIn("#reply-title", "This is the new text for the title");
await fillIn(".d-editor-input", "This is the new text for the post");
await composerActions.expand();
await composerActions.selectRowByValue("shared_draft");
@ -138,6 +144,8 @@ QUnit.test("shared draft", async assert => {
I18n.t("composer.create_shared_draft")
);
assert.ok(find("#reply-control.composing-shared-draft").length === 1);
toggleCheckDraftPopup(false);
});
QUnit.test("hide component if no content", async assert => {