2023-03-15 17:42:12 +08:00
|
|
|
import Controller from "@ember/controller";
|
2024-03-07 01:05:11 +08:00
|
|
|
import { service } from "@ember/service";
|
2019-04-26 18:16:21 +08:00
|
|
|
|
2023-03-15 17:42:12 +08:00
|
|
|
export default class AdminPluginsController extends Controller {
|
2024-03-21 11:42:06 +08:00
|
|
|
@service adminPluginNavManager;
|
2023-03-15 17:42:12 +08:00
|
|
|
@service router;
|
2022-11-08 00:39:27 +08:00
|
|
|
|
|
|
|
get adminRoutes() {
|
2024-03-13 11:15:12 +08:00
|
|
|
return this.allAdminRoutes.filter((route) => this.routeExists(route));
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
2022-11-08 00:39:27 +08:00
|
|
|
|
|
|
|
get brokenAdminRoutes() {
|
2024-03-13 11:15:12 +08:00
|
|
|
return this.allAdminRoutes.filter((route) => !this.routeExists(route));
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
2022-11-08 00:39:27 +08:00
|
|
|
|
2024-08-30 12:53:36 +08:00
|
|
|
// NOTE: See also AdminPluginsIndexController, there is some duplication here
|
|
|
|
// while we convert plugins to use_new_show_route
|
2022-11-08 00:39:27 +08:00
|
|
|
get allAdminRoutes() {
|
2019-05-27 16:15:39 +08:00
|
|
|
return this.model
|
2024-08-30 12:53:36 +08:00
|
|
|
.filter((plugin) => plugin?.enabled && plugin?.adminRoute)
|
2023-08-28 08:48:59 +08:00
|
|
|
.map((plugin) => {
|
2024-08-30 12:53:36 +08:00
|
|
|
return Object.assign(plugin.adminRoute, { plugin_id: plugin.id });
|
|
|
|
});
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
2019-04-26 18:16:21 +08:00
|
|
|
|
2024-03-21 11:42:06 +08:00
|
|
|
get showTopNav() {
|
|
|
|
return (
|
2024-08-30 12:53:36 +08:00
|
|
|
!this.adminPluginNavManager.viewingPluginsList &&
|
|
|
|
(!this.adminPluginNavManager.currentPlugin ||
|
|
|
|
this.adminPluginNavManager.isSidebarMode)
|
2024-03-21 11:42:06 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-03-13 11:15:12 +08:00
|
|
|
routeExists(route) {
|
2022-11-08 00:39:27 +08:00
|
|
|
try {
|
2024-03-13 11:15:12 +08:00
|
|
|
if (route.use_new_show_route) {
|
|
|
|
this.router.urlFor(route.full_location, route.location);
|
|
|
|
} else {
|
|
|
|
this.router.urlFor(route.full_location);
|
|
|
|
}
|
2022-11-08 00:39:27 +08:00
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
|
|
|
}
|