DEV: Moving around admin persona config routes again (#586)
The initial setup done in fb0d56324f
clashed with other plugins, I found this when trying to do the same
for Gamification. This uses a better routing setup and removes the
need to define the config nav link for Settings -- that is always inserted.
Relies on https://github.com/discourse/discourse/pull/26707
This commit is contained in:
parent
6623928b95
commit
b52d3c7d29
|
@ -1,7 +0,0 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
model() {
|
||||
return this.modelFor("adminPlugins.show.discourse-ai.ai-personas");
|
||||
},
|
||||
});
|
|
@ -1,12 +0,0 @@
|
|||
import { inject as service } from "@ember/service";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default class DiscourseAiIndexRoute extends DiscourseRoute {
|
||||
@service router;
|
||||
|
||||
beforeModel() {
|
||||
return this.router.transitionTo(
|
||||
"adminPlugins.show.discourse-ai.ai-personas.index"
|
||||
);
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ export default DiscourseRoute.extend({
|
|||
this._super(controller, model);
|
||||
controller.set(
|
||||
"allPersonas",
|
||||
this.modelFor("adminPlugins.show.discourse-ai.ai-personas")
|
||||
this.modelFor("adminPlugins.show.discourse-ai-personas")
|
||||
);
|
||||
},
|
||||
});
|
|
@ -3,7 +3,7 @@ import DiscourseRoute from "discourse/routes/discourse";
|
|||
export default DiscourseRoute.extend({
|
||||
async model(params) {
|
||||
const allPersonas = this.modelFor(
|
||||
"adminPlugins.show.discourse-ai.ai-personas"
|
||||
"adminPlugins.show.discourse-ai-personas"
|
||||
);
|
||||
const id = parseInt(params.id, 10);
|
||||
return allPersonas.findBy("id", id);
|
||||
|
@ -13,7 +13,7 @@ export default DiscourseRoute.extend({
|
|||
this._super(controller, model);
|
||||
controller.set(
|
||||
"allPersonas",
|
||||
this.modelFor("adminPlugins.show.discourse-ai.ai-personas")
|
||||
this.modelFor("adminPlugins.show.discourse-ai-personas")
|
||||
);
|
||||
},
|
||||
});
|
|
@ -4,11 +4,9 @@ export default {
|
|||
path: "/plugins",
|
||||
|
||||
map() {
|
||||
this.route("discourse-ai", { path: "/" }, function () {
|
||||
this.route("ai-personas", function () {
|
||||
this.route("new");
|
||||
this.route("show", { path: "/:id" });
|
||||
});
|
||||
this.route("discourse-ai-personas", { path: "ai-personas" }, function () {
|
||||
this.route("new");
|
||||
this.route("show", { path: "/:id" });
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -102,7 +102,7 @@ export default class PersonaEditor extends Component {
|
|||
if (isNew && this.args.model.rag_uploads.length === 0) {
|
||||
this.args.personas.addObject(this.args.model);
|
||||
this.router.transitionTo(
|
||||
"adminPlugins.show.discourse-ai.ai-personas.show",
|
||||
"adminPlugins.show.discourse-ai-personas.show",
|
||||
this.args.model
|
||||
);
|
||||
} else {
|
||||
|
@ -175,7 +175,7 @@ export default class PersonaEditor extends Component {
|
|||
return this.args.model.destroyRecord().then(() => {
|
||||
this.args.personas.removeObject(this.args.model);
|
||||
this.router.transitionTo(
|
||||
"adminPlugins.show.discourse-ai.ai-personas.index"
|
||||
"adminPlugins.show.discourse-ai-personas.index"
|
||||
);
|
||||
});
|
||||
},
|
||||
|
@ -265,7 +265,7 @@ export default class PersonaEditor extends Component {
|
|||
|
||||
<template>
|
||||
<BackButton
|
||||
@route="adminPlugins.show.discourse-ai.ai-personas"
|
||||
@route="adminPlugins.show.discourse-ai-personas"
|
||||
@label="discourse_ai.ai_persona.back"
|
||||
/>
|
||||
<form
|
||||
|
|
|
@ -50,7 +50,7 @@ export default class AiPersonaListEditor extends Component {
|
|||
<h3>{{i18n "discourse_ai.ai_persona.short_title"}}</h3>
|
||||
{{#unless @currentPersona.isNew}}
|
||||
<LinkTo
|
||||
@route="adminPlugins.show.discourse-ai.ai-personas.new"
|
||||
@route="adminPlugins.show.discourse-ai-personas.new"
|
||||
class="btn btn-small btn-primary"
|
||||
>
|
||||
{{icon "plus"}}
|
||||
|
@ -105,7 +105,7 @@ export default class AiPersonaListEditor extends Component {
|
|||
</td>
|
||||
<td>
|
||||
<LinkTo
|
||||
@route="adminPlugins.show.discourse-ai.ai-personas.show"
|
||||
@route="adminPlugins.show.discourse-ai-personas.show"
|
||||
@model={{persona}}
|
||||
class="btn btn-text btn-small"
|
||||
>{{i18n "discourse_ai.ai_persona.edit"}} </LinkTo>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
<AiPersonaListEditor @personas={{this.model}} />
|
|
@ -1 +0,0 @@
|
|||
<AiPersonaListEditor @personas={{this.model}} />
|
|
@ -12,13 +12,9 @@ export default {
|
|||
|
||||
withPluginApi("1.1.0", (api) => {
|
||||
api.addAdminPluginConfigurationNav("discourse-ai", PLUGIN_NAV_MODE_TOP, [
|
||||
{
|
||||
label: "admin.plugins.change_settings_short",
|
||||
route: "adminPlugins.show.settings",
|
||||
},
|
||||
{
|
||||
label: "discourse_ai.ai_persona.short_title",
|
||||
route: "adminPlugins.show.discourse-ai.ai-personas",
|
||||
route: "adminPlugins.show.discourse-ai-personas",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue