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