2023-03-15 17:42:12 +08:00
|
|
|
import Controller from "@ember/controller";
|
2023-10-11 02:38:59 +08:00
|
|
|
import { inject as 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 {
|
|
|
|
@service router;
|
2022-11-08 00:39:27 +08:00
|
|
|
|
|
|
|
get adminRoutes() {
|
2023-08-28 08:48:59 +08:00
|
|
|
return this.allAdminRoutes.filter((route) =>
|
|
|
|
this.routeExists(route.full_location)
|
|
|
|
);
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
2022-11-08 00:39:27 +08:00
|
|
|
|
|
|
|
get brokenAdminRoutes() {
|
|
|
|
return this.allAdminRoutes.filter(
|
2023-08-28 08:48:59 +08:00
|
|
|
(route) => !this.routeExists(route.full_location)
|
2022-11-08 00:39:27 +08:00
|
|
|
);
|
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
|
2023-08-28 08:48:59 +08:00
|
|
|
.filter((plugin) => plugin?.enabled)
|
|
|
|
.map((plugin) => {
|
|
|
|
return plugin.adminRoute;
|
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
|
|
|
}
|
|
|
|
}
|