1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/cluster-manager/cluster-context.tsx
Roman 6df56b5471 cluster-manager view
Signed-off-by: Roman <ixrock@gmail.com>
2020-07-10 12:47:50 +03:00

31 lines
793 B
TypeScript

import React from "react";
import { observer } from "mobx-react";
import { ClusterId, clusterStore } from "../../../common/cluster-store";
import { WorkspaceId, workspaceStore } from "../../../common/workspace-store";
export const clusterContext = React.createContext(getClusterContext());
export interface ClusterContextValue {
workspaceId: WorkspaceId;
clusterId?: ClusterId;
}
export function getClusterContext(): ClusterContextValue {
return {
clusterId: clusterStore.activeCluster,
workspaceId: workspaceStore.currentWorkspace,
}
}
@observer
export class ClusterContext extends React.Component {
render() {
const { Provider } = clusterContext;
return (
<Provider value={getClusterContext()}>
{this.props.children}
</Provider>
)
}
}