2024-06-27 17:27:40 +10:00
|
|
|
import Component from "@glimmer/component";
|
2024-06-28 00:59:51 +02:00
|
|
|
import { service } from "@ember/service";
|
2024-06-27 17:27:40 +10:00
|
|
|
import BackButton from "discourse/components/back-button";
|
2025-04-22 18:23:25 +02:00
|
|
|
import AiToolEditorForm from "./ai-tool-editor-form";
|
2024-06-28 00:59:51 +02:00
|
|
|
|
2024-06-27 17:27:40 +10:00
|
|
|
export default class AiToolEditor extends Component {
|
2024-08-29 16:05:38 +10:00
|
|
|
@service store;
|
2024-06-27 17:27:40 +10:00
|
|
|
|
2025-04-22 18:23:25 +02:00
|
|
|
get selectedPreset() {
|
|
|
|
|
if (!this.args.selectedPreset) {
|
|
|
|
|
return this.args.presets.findBy("preset_id", "empty_tool");
|
2024-06-27 17:27:40 +10:00
|
|
|
}
|
2025-04-22 18:23:25 +02:00
|
|
|
|
|
|
|
|
return this.args.presets.findBy("preset_id", this.args.selectedPreset);
|
2024-06-27 17:27:40 +10:00
|
|
|
}
|
|
|
|
|
|
2025-04-22 18:23:25 +02:00
|
|
|
get editingModel() {
|
|
|
|
|
if (this.args.model.isNew) {
|
|
|
|
|
return this.store.createRecord("ai-tool", this.selectedPreset);
|
|
|
|
|
} else {
|
|
|
|
|
return this.args.model;
|
2025-03-18 18:07:04 +11:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-27 17:27:40 +10:00
|
|
|
<template>
|
|
|
|
|
<BackButton
|
|
|
|
|
@route="adminPlugins.show.discourse-ai-tools"
|
2024-07-16 14:23:17 -03:00
|
|
|
@label="discourse_ai.tools.back"
|
2024-06-27 17:27:40 +10:00
|
|
|
/>
|
|
|
|
|
|
2025-04-22 18:23:25 +02:00
|
|
|
<AiToolEditorForm
|
|
|
|
|
@model={{@model}}
|
|
|
|
|
@tools={{@tools}}
|
|
|
|
|
@editingModel={{this.editingModel}}
|
|
|
|
|
@isNew={{@model.isNew}}
|
|
|
|
|
@selectedPreset={{this.selectedPreset}}
|
|
|
|
|
/>
|
2024-06-27 17:27:40 +10:00
|
|
|
</template>
|
|
|
|
|
}
|