2017-09-12 01:14:22 +08:00
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
2014-04-10 13:53:31 +08:00
|
|
|
|
2017-09-12 01:14:22 +08:00
|
|
|
export default Ember.Component.extend({
|
2017-11-21 18:53:09 +08:00
|
|
|
pluginApiIdentifiers: ["pinned-button"],
|
2017-09-12 01:14:22 +08:00
|
|
|
descriptionKey: "help",
|
2017-10-20 03:51:08 +08:00
|
|
|
classNames: "pinned-button",
|
|
|
|
classNameBindings: ["isHidden"],
|
2017-11-21 18:53:09 +08:00
|
|
|
layoutName: "select-kit/templates/components/pinned-button",
|
2014-04-10 13:53:31 +08:00
|
|
|
|
2017-11-21 18:53:09 +08:00
|
|
|
@computed("topic.pinned_globally", "pinned")
|
2017-09-12 01:14:22 +08:00
|
|
|
reasonText(pinnedGlobally, pinned) {
|
|
|
|
const globally = pinnedGlobally ? "_globally" : "";
|
|
|
|
const pinnedKey = pinned ? `pinned${globally}` : "unpinned";
|
|
|
|
const key = `topic_statuses.${pinnedKey}.help`;
|
|
|
|
return I18n.t(key);
|
2017-07-27 04:33:17 +08:00
|
|
|
},
|
2014-04-10 13:53:31 +08:00
|
|
|
|
2017-11-21 18:53:09 +08:00
|
|
|
@computed("pinned", "topic.deleted", "topic.unpinned")
|
2017-10-20 03:51:08 +08:00
|
|
|
isHidden(pinned, deleted, unpinned) {
|
2017-09-12 07:03:16 +08:00
|
|
|
return deleted || (!pinned && !unpinned);
|
2014-04-10 13:53:31 +08:00
|
|
|
}
|
|
|
|
});
|