It used to change the category of the topic, instead of the destination category (topic.category_id instead of topic.shared_draft.category_id). The shared drafts controls were displayed only if the current category matched the 'shared drafts category', which was not true for shared drafts that had their categories changed (affected by the previous bug).
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
import Component from "@ember/component";
|
|
import I18n from "I18n";
|
|
import bootbox from "bootbox";
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
|
|
export default Component.extend({
|
|
tagName: "",
|
|
publishing: false,
|
|
|
|
@discourseComputed("topic.destination_category_id")
|
|
validCategory(destCatId) {
|
|
return destCatId && destCatId !== this.site.shared_drafts_category_id;
|
|
},
|
|
|
|
actions: {
|
|
updateDestinationCategory(categoryId) {
|
|
return this.topic.updateDestinationCategory(categoryId);
|
|
},
|
|
|
|
publish() {
|
|
bootbox.confirm(I18n.t("shared_drafts.confirm_publish"), (result) => {
|
|
if (result) {
|
|
this.set("publishing", true);
|
|
const destinationCategoryId = this.topic.destination_category_id;
|
|
this.topic
|
|
.publish()
|
|
.then(() => {
|
|
this.topic.setProperties({
|
|
category_id: destinationCategoryId,
|
|
destination_category_id: undefined,
|
|
is_shared_draft: false,
|
|
});
|
|
})
|
|
.finally(() => {
|
|
this.set("publishing", false);
|
|
});
|
|
}
|
|
});
|
|
},
|
|
},
|
|
});
|