2019-10-24 00:30:52 +08:00
|
|
|
import Component from "@ember/component";
|
2024-08-23 19:17:07 +08:00
|
|
|
import { classNameBindings, classNames } from "@ember-decorators/component";
|
2019-11-08 05:38:28 +08:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2024-11-20 04:45:18 +08:00
|
|
|
import { i18n } from "discourse-i18n";
|
2024-08-23 19:17:07 +08:00
|
|
|
import { pluginApiIdentifiers } from "select-kit/components/select-kit";
|
2014-04-10 13:53:31 +08:00
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
@classNames("pinned-button")
|
|
|
|
@classNameBindings("isHidden")
|
|
|
|
@pluginApiIdentifiers("pinned-button")
|
|
|
|
export default class PinnedButton extends Component {
|
|
|
|
descriptionKey = "help";
|
2014-04-10 13:53:31 +08:00
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("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`;
|
2024-11-20 04:45:18 +08:00
|
|
|
return i18n(key);
|
2024-08-23 19:17:07 +08:00
|
|
|
}
|
2014-04-10 13:53:31 +08:00
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("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);
|
2024-08-23 19:17:07 +08:00
|
|
|
}
|
|
|
|
}
|