DEV: Convert to native class syntax (#981)
This commit is contained in:
parent
0cb2c413ba
commit
120a20c5cd
|
@ -1,18 +1,18 @@
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
export default class AdminPluginsShowDiscourseAiLlmsNew extends DiscourseRoute {
|
||||||
queryParams: {
|
queryParams = {
|
||||||
llmTemplate: { refreshModel: true },
|
llmTemplate: { refreshModel: true },
|
||||||
},
|
};
|
||||||
|
|
||||||
async model() {
|
async model() {
|
||||||
const record = this.store.createRecord("ai-llm");
|
const record = this.store.createRecord("ai-llm");
|
||||||
record.provider_params = {};
|
record.provider_params = {};
|
||||||
return record;
|
return record;
|
||||||
},
|
}
|
||||||
|
|
||||||
setupController(controller, model) {
|
setupController(controller, model) {
|
||||||
this._super(controller, model);
|
super.setupController(controller, model);
|
||||||
controller.set(
|
controller.set(
|
||||||
"allLlms",
|
"allLlms",
|
||||||
this.modelFor("adminPlugins.show.discourse-ai-llms")
|
this.modelFor("adminPlugins.show.discourse-ai-llms")
|
||||||
|
@ -21,5 +21,5 @@ export default DiscourseRoute.extend({
|
||||||
"llmTemplate",
|
"llmTemplate",
|
||||||
this.paramsFor(this.routeName).llmTemplate || null
|
this.paramsFor(this.routeName).llmTemplate || null
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
export default class AdminPluginsShowDiscourseAiLlmsShow extends DiscourseRoute {
|
||||||
async model(params) {
|
async model(params) {
|
||||||
const allLlms = this.modelFor("adminPlugins.show.discourse-ai-llms");
|
const allLlms = this.modelFor("adminPlugins.show.discourse-ai-llms");
|
||||||
const id = parseInt(params.id, 10);
|
const id = parseInt(params.id, 10);
|
||||||
const record = allLlms.findBy("id", id);
|
const record = allLlms.findBy("id", id);
|
||||||
record.provider_params = record.provider_params || {};
|
record.provider_params = record.provider_params || {};
|
||||||
return record;
|
return record;
|
||||||
},
|
}
|
||||||
|
|
||||||
setupController(controller, model) {
|
setupController(controller, model) {
|
||||||
this._super(controller, model);
|
super.setupController(controller, model);
|
||||||
controller.set(
|
controller.set(
|
||||||
"allLlms",
|
"allLlms",
|
||||||
this.modelFor("adminPlugins.show.discourse-ai-llms")
|
this.modelFor("adminPlugins.show.discourse-ai-llms")
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { AUTO_GROUPS } from "discourse/lib/constants";
|
import { AUTO_GROUPS } from "discourse/lib/constants";
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
export default class AdminPluginsShowDiscourseAiPersonasNew extends DiscourseRoute {
|
||||||
async model() {
|
async model() {
|
||||||
const record = this.store.createRecord("ai-persona");
|
const record = this.store.createRecord("ai-persona");
|
||||||
record.set("allowed_group_ids", [AUTO_GROUPS.trust_level_0.id]);
|
record.set("allowed_group_ids", [AUTO_GROUPS.trust_level_0.id]);
|
||||||
|
@ -13,13 +13,13 @@ export default DiscourseRoute.extend({
|
||||||
record.set("allow_personal_messages", true);
|
record.set("allow_personal_messages", true);
|
||||||
record.set("tool_details", false);
|
record.set("tool_details", false);
|
||||||
return record;
|
return record;
|
||||||
},
|
}
|
||||||
|
|
||||||
setupController(controller, model) {
|
setupController(controller, model) {
|
||||||
this._super(controller, model);
|
super.setupController(controller, model);
|
||||||
controller.set(
|
controller.set(
|
||||||
"allPersonas",
|
"allPersonas",
|
||||||
this.modelFor("adminPlugins.show.discourse-ai-personas")
|
this.modelFor("adminPlugins.show.discourse-ai-personas")
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
export default class AdminPluginsShowDiscourseAiPersonasShow extends DiscourseRoute {
|
||||||
async model(params) {
|
async model(params) {
|
||||||
const allPersonas = this.modelFor(
|
const allPersonas = this.modelFor(
|
||||||
"adminPlugins.show.discourse-ai-personas"
|
"adminPlugins.show.discourse-ai-personas"
|
||||||
);
|
);
|
||||||
const id = parseInt(params.id, 10);
|
const id = parseInt(params.id, 10);
|
||||||
return allPersonas.findBy("id", id);
|
return allPersonas.findBy("id", id);
|
||||||
},
|
}
|
||||||
|
|
||||||
setupController(controller, model) {
|
setupController(controller, model) {
|
||||||
this._super(controller, model);
|
super.setupController(controller, model);
|
||||||
controller.set(
|
controller.set(
|
||||||
"allPersonas",
|
"allPersonas",
|
||||||
this.modelFor("adminPlugins.show.discourse-ai-personas")
|
this.modelFor("adminPlugins.show.discourse-ai-personas")
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
|
@ -1,22 +1,25 @@
|
||||||
import { computed, observer } from "@ember/object";
|
import { computed } from "@ember/object";
|
||||||
|
import { observes } from "@ember-decorators/object";
|
||||||
import I18n from "discourse-i18n";
|
import I18n from "discourse-i18n";
|
||||||
import ComboBox from "select-kit/components/combo-box";
|
import ComboBox from "select-kit/components/combo-box";
|
||||||
|
import { selectKitOptions } from "select-kit/components/select-kit";
|
||||||
|
|
||||||
export default ComboBox.extend({
|
@selectKitOptions({
|
||||||
_modelDisabledChanged: observer("attrs.disabled", function () {
|
filterable: true,
|
||||||
|
})
|
||||||
|
export default class AiLlmSelector extends ComboBox {
|
||||||
|
@observes("attrs.disabled")
|
||||||
|
_modelDisabledChanged() {
|
||||||
this.selectKit.options.set("disabled", this.get("attrs.disabled.value"));
|
this.selectKit.options.set("disabled", this.get("attrs.disabled.value"));
|
||||||
}),
|
}
|
||||||
|
|
||||||
content: computed(function () {
|
@computed
|
||||||
|
get content() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
id: "blank",
|
id: "blank",
|
||||||
name: I18n.t("discourse_ai.ai_persona.no_llm_selected"),
|
name: I18n.t("discourse_ai.ai_persona.no_llm_selected"),
|
||||||
},
|
},
|
||||||
].concat(this.llms);
|
].concat(this.llms);
|
||||||
}),
|
}
|
||||||
|
}
|
||||||
selectKitOptions: {
|
|
||||||
filterable: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
import { observer } from "@ember/object";
|
|
||||||
import { readOnly } from "@ember/object/computed";
|
import { readOnly } from "@ember/object/computed";
|
||||||
|
import { observes } from "@ember-decorators/object";
|
||||||
import MultiSelectComponent from "select-kit/components/multi-select";
|
import MultiSelectComponent from "select-kit/components/multi-select";
|
||||||
|
import { selectKitOptions } from "select-kit/components/select-kit";
|
||||||
|
|
||||||
export default MultiSelectComponent.extend({
|
@selectKitOptions({
|
||||||
_modelDisabledChanged: observer("attrs.disabled", function () {
|
filterable: true,
|
||||||
|
})
|
||||||
|
export default class AiToolSelector extends MultiSelectComponent {
|
||||||
|
@readOnly("tools") content;
|
||||||
|
|
||||||
|
value = "";
|
||||||
|
|
||||||
|
@observes("attrs.disabled")
|
||||||
|
_modelDisabledChanged() {
|
||||||
this.selectKit.options.set("disabled", this.get("attrs.disabled.value"));
|
this.selectKit.options.set("disabled", this.get("attrs.disabled.value"));
|
||||||
}),
|
}
|
||||||
|
}
|
||||||
content: readOnly("tools"),
|
|
||||||
|
|
||||||
value: "",
|
|
||||||
|
|
||||||
selectKitOptions: {
|
|
||||||
filterable: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
Loading…
Reference in New Issue