import Component from "@glimmer/component"; import { tracked } from "@glimmer/tracking"; import { fn } from "@ember/helper"; import { on } from "@ember/modifier"; import { action } from "@ember/object"; import { LinkTo } from "@ember/routing"; import { service } from "@ember/service"; import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item"; import DToggleSwitch from "discourse/components/d-toggle-switch"; import concatClass from "discourse/helpers/concat-class"; import { popupAjaxError } from "discourse/lib/ajax-error"; import { cook } from "discourse/lib/text"; import icon from "discourse-common/helpers/d-icon"; import i18n from "discourse-common/helpers/i18n"; import I18n from "discourse-i18n"; import AiPersonaEditor from "./ai-persona-editor"; export default class AiPersonaListEditor extends Component { @service adminPluginNavManager; @tracked _noPersonaText = null; get noPersonaText() { if (this._noPersonaText === null) { const raw = I18n.t("discourse_ai.ai_persona.no_persona_selected"); cook(raw).then((result) => { this._noPersonaText = result; }); } return this._noPersonaText; } @action async toggleEnabled(persona) { const oldValue = persona.enabled; const newValue = !oldValue; try { persona.set("enabled", newValue); await persona.save(); } catch (err) { persona.set("enabled", oldValue); popupAjaxError(err); } } }