2019-10-23 12:30:52 -04:00
|
|
|
import Component from "@ember/component";
|
2020-05-13 16:23:41 -04:00
|
|
|
import I18n from "I18n";
|
2019-11-07 16:38:28 -05:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2017-07-26 12:13:49 -04:00
|
|
|
import { iconHTML } from "discourse-common/lib/icon-library";
|
2016-06-15 13:49:57 -04:00
|
|
|
|
2019-12-03 19:19:52 -05:00
|
|
|
export default Component.extend({
|
|
|
|
classes: ["text-muted", "text-danger", "text-successful", "text-muted"],
|
|
|
|
icons: ["far-circle", "times-circle", "circle", "circle"],
|
|
|
|
circleIcon: null,
|
|
|
|
deliveryStatus: null,
|
2016-06-15 13:49:57 -04:00
|
|
|
|
2019-12-03 19:19:52 -05:00
|
|
|
@discourseComputed("deliveryStatuses", "model.last_delivery_status")
|
|
|
|
status(deliveryStatuses, lastDeliveryStatus) {
|
|
|
|
return deliveryStatuses.find((s) => s.id === lastDeliveryStatus);
|
|
|
|
},
|
2016-06-15 13:49:57 -04:00
|
|
|
|
2019-12-03 19:19:52 -05:00
|
|
|
@discourseComputed("status.id", "icons")
|
|
|
|
icon(statusId, icons) {
|
|
|
|
return icons[statusId - 1];
|
|
|
|
},
|
2016-06-15 13:49:57 -04:00
|
|
|
|
2019-12-03 19:19:52 -05:00
|
|
|
@discourseComputed("status.id", "classes")
|
|
|
|
class(statusId, classes) {
|
|
|
|
return classes[statusId - 1];
|
|
|
|
},
|
2016-06-15 13:49:57 -04:00
|
|
|
|
2019-12-03 19:19:52 -05:00
|
|
|
didReceiveAttrs() {
|
|
|
|
this._super(...arguments);
|
2019-12-03 19:39:39 -05:00
|
|
|
this.set(
|
|
|
|
"circleIcon",
|
|
|
|
iconHTML(this.icon, { class: this.class }).htmlSafe()
|
|
|
|
);
|
|
|
|
this.set(
|
|
|
|
"deliveryStatus",
|
|
|
|
I18n.t(`admin.web_hooks.delivery_status.${this.get("status.name")}`)
|
|
|
|
);
|
2019-12-03 19:19:52 -05:00
|
|
|
},
|
|
|
|
});
|