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

Fix cluster role dialog

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-01-04 09:14:08 -05:00
parent 809611aaf4
commit 40a1b2e288
2 changed files with 16 additions and 5 deletions

View File

@ -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;

View File

@ -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<Dependencies> {
render() {
const {
openAddClusterRoleDialog,
clusterRoleStore,
} = this.props;
return (
<SiblingsInTabLayout>
<KubeObjectListLayout
isConfigurable
tableId="access_cluster_roles"
className="ClusterRoles"
store={this.props.clusterRoleStore}
store={clusterRoleStore}
sortingCallbacks={{
[columnId.name]: clusterRole => clusterRole.getName(),
[columnId.age]: clusterRole => -clusterRole.getCreationTimestamp(),
@ -55,7 +63,7 @@ class NonInjectedClusterRoles extends React.Component<Dependencies> {
<KubeObjectAge key="age" object={clusterRole} />,
]}
addRemoveButtons={{
onAdd: () => AddClusterRoleDialog.open(),
onAdd: () => openAddClusterRoleDialog(),
addTooltip: "Create new ClusterRole",
}}
/>
@ -69,5 +77,6 @@ export const ClusterRoles = withInjectables<Dependencies>(NonInjectedClusterRole
getProps: (di, props) => ({
...props,
clusterRoleStore: di.inject(clusterRoleStoreInjectable),
openAddClusterRoleDialog: di.inject(openAddClusterRoleDialogInjectable),
}),
});