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";
|
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-03-12 23:15:12 -04:00
|
|
|
return this.allAdminRoutes.filter((route) => this.routeExists(route));
|
2023-03-15 05:42:12 -04:00
|
|
|
}
|
2022-11-07 11:39:27 -05:00
|
|
|
|
|
|
|
get brokenAdminRoutes() {
|
2024-03-12 23:15:12 -04:00
|
|
|
return this.allAdminRoutes.filter((route) => !this.routeExists(route));
|
2023-03-15 05:42:12 -04:00
|
|
|
}
|
2022-11-07 11:39:27 -05:00
|
|
|
|
|
|
|
get allAdminRoutes() {
|
2019-05-27 04:15:39 -04:00
|
|
|
return this.model
|
2023-08-27 20:48:59 -04:00
|
|
|
.filter((plugin) => plugin?.enabled)
|
|
|
|
.map((plugin) => {
|
|
|
|
return plugin.adminRoute;
|
2017-02-09 12:11:53 -05:00
|
|
|
})
|
2022-11-07 11:39:27 -05:00
|
|
|
.filter(Boolean);
|
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 (
|
|
|
|
!this.adminPluginNavManager.currentPlugin ||
|
|
|
|
this.adminPluginNavManager.isSidebarMode
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-03-12 23:15:12 -04:00
|
|
|
routeExists(route) {
|
2022-11-07 11:39:27 -05:00
|
|
|
try {
|
2024-03-12 23:15:12 -04:00
|
|
|
if (route.use_new_show_route) {
|
|
|
|
this.router.urlFor(route.full_location, route.location);
|
|
|
|
} else {
|
|
|
|
this.router.urlFor(route.full_location);
|
|
|
|
}
|
2022-11-07 11:39:27 -05:00
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-03-15 05:42:12 -04:00
|
|
|
}
|
|
|
|
}
|