2023-03-15 05:42:12 -04:00
|
|
|
import Controller from "@ember/controller";
|
2023-10-10 14:38:59 -04:00
|
|
|
import { inject as 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 {
|
|
|
|
@service router;
|
2022-11-07 11:39:27 -05:00
|
|
|
|
|
|
|
get adminRoutes() {
|
2023-08-27 20:48:59 -04:00
|
|
|
return this.allAdminRoutes.filter((route) =>
|
|
|
|
this.routeExists(route.full_location)
|
|
|
|
);
|
2023-03-15 05:42:12 -04:00
|
|
|
}
|
2022-11-07 11:39:27 -05:00
|
|
|
|
|
|
|
get brokenAdminRoutes() {
|
|
|
|
return this.allAdminRoutes.filter(
|
2023-08-27 20:48:59 -04:00
|
|
|
(route) => !this.routeExists(route.full_location)
|
2022-11-07 11:39:27 -05:00
|
|
|
);
|
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
|
|
|
|
2022-11-07 11:39:27 -05:00
|
|
|
routeExists(routeName) {
|
|
|
|
try {
|
|
|
|
this.router.urlFor(routeName);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-03-15 05:42:12 -04:00
|
|
|
}
|
|
|
|
}
|