diff --git a/app/assets/javascripts/admin/addon/controllers/admin-plugins-index.js b/app/assets/javascripts/admin/addon/controllers/admin-plugins-index.js
index 035f42a1278..a7aed4b0690 100644
--- a/app/assets/javascripts/admin/addon/controllers/admin-plugins-index.js
+++ b/app/assets/javascripts/admin/addon/controllers/admin-plugins-index.js
@@ -6,6 +6,8 @@ import SiteSetting from "admin/models/site-setting";
export default class AdminPluginsIndexController extends Controller {
@service session;
+ @service adminPluginNavManager;
+ @service router;
@action
async togglePluginEnabled(plugin) {
@@ -21,4 +23,31 @@ export default class AdminPluginsIndexController extends Controller {
popupAjaxError(e);
}
}
+
+ // NOTE: See also AdminPluginsController, there is some duplication here
+ // while we convert plugins to use_new_show_route
+ get adminRoutes() {
+ return this.allAdminRoutes.filter((route) => this.routeExists(route));
+ }
+
+ get allAdminRoutes() {
+ return this.model
+ .filter((plugin) => plugin?.enabled && plugin?.adminRoute)
+ .map((plugin) => {
+ return Object.assign(plugin.adminRoute, { plugin_id: plugin.id });
+ });
+ }
+
+ routeExists(route) {
+ try {
+ if (route.use_new_show_route) {
+ this.router.urlFor(route.full_location, route.location);
+ } else {
+ this.router.urlFor(route.full_location);
+ }
+ return true;
+ } catch (e) {
+ return false;
+ }
+ }
}
diff --git a/app/assets/javascripts/admin/addon/controllers/admin-plugins.js b/app/assets/javascripts/admin/addon/controllers/admin-plugins.js
index c8aead72e63..66c62504948 100644
--- a/app/assets/javascripts/admin/addon/controllers/admin-plugins.js
+++ b/app/assets/javascripts/admin/addon/controllers/admin-plugins.js
@@ -13,19 +13,21 @@ export default class AdminPluginsController extends Controller {
return this.allAdminRoutes.filter((route) => !this.routeExists(route));
}
+ // NOTE: See also AdminPluginsIndexController, there is some duplication here
+ // while we convert plugins to use_new_show_route
get allAdminRoutes() {
return this.model
- .filter((plugin) => plugin?.enabled)
+ .filter((plugin) => plugin?.enabled && plugin?.adminRoute)
.map((plugin) => {
- return plugin.adminRoute;
- })
- .filter(Boolean);
+ return Object.assign(plugin.adminRoute, { plugin_id: plugin.id });
+ });
}
get showTopNav() {
return (
- !this.adminPluginNavManager.currentPlugin ||
- this.adminPluginNavManager.isSidebarMode
+ !this.adminPluginNavManager.viewingPluginsList &&
+ (!this.adminPluginNavManager.currentPlugin ||
+ this.adminPluginNavManager.isSidebarMode)
);
}
diff --git a/app/assets/javascripts/admin/addon/routes/admin-backups-logs.js b/app/assets/javascripts/admin/addon/routes/admin-backups-logs.js
index e61d868d585..ba31db92f4f 100644
--- a/app/assets/javascripts/admin/addon/routes/admin-backups-logs.js
+++ b/app/assets/javascripts/admin/addon/routes/admin-backups-logs.js
@@ -1,8 +1,9 @@
import EmberObject from "@ember/object";
-import Route from "@ember/routing/route";
import PreloadStore from "discourse/lib/preload-store";
+import DiscourseRoute from "discourse/routes/discourse";
+import I18n from "discourse-i18n";
-export default class AdminBackupsLogsRoute extends Route {
+export default class AdminBackupsLogsRoute extends DiscourseRoute {
// since the logs are pushed via the message bus
// we only want to preload them (hence the beforeModel hook)
beforeModel() {
@@ -25,4 +26,8 @@ export default class AdminBackupsLogsRoute extends Route {
setupController() {
/* prevent default behavior */
}
+
+ titleToken() {
+ return I18n.t("admin.backups.menu.logs");
+ }
}
diff --git a/app/assets/javascripts/admin/addon/routes/admin-backups-settings.js b/app/assets/javascripts/admin/addon/routes/admin-backups-settings.js
index 1c951827c5c..fbee45d1d40 100644
--- a/app/assets/javascripts/admin/addon/routes/admin-backups-settings.js
+++ b/app/assets/javascripts/admin/addon/routes/admin-backups-settings.js
@@ -1,11 +1,16 @@
-import Route from "@ember/routing/route";
+import DiscourseRoute from "discourse/routes/discourse";
+import I18n from "discourse-i18n";
import SiteSetting from "admin/models/site-setting";
-export default class AdminBackupsSettingsRoute extends Route {
+export default class AdminBackupsSettingsRoute extends DiscourseRoute {
queryParams = {
filter: { replace: true },
};
+ titleToken() {
+ return I18n.t("admin.backups.settings");
+ }
+
async model(params) {
return {
settings: await SiteSetting.findAll({ categories: ["backups"] }),
diff --git a/app/assets/javascripts/admin/addon/routes/admin-plugins-index.js b/app/assets/javascripts/admin/addon/routes/admin-plugins-index.js
new file mode 100644
index 00000000000..65a7e252cc6
--- /dev/null
+++ b/app/assets/javascripts/admin/addon/routes/admin-plugins-index.js
@@ -0,0 +1,14 @@
+import Route from "@ember/routing/route";
+import { service } from "@ember/service";
+
+export default class AdminPluginsIndexRoute extends Route {
+ @service adminPluginNavManager;
+
+ afterModel() {
+ this.adminPluginNavManager.viewingPluginsList = true;
+ }
+
+ deactivate() {
+ this.adminPluginNavManager.viewingPluginsList = false;
+ }
+}
diff --git a/app/assets/javascripts/admin/addon/routes/admin-plugins.js b/app/assets/javascripts/admin/addon/routes/admin-plugins.js
index 289231101cb..bcb5f9fe407 100644
--- a/app/assets/javascripts/admin/addon/routes/admin-plugins.js
+++ b/app/assets/javascripts/admin/addon/routes/admin-plugins.js
@@ -1,12 +1,17 @@
-import Route from "@ember/routing/route";
import { service } from "@ember/service";
+import DiscourseRoute from "discourse/routes/discourse";
+import I18n from "discourse-i18n";
import AdminPlugin from "admin/models/admin-plugin";
-export default class AdminPluginsRoute extends Route {
+export default class AdminPluginsRoute extends DiscourseRoute {
@service router;
async model() {
const plugins = await this.store.findAll("plugin");
return plugins.map((plugin) => AdminPlugin.create(plugin));
}
+
+ titleToken() {
+ return I18n.t("admin.plugins.title");
+ }
}
diff --git a/app/assets/javascripts/admin/addon/services/admin-plugin-nav-manager.js b/app/assets/javascripts/admin/addon/services/admin-plugin-nav-manager.js
index e3aa99d8567..0a2eee6840d 100644
--- a/app/assets/javascripts/admin/addon/services/admin-plugin-nav-manager.js
+++ b/app/assets/javascripts/admin/addon/services/admin-plugin-nav-manager.js
@@ -10,6 +10,11 @@ export default class AdminPluginNavManager extends Service {
@service currentUser;
@tracked currentPlugin;
+ // NOTE (martin) This is a temporary solution so we know whether to
+ // show the expanded header / nav on the admin plugin list or not.
+ // This will be removed when all plugins follow the new "show route" pattern.
+ @tracked viewingPluginsList = false;
+
get currentUserUsingAdminSidebar() {
return this.currentUser?.use_admin_sidebar;
}
diff --git a/app/assets/javascripts/admin/addon/templates/plugins-index.hbs b/app/assets/javascripts/admin/addon/templates/plugins-index.hbs
index 08830a80341..2cc9180a05e 100644
--- a/app/assets/javascripts/admin/addon/templates/plugins-index.hbs
+++ b/app/assets/javascripts/admin/addon/templates/plugins-index.hbs
@@ -1,25 +1,52 @@
-
{{i18n "admin.plugins.none_installed"}}
{{/if}} -- - {{i18n "admin.plugins.howto"}} - -
-