diff --git a/src/renderer/components/+user-management/+cluster-roles/add-dialog/open.injectable.ts b/src/renderer/components/+user-management/+cluster-roles/add-dialog/open.injectable.ts index 04af979ae7..2c2a41a0b8 100644 --- a/src/renderer/components/+user-management/+cluster-roles/add-dialog/open.injectable.ts +++ b/src/renderer/components/+user-management/+cluster-roles/add-dialog/open.injectable.ts @@ -6,8 +6,10 @@ import { getInjectable } from "@ogre-tools/injectable"; import { action } from "mobx"; import addClusterRoleDialogStateInjectable from "./state.injectable"; -const openAddClusterRoleDialogStateInjectable = getInjectable({ - id: "open-add-cluster-role-dialog-state", +export type OpenAddClusterRoleDialog = () => void; + +const openAddClusterRoleDialogInjectable = getInjectable({ + id: "open-add-cluster-role-dialog", instantiate: (di) => { const state = di.inject(addClusterRoleDialogStateInjectable); @@ -18,4 +20,4 @@ const openAddClusterRoleDialogStateInjectable = getInjectable({ }, }); -export default openAddClusterRoleDialogStateInjectable; +export default openAddClusterRoleDialogInjectable; diff --git a/src/renderer/components/+user-management/+cluster-roles/view.tsx b/src/renderer/components/+user-management/+cluster-roles/view.tsx index c98d4c300b..8a64e775b3 100644 --- a/src/renderer/components/+user-management/+cluster-roles/view.tsx +++ b/src/renderer/components/+user-management/+cluster-roles/view.tsx @@ -15,6 +15,8 @@ import { KubeObjectAge } from "../../kube-object/age"; import type { ClusterRoleStore } from "./store"; import { withInjectables } from "@ogre-tools/injectable-react"; import clusterRoleStoreInjectable from "./store.injectable"; +import type { OpenAddClusterRoleDialog } from "./add-dialog/open.injectable"; +import openAddClusterRoleDialogInjectable from "./add-dialog/open.injectable"; enum columnId { name = "name", @@ -24,18 +26,24 @@ enum columnId { interface Dependencies { clusterRoleStore: ClusterRoleStore; + openAddClusterRoleDialog: OpenAddClusterRoleDialog; } @observer class NonInjectedClusterRoles extends React.Component { render() { + const { + openAddClusterRoleDialog, + clusterRoleStore, + } = this.props; + return ( clusterRole.getName(), [columnId.age]: clusterRole => -clusterRole.getCreationTimestamp(), @@ -55,7 +63,7 @@ class NonInjectedClusterRoles extends React.Component { , ]} addRemoveButtons={{ - onAdd: () => AddClusterRoleDialog.open(), + onAdd: () => openAddClusterRoleDialog(), addTooltip: "Create new ClusterRole", }} /> @@ -69,5 +77,6 @@ export const ClusterRoles = withInjectables(NonInjectedClusterRole getProps: (di, props) => ({ ...props, clusterRoleStore: di.inject(clusterRoleStoreInjectable), + openAddClusterRoleDialog: di.inject(openAddClusterRoleDialogInjectable), }), });