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:
Martin Brennan 2024-05-02 12:42:30 +10:00 committed by GitHub
parent 6623928b95
commit b52d3c7d29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 12 additions and 39 deletions

View File

@ -1,7 +0,0 @@
import DiscourseRoute from "discourse/routes/discourse";
export default DiscourseRoute.extend({
model() {
return this.modelFor("adminPlugins.show.discourse-ai.ai-personas");
},
});

View File

@ -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"
);
}
}

View File

@ -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")
);
},
});

View File

@ -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")
);
},
});

View File

@ -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" });
});
},
};

View File

@ -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

View File

@ -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>

View File

@ -1 +0,0 @@
<AiPersonaListEditor @personas={{this.model}} />

View File

@ -1 +0,0 @@
<AiPersonaListEditor @personas={{this.model}} />

View File

@ -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",
},
]);
});