2019-10-23 12:30:52 -04:00
|
|
|
import Component from "@ember/component";
|
2024-08-23 07:17:07 -04:00
|
|
|
import { classNameBindings, classNames } from "@ember-decorators/component";
|
2019-11-07 16:38:28 -05:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2024-11-19 15:45:18 -05:00
|
|
|
import { i18n } from "discourse-i18n";
|
2024-08-23 07:17:07 -04:00
|
|
|
import { pluginApiIdentifiers } from "select-kit/components/select-kit";
|
2014-04-10 01:53:31 -04:00
|
|
|
|
2024-08-23 07:17:07 -04:00
|
|
|
@classNames("pinned-button")
|
|
|
|
@classNameBindings("isHidden")
|
|
|
|
@pluginApiIdentifiers("pinned-button")
|
|
|
|
export default class PinnedButton extends Component {
|
|
|
|
descriptionKey = "help";
|
2014-04-10 01:53:31 -04:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("topic.pinned_globally", "pinned")
|
2017-09-11 13:14:22 -04:00
|
|
|
reasonText(pinnedGlobally, pinned) {
|
|
|
|
const globally = pinnedGlobally ? "_globally" : "";
|
|
|
|
const pinnedKey = pinned ? `pinned${globally}` : "unpinned";
|
|
|
|
const key = `topic_statuses.${pinnedKey}.help`;
|
2024-11-19 15:45:18 -05:00
|
|
|
return i18n(key);
|
2024-08-23 07:17:07 -04:00
|
|
|
}
|
2014-04-10 01:53:31 -04:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("pinned", "topic.deleted", "topic.unpinned")
|
2017-10-19 15:51:08 -04:00
|
|
|
isHidden(pinned, deleted, unpinned) {
|
2017-09-11 19:03:16 -04:00
|
|
|
return deleted || (!pinned && !unpinned);
|
2024-08-23 07:17:07 -04:00
|
|
|
}
|
|
|
|
}
|