This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/reviewable-claimed-topic.js.es6
Robin Ward b380ed5282 FEATURE: Claim Reviewables by Topic
This is a feature that used to be present in discourse-assign but is
much easier to implement in core. It also allows a topic to be assigned
without it claiming for review and vice versa and allows it to work with
category group reviewers.
2019-05-09 13:40:36 -04:00

34 lines
793 B
JavaScript

import computed from "ember-addons/ember-computed-decorators";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { ajax } from "discourse/lib/ajax";
export default Ember.Component.extend({
tagName: "",
@computed
enabled() {
return this.siteSettings.reviewable_claiming !== "disabled";
},
actions: {
unclaim() {
ajax(`/reviewable_claimed_topics/${this.get("topicId")}`, {
method: "DELETE"
}).then(() => {
this.set("claimedBy", null);
});
},
claim() {
let claim = this.store.createRecord("reviewable-claimed-topic");
claim
.save({ topic_id: this.get("topicId") })
.then(() => {
this.set("claimedBy", this.currentUser);
})
.catch(popupAjaxError);
}
}
});