This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/plugins/chat/assets/javascripts/discourse/components/chat-channel-status.js
Roman Rizzi 0a5f548635
DEV: Move discourse-chat to the core repo. (#18776)
As part of this move, we are also renaming `discourse-chat` to `chat`.
2022-11-02 10:41:30 -03:00

58 lines
1.4 KiB
JavaScript

import discourseComputed from "discourse-common/utils/decorators";
import I18n from "I18n";
import Component from "@ember/component";
import {
CHANNEL_STATUSES,
channelStatusIcon,
channelStatusName,
} from "discourse/plugins/chat/discourse/models/chat-channel";
export default Component.extend({
tagName: "",
channel: null,
format: null,
init() {
this._super(...arguments);
if (!["short", "long"].includes(this.format)) {
this.set("format", "long");
}
},
@discourseComputed("channel.status")
channelStatusMessage(channelStatus) {
if (channelStatus === CHANNEL_STATUSES.open) {
return null;
}
if (this.format === "long") {
return this._longStatusMessage(channelStatus);
} else {
return this._shortStatusMessage(channelStatus);
}
},
@discourseComputed("channel.status")
channelStatusIcon(channelStatus) {
return channelStatusIcon(channelStatus);
},
_shortStatusMessage(channelStatus) {
return channelStatusName(channelStatus);
},
_longStatusMessage(channelStatus) {
switch (channelStatus) {
case CHANNEL_STATUSES.closed:
return I18n.t("chat.channel_status.closed_header");
break;
case CHANNEL_STATUSES.readOnly:
return I18n.t("chat.channel_status.read_only_header");
break;
case CHANNEL_STATUSES.archived:
return I18n.t("chat.channel_status.archived_header");
break;
}
},
});