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
2019-05-27 10:15:39 +02:00

34 lines
779 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.topicId}`, {
method: "DELETE"
}).then(() => {
this.set("claimedBy", null);
});
},
claim() {
let claim = this.store.createRecord("reviewable-claimed-topic");
claim
.save({ topic_id: this.topicId })
.then(() => {
this.set("claimedBy", this.currentUser);
})
.catch(popupAjaxError);
}
}
});