discourse-ai/assets/javascripts/discourse/widgets/ai-bot-header-panel-wrapper.js
David Taylor 261fe13599
DEV: Tweaks for drop-down implementation (#69)
- Remove unused 'toggleAiBotPanel' widget action

- Switch from appEvents to closure actions

- Convert widget definition to native class syntax, so that we can use `@action` decorator. (alternatively, we could have done `{ closePanel: this.hideAiBotPanel.bind(this) }` in `RenderGlimmer`
2023-05-18 09:28:43 +01:00

31 lines
693 B
JavaScript

import Widget from "discourse/widgets/widget";
import RenderGlimmer from "discourse/widgets/render-glimmer";
import { hbs } from "ember-cli-htmlbars";
import { action } from "@ember/object";
export default class AiBotHeaderPanelWrapper extends Widget {
buildAttributes() {
return { "data-click-outside": true };
}
html() {
return [
new RenderGlimmer(
this,
"div.widget-component-connector",
hbs`<AiBotHeaderPanel @closePanel={{@data.closePanel}} />`,
{ closePanel: this.closePanel }
),
];
}
@action
closePanel() {
this.sendWidgetAction("hideAiBotPanel");
}
@action
clickOutside() {
this.closePanel();
}
}