mirror of
https://ghfast.top/https://github.com/discourse/discourse-ai.git
synced 2026-05-26 01:04:52 +08:00
This PR is a retry of: #1135, where we migrate AiTools form to FormKit. The previous PR accidentally removed code related to setting enum values, and as a result was reverted. This update includes enums correctly along with the previous updates.
39 lines
1,008 B
Text
39 lines
1,008 B
Text
import Component from "@glimmer/component";
|
|
import { service } from "@ember/service";
|
|
import BackButton from "discourse/components/back-button";
|
|
import AiToolEditorForm from "./ai-tool-editor-form";
|
|
|
|
export default class AiToolEditor extends Component {
|
|
@service store;
|
|
|
|
get selectedPreset() {
|
|
if (!this.args.selectedPreset) {
|
|
return this.args.presets.findBy("preset_id", "empty_tool");
|
|
}
|
|
|
|
return this.args.presets.findBy("preset_id", this.args.selectedPreset);
|
|
}
|
|
|
|
get editingModel() {
|
|
if (this.args.model.isNew) {
|
|
return this.store.createRecord("ai-tool", this.selectedPreset);
|
|
} else {
|
|
return this.args.model;
|
|
}
|
|
}
|
|
|
|
<template>
|
|
<BackButton
|
|
@route="adminPlugins.show.discourse-ai-tools"
|
|
@label="discourse_ai.tools.back"
|
|
/>
|
|
|
|
<AiToolEditorForm
|
|
@model={{@model}}
|
|
@tools={{@tools}}
|
|
@editingModel={{this.editingModel}}
|
|
@isNew={{@model.isNew}}
|
|
@selectedPreset={{this.selectedPreset}}
|
|
/>
|
|
</template>
|
|
}
|