2021-01-22 23:09:02 +08:00
|
|
|
import Component from "@ember/component";
|
2021-02-11 02:12:04 +08:00
|
|
|
import { action, computed } from "@ember/object";
|
2021-01-22 23:09:02 +08:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
newFeatures: null,
|
2021-02-11 02:12:04 +08:00
|
|
|
classNames: ["section", "dashboard-new-features"],
|
|
|
|
classNameBindings: ["hasUnseenFeatures:ordered-first"],
|
2021-01-22 23:09:02 +08:00
|
|
|
releaseNotesLink: null,
|
|
|
|
|
|
|
|
init() {
|
|
|
|
this._super(...arguments);
|
|
|
|
|
|
|
|
ajax("/admin/dashboard/new-features.json").then((json) => {
|
2021-11-25 03:13:52 +08:00
|
|
|
if (!this.element || this.isDestroying || this.isDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-01-22 23:09:02 +08:00
|
|
|
this.setProperties({
|
|
|
|
newFeatures: json.new_features,
|
2021-02-11 02:12:04 +08:00
|
|
|
hasUnseenFeatures: json.has_unseen_features,
|
2021-01-22 23:09:02 +08:00
|
|
|
releaseNotesLink: json.release_notes_link,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-02-11 02:12:04 +08:00
|
|
|
columnCountClass: computed("newFeatures", function () {
|
|
|
|
return this.newFeatures.length > 2 ? "three-or-more-items" : "";
|
|
|
|
}),
|
|
|
|
|
2021-01-22 23:09:02 +08:00
|
|
|
@action
|
|
|
|
dismissNewFeatures() {
|
|
|
|
ajax("/admin/dashboard/mark-new-features-as-seen.json", {
|
|
|
|
type: "PUT",
|
2021-02-11 02:12:04 +08:00
|
|
|
}).then(() => this.set("hasUnseenFeatures", false));
|
2021-01-22 23:09:02 +08:00
|
|
|
},
|
|
|
|
});
|