Files
lens/src/renderer/components/+user-management/+cluster-role-bindings/cluster-role-bindings-sidebar-items.injectable.tsx
T
Janne SavolainenandMikko Aspiala 5c8ca2c038 Implement a lot of technical requirements for behavioural unit tests
Note: the crux of this was to make routing env-agnostic, and not based on URLs as magic strings, but instead something type-enforced.

Note: extension-based routes comply to same exact interface by "late-registering" their routes when installed. Routes are just injectables.

Note: another chunk of global shared state is no more.

Note: a lot of explicit side effects have been cornered to injectables.

Note: a lot of stuff has become reactive as part if this.

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
2022-03-31 15:13:26 +03:00

39 lines
1.6 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx";
import clusterRoleBindingsRouteInjectable from "../../../../common/front-end-routing/routes/cluster/user-management/cluster-role-bindings/cluster-role-bindings-route.injectable";
import { userManagementSidebarItemId } from "../user-management-sidebar-items.injectable";
import { sidebarItemsInjectionToken } from "../../layout/sidebar-items.injectable";
import routeIsActiveInjectable from "../../../routes/route-is-active.injectable";
import navigateToClusterRoleBindingsInjectable from "../../../../common/front-end-routing/routes/cluster/user-management/cluster-role-bindings/navigate-to-cluster-role-bindings.injectable";
const clusterRoleBindingsSidebarItemsInjectable = getInjectable({
id: "cluster-role-bindings-sidebar-items",
instantiate: (di) => {
const route = di.inject(clusterRoleBindingsRouteInjectable);
const navigateToClusterRoleBindings = di.inject(navigateToClusterRoleBindingsInjectable);
const routeIsActive = di.inject(routeIsActiveInjectable, route);
return computed(() => [
{
id: "cluster-role-bindings",
parentId: userManagementSidebarItemId,
title: "Cluster Role Bindings",
onClick: navigateToClusterRoleBindings,
isActive: routeIsActive,
isVisible: route.isEnabled,
orderNumber: 40,
},
]);
},
injectionToken: sidebarItemsInjectionToken,
});
export default clusterRoleBindingsSidebarItemsInjectable;