2022-11-08 00:39:27 +08:00
|
|
|
import { inject as service } from "@ember/service";
|
2023-03-15 17:42:12 +08:00
|
|
|
import Controller from "@ember/controller";
|
2019-04-26 18:16:21 +08:00
|
|
|
|
2023-03-15 17:42:12 +08:00
|
|
|
export default class AdminPluginsController extends Controller {
|
|
|
|
@service router;
|
2022-11-08 00:39:27 +08:00
|
|
|
|
|
|
|
get adminRoutes() {
|
|
|
|
return this.allAdminRoutes.filter((r) => this.routeExists(r.full_location));
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
2022-11-08 00:39:27 +08:00
|
|
|
|
|
|
|
get brokenAdminRoutes() {
|
|
|
|
return this.allAdminRoutes.filter(
|
|
|
|
(r) => !this.routeExists(r.full_location)
|
|
|
|
);
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
2022-11-08 00:39:27 +08:00
|
|
|
|
|
|
|
get allAdminRoutes() {
|
2019-05-27 16:15:39 +08:00
|
|
|
return this.model
|
2022-11-08 00:39:27 +08:00
|
|
|
.filter((p) => p?.enabled)
|
2017-02-10 01:11:53 +08:00
|
|
|
.map((p) => {
|
2022-11-08 00:39:27 +08:00
|
|
|
return p.admin_route;
|
2017-02-10 01:11:53 +08:00
|
|
|
})
|
2022-11-08 00:39:27 +08:00
|
|
|
.filter(Boolean);
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
2019-04-26 18:16:21 +08:00
|
|
|
|
2022-11-08 00:39:27 +08:00
|
|
|
routeExists(routeName) {
|
|
|
|
try {
|
|
|
|
this.router.urlFor(routeName);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
|
|
|
}
|