1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix cluster role binding dialog

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-01-04 09:12:22 -05:00
parent 7d9f1e00e5
commit 809611aaf4
2 changed files with 17 additions and 3 deletions

View File

@ -16,9 +16,15 @@ import directoryForUserDataInjectable from "../../../../../common/app-paths/dire
import directoryForKubeConfigsInjectable from "../../../../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable"; import directoryForKubeConfigsInjectable from "../../../../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";
import hostedClusterInjectable from "../../../../cluster-frame-context/hosted-cluster.injectable"; import hostedClusterInjectable from "../../../../cluster-frame-context/hosted-cluster.injectable";
import createClusterInjectable from "../../../../cluster/create-cluster.injectable"; import createClusterInjectable from "../../../../cluster/create-cluster.injectable";
import type { CloseClusterRoleBindingDialog } from "../dialog/close.injectable";
import closeClusterRoleBindingDialogInjectable from "../dialog/close.injectable";
import type { OpenClusterRoleBindingDialog } from "../dialog/open.injectable";
import openClusterRoleBindingDialogInjectable from "../dialog/open.injectable";
describe("ClusterRoleBindingDialog tests", () => { describe("ClusterRoleBindingDialog tests", () => {
let render: DiRender; let render: DiRender;
let closeClusterRoleBindingDialog: CloseClusterRoleBindingDialog;
let openClusterRoleBindingDialog: OpenClusterRoleBindingDialog;
beforeEach(() => { beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true }); const di = getDiForUnitTesting({ doGeneralOverrides: true });
@ -27,6 +33,9 @@ describe("ClusterRoleBindingDialog tests", () => {
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs"); di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");
di.override(storesAndApisCanBeCreatedInjectable, () => true); di.override(storesAndApisCanBeCreatedInjectable, () => true);
closeClusterRoleBindingDialog = di.inject(closeClusterRoleBindingDialogInjectable);
openClusterRoleBindingDialog = di.inject(openClusterRoleBindingDialogInjectable);
const createCluster = di.inject(createClusterInjectable); const createCluster = di.inject(createClusterInjectable);
di.override(hostedClusterInjectable, () => createCluster({ di.override(hostedClusterInjectable, () => createCluster({
@ -56,7 +65,7 @@ describe("ClusterRoleBindingDialog tests", () => {
}); });
afterEach(() => { afterEach(() => {
ClusterRoleBindingDialog.close(); closeClusterRoleBindingDialog();
jest.resetAllMocks(); jest.resetAllMocks();
}); });
@ -67,7 +76,7 @@ describe("ClusterRoleBindingDialog tests", () => {
}); });
it("clusterrole select should be searchable", async () => { it("clusterrole select should be searchable", async () => {
ClusterRoleBindingDialog.open(); openClusterRoleBindingDialog();
const res = render(<ClusterRoleBindingDialog />); const res = render(<ClusterRoleBindingDialog />);
userEvent.keyboard("a"); userEvent.keyboard("a");

View File

@ -19,6 +19,8 @@ import type { ClusterRoleStore } from "../+cluster-roles/store";
import type { ServiceAccountStore } from "../+service-accounts/store"; import type { ServiceAccountStore } from "../+service-accounts/store";
import clusterRoleStoreInjectable from "../+cluster-roles/store.injectable"; import clusterRoleStoreInjectable from "../+cluster-roles/store.injectable";
import serviceAccountStoreInjectable from "../+service-accounts/store.injectable"; import serviceAccountStoreInjectable from "../+service-accounts/store.injectable";
import type { OpenClusterRoleBindingDialog } from "./dialog/open.injectable";
import openClusterRoleBindingDialogInjectable from "./dialog/open.injectable";
enum columnId { enum columnId {
name = "name", name = "name",
@ -31,6 +33,7 @@ interface Dependencies {
clusterRoleBindingStore: ClusterRoleBindingStore; clusterRoleBindingStore: ClusterRoleBindingStore;
clusterRoleStore: ClusterRoleStore; clusterRoleStore: ClusterRoleStore;
serviceAccountStore: ServiceAccountStore; serviceAccountStore: ServiceAccountStore;
openClusterRoleBindingDialog: OpenClusterRoleBindingDialog;
} }
@observer @observer
@ -40,6 +43,7 @@ class NonInjectedClusterRoleBindings extends React.Component<Dependencies> {
clusterRoleBindingStore, clusterRoleBindingStore,
clusterRoleStore, clusterRoleStore,
serviceAccountStore, serviceAccountStore,
openClusterRoleBindingDialog,
} = this.props; } = this.props;
return ( return (
@ -73,7 +77,7 @@ class NonInjectedClusterRoleBindings extends React.Component<Dependencies> {
<KubeObjectAge key="age" object={binding} />, <KubeObjectAge key="age" object={binding} />,
]} ]}
addRemoveButtons={{ addRemoveButtons={{
onAdd: () => ClusterRoleBindingDialog.open(), onAdd: () => openClusterRoleBindingDialog(),
addTooltip: "Create new ClusterRoleBinding", addTooltip: "Create new ClusterRoleBinding",
}} }}
/> />
@ -89,5 +93,6 @@ export const ClusterRoleBindings = withInjectables<Dependencies>(NonInjectedClus
clusterRoleBindingStore: di.inject(clusterRoleBindingStoreInjectable), clusterRoleBindingStore: di.inject(clusterRoleBindingStoreInjectable),
clusterRoleStore: di.inject(clusterRoleStoreInjectable), clusterRoleStore: di.inject(clusterRoleStoreInjectable),
serviceAccountStore: di.inject(serviceAccountStoreInjectable), serviceAccountStore: di.inject(serviceAccountStoreInjectable),
openClusterRoleBindingDialog: di.inject(openClusterRoleBindingDialogInjectable),
}), }),
}); });