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);
|
this._super(controller, model);
|
||||||
controller.set(
|
controller.set(
|
||||||
"allPersonas",
|
"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({
|
export default DiscourseRoute.extend({
|
||||||
async model(params) {
|
async model(params) {
|
||||||
const allPersonas = this.modelFor(
|
const allPersonas = this.modelFor(
|
||||||
"adminPlugins.show.discourse-ai.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);
|
||||||
|
@ -13,7 +13,7 @@ export default DiscourseRoute.extend({
|
||||||
this._super(controller, model);
|
this._super(controller, model);
|
||||||
controller.set(
|
controller.set(
|
||||||
"allPersonas",
|
"allPersonas",
|
||||||
this.modelFor("adminPlugins.show.discourse-ai.ai-personas")
|
this.modelFor("adminPlugins.show.discourse-ai-personas")
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
|
@ -4,11 +4,9 @@ export default {
|
||||||
path: "/plugins",
|
path: "/plugins",
|
||||||
|
|
||||||
map() {
|
map() {
|
||||||
this.route("discourse-ai", { path: "/" }, function () {
|
this.route("discourse-ai-personas", { path: "ai-personas" }, function () {
|
||||||
this.route("ai-personas", function () {
|
|
||||||
this.route("new");
|
this.route("new");
|
||||||
this.route("show", { path: "/:id" });
|
this.route("show", { path: "/:id" });
|
||||||
});
|
});
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -102,7 +102,7 @@ export default class PersonaEditor extends Component {
|
||||||
if (isNew && this.args.model.rag_uploads.length === 0) {
|
if (isNew && this.args.model.rag_uploads.length === 0) {
|
||||||
this.args.personas.addObject(this.args.model);
|
this.args.personas.addObject(this.args.model);
|
||||||
this.router.transitionTo(
|
this.router.transitionTo(
|
||||||
"adminPlugins.show.discourse-ai.ai-personas.show",
|
"adminPlugins.show.discourse-ai-personas.show",
|
||||||
this.args.model
|
this.args.model
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -175,7 +175,7 @@ export default class PersonaEditor extends Component {
|
||||||
return this.args.model.destroyRecord().then(() => {
|
return this.args.model.destroyRecord().then(() => {
|
||||||
this.args.personas.removeObject(this.args.model);
|
this.args.personas.removeObject(this.args.model);
|
||||||
this.router.transitionTo(
|
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>
|
<template>
|
||||||
<BackButton
|
<BackButton
|
||||||
@route="adminPlugins.show.discourse-ai.ai-personas"
|
@route="adminPlugins.show.discourse-ai-personas"
|
||||||
@label="discourse_ai.ai_persona.back"
|
@label="discourse_ai.ai_persona.back"
|
||||||
/>
|
/>
|
||||||
<form
|
<form
|
||||||
|
|
|
@ -50,7 +50,7 @@ export default class AiPersonaListEditor extends Component {
|
||||||
<h3>{{i18n "discourse_ai.ai_persona.short_title"}}</h3>
|
<h3>{{i18n "discourse_ai.ai_persona.short_title"}}</h3>
|
||||||
{{#unless @currentPersona.isNew}}
|
{{#unless @currentPersona.isNew}}
|
||||||
<LinkTo
|
<LinkTo
|
||||||
@route="adminPlugins.show.discourse-ai.ai-personas.new"
|
@route="adminPlugins.show.discourse-ai-personas.new"
|
||||||
class="btn btn-small btn-primary"
|
class="btn btn-small btn-primary"
|
||||||
>
|
>
|
||||||
{{icon "plus"}}
|
{{icon "plus"}}
|
||||||
|
@ -105,7 +105,7 @@ export default class AiPersonaListEditor extends Component {
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<LinkTo
|
<LinkTo
|
||||||
@route="adminPlugins.show.discourse-ai.ai-personas.show"
|
@route="adminPlugins.show.discourse-ai-personas.show"
|
||||||
@model={{persona}}
|
@model={{persona}}
|
||||||
class="btn btn-text btn-small"
|
class="btn btn-text btn-small"
|
||||||
>{{i18n "discourse_ai.ai_persona.edit"}} </LinkTo>
|
>{{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) => {
|
withPluginApi("1.1.0", (api) => {
|
||||||
api.addAdminPluginConfigurationNav("discourse-ai", PLUGIN_NAV_MODE_TOP, [
|
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",
|
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