2023-03-15 05:42:12 -04:00
|
|
|
import Controller from "@ember/controller";
|
2024-03-06 12:05:11 -05:00
|
|
|
import { service } from "@ember/service";
|
2024-10-10 19:26:10 -04:00
|
|
|
import { adminRouteValid } from "discourse/lib/admin-utilities";
|
2019-04-26 06:16:21 -04:00
|
|
|
|
2023-03-15 05:42:12 -04:00
|
|
|
export default class AdminPluginsController extends Controller {
|
2024-03-20 23:42:06 -04:00
|
|
|
@service adminPluginNavManager;
|
2023-03-15 05:42:12 -04:00
|
|
|
@service router;
|
2022-11-07 11:39:27 -05:00
|
|
|
|
|
|
|
get adminRoutes() {
|
2024-10-10 19:26:10 -04:00
|
|
|
return this.allAdminRoutes.filter((route) =>
|
|
|
|
adminRouteValid(this.router, route)
|
|
|
|
);
|
2023-03-15 05:42:12 -04:00
|
|
|
}
|
2022-11-07 11:39:27 -05:00
|
|
|
|
|
|
|
get brokenAdminRoutes() {
|
2024-10-10 19:26:10 -04:00
|
|
|
return this.allAdminRoutes.filter(
|
|
|
|
(route) => !adminRouteValid(this.router, route)
|
|
|
|
);
|
2023-03-15 05:42:12 -04:00
|
|
|
}
|
2022-11-07 11:39:27 -05:00
|
|
|
|
2024-08-30 00:53:36 -04:00
|
|
|
// NOTE: See also AdminPluginsIndexController, there is some duplication here
|
|
|
|
// while we convert plugins to use_new_show_route
|
2022-11-07 11:39:27 -05:00
|
|
|
get allAdminRoutes() {
|
2019-05-27 04:15:39 -04:00
|
|
|
return this.model
|
2024-08-30 00:53:36 -04:00
|
|
|
.filter((plugin) => plugin?.enabled && plugin?.adminRoute)
|
2023-08-27 20:48:59 -04:00
|
|
|
.map((plugin) => {
|
2024-08-30 00:53:36 -04:00
|
|
|
return Object.assign(plugin.adminRoute, { plugin_id: plugin.id });
|
|
|
|
});
|
2023-03-15 05:42:12 -04:00
|
|
|
}
|
2019-04-26 06:16:21 -04:00
|
|
|
|
2024-03-20 23:42:06 -04:00
|
|
|
get showTopNav() {
|
|
|
|
return (
|
2024-08-30 00:53:36 -04:00
|
|
|
!this.adminPluginNavManager.viewingPluginsList &&
|
|
|
|
(!this.adminPluginNavManager.currentPlugin ||
|
|
|
|
this.adminPluginNavManager.isSidebarMode)
|
2024-03-20 23:42:06 -04:00
|
|
|
);
|
|
|
|
}
|
2023-03-15 05:42:12 -04:00
|
|
|
}
|