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-11-07 15:38:28 -06:00

35 lines
828 B
JavaScript

import discourseComputed from "discourse-common/utils/decorators";
import Component from "@ember/component";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { ajax } from "discourse/lib/ajax";
export default Component.extend({
tagName: "",
@discourseComputed
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);
}
}
});