2024-03-08 05:07:48 -05:00
|
|
|
import Component from "@glimmer/component";
|
|
|
|
import { action } from "@ember/object";
|
|
|
|
import { service } from "@ember/service";
|
|
|
|
import { gt } from "truth-helpers";
|
|
|
|
import DButton from "discourse/components/d-button";
|
|
|
|
import i18n from "discourse-common/helpers/i18n";
|
|
|
|
import { composeAiBotMessage } from "../lib/ai-bot-helper";
|
|
|
|
|
|
|
|
export default class AiBotHeaderIcon extends Component {
|
|
|
|
@service siteSettings;
|
|
|
|
@service composer;
|
|
|
|
|
|
|
|
get bots() {
|
|
|
|
return this.siteSettings.ai_bot_add_to_header
|
|
|
|
? this.siteSettings.ai_bot_enabled_chat_bots.split("|").filter(Boolean)
|
|
|
|
: [];
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
compose() {
|
|
|
|
composeAiBotMessage(this.bots[0], this.composer);
|
|
|
|
}
|
|
|
|
|
|
|
|
<template>
|
|
|
|
{{#if (gt this.bots.length 0)}}
|
|
|
|
<li>
|
2024-05-14 03:54:54 -04:00
|
|
|
<DButton
|
2024-05-14 09:30:03 -04:00
|
|
|
@action={{this.compose}}
|
2024-05-14 03:54:54 -04:00
|
|
|
@icon="robot"
|
2024-05-14 09:30:03 -04:00
|
|
|
title={{i18n "discourse_ai.ai_bot.shortcut_title"}}
|
2024-05-14 03:54:54 -04:00
|
|
|
class="ai-bot-button icon btn-flat"
|
|
|
|
/>
|
2024-03-08 05:07:48 -05:00
|
|
|
</li>
|
|
|
|
{{/if}}
|
|
|
|
</template>
|
|
|
|
}
|