mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Inject dependencies to PodDetailsList
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
72c98da185
commit
5dd9a5c6bc
@ -183,7 +183,6 @@ class NonInjectedNodeDetails extends React.Component<NodeDetailsProps & Dependen
|
|||||||
<NodeDetailsResources node={node} type="allocatable"/>
|
<NodeDetailsResources node={node} type="allocatable"/>
|
||||||
<PodDetailsList
|
<PodDetailsList
|
||||||
pods={childPods}
|
pods={childPods}
|
||||||
owner={node}
|
|
||||||
maxCpu={node.getCpuCapacity()}
|
maxCpu={node.getCpuCapacity()}
|
||||||
maxMemory={node.getMemoryCapacity()}
|
maxMemory={node.getMemoryCapacity()}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -133,7 +133,7 @@ class NonInjectedDaemonSetDetails extends React.Component<DaemonSetDetailsProps
|
|||||||
<PodDetailsStatuses pods={childPods}/>
|
<PodDetailsStatuses pods={childPods}/>
|
||||||
</DrawerItem>
|
</DrawerItem>
|
||||||
<ResourceMetricsText metrics={this.metrics}/>
|
<ResourceMetricsText metrics={this.metrics}/>
|
||||||
<PodDetailsList pods={childPods} owner={daemonSet}/>
|
<PodDetailsList pods={childPods}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -161,7 +161,7 @@ class NonInjectedDeploymentDetails extends React.Component<DeploymentDetailsProp
|
|||||||
<PodDetailsAffinities workload={deployment}/>
|
<PodDetailsAffinities workload={deployment}/>
|
||||||
<ResourceMetricsText metrics={this.metrics}/>
|
<ResourceMetricsText metrics={this.metrics}/>
|
||||||
<DeploymentReplicaSets replicaSets={replicaSets}/>
|
<DeploymentReplicaSets replicaSets={replicaSets}/>
|
||||||
<PodDetailsList pods={childPods} owner={deployment}/>
|
<PodDetailsList pods={childPods}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,7 +149,7 @@ class NonInjectedJobDetails extends React.Component<JobDetailsProps & Dependenci
|
|||||||
<DrawerItem name="Pod Status" className="pod-status">
|
<DrawerItem name="Pod Status" className="pod-status">
|
||||||
<PodDetailsStatuses pods={childPods}/>
|
<PodDetailsStatuses pods={childPods}/>
|
||||||
</DrawerItem>
|
</DrawerItem>
|
||||||
<PodDetailsList pods={childPods} owner={job}/>
|
<PodDetailsList pods={childPods} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,20 +5,22 @@
|
|||||||
|
|
||||||
import "./pod-details-list.scss";
|
import "./pod-details-list.scss";
|
||||||
|
|
||||||
import React from "react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import kebabCase from "lodash/kebabCase";
|
import kebabCase from "lodash/kebabCase";
|
||||||
import { reaction } from "mobx";
|
import { reaction } from "mobx";
|
||||||
import { disposeOnUnmount, observer } from "mobx-react";
|
import { disposeOnUnmount, observer } from "mobx-react";
|
||||||
import { podStore } from "./legacy-store";
|
import React from "react";
|
||||||
import type { Pod } from "../../../common/k8s-api/endpoints";
|
import type { Pod } from "../../../common/k8s-api/endpoints";
|
||||||
import { autoBind, bytesToUnits, cssNames, interval, prevDefault } from "../../utils";
|
import { bytesToUnits, cssNames, interval, prevDefault } from "../../utils";
|
||||||
import { LineProgress } from "../line-progress";
|
|
||||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
|
||||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
|
||||||
import { Spinner } from "../spinner";
|
|
||||||
import { DrawerTitle } from "../drawer";
|
import { DrawerTitle } from "../drawer";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
|
||||||
import { showDetails } from "../kube-detail-params";
|
import { showDetails } from "../kube-detail-params";
|
||||||
|
import getDetailsUrlInjectable, { type GetDetailsUrl } from "../kube-detail-params/get-details-url.injectable";
|
||||||
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
|
import { LineProgress } from "../line-progress";
|
||||||
|
import { Spinner } from "../spinner";
|
||||||
|
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||||
|
import type { PodStore } from "./store";
|
||||||
|
import podStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
enum sortBy {
|
enum sortBy {
|
||||||
name = "name",
|
name = "name",
|
||||||
@ -30,26 +32,25 @@ enum sortBy {
|
|||||||
|
|
||||||
export interface PodDetailsListProps {
|
export interface PodDetailsListProps {
|
||||||
pods: Pod[];
|
pods: Pod[];
|
||||||
owner: KubeObject;
|
|
||||||
maxCpu?: number;
|
maxCpu?: number;
|
||||||
maxMemory?: number;
|
maxMemory?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
interface Dependencies {
|
||||||
export class PodDetailsList extends React.Component<PodDetailsListProps> {
|
getDetailsUrl: GetDetailsUrl;
|
||||||
constructor(props: PodDetailsListProps) {
|
podStore: PodStore;
|
||||||
super(props);
|
}
|
||||||
autoBind(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@observer
|
||||||
|
export class NonInjectedPodDetailsList extends React.Component<PodDetailsListProps & Dependencies> {
|
||||||
private metricsWatcher = interval(120, () => {
|
private metricsWatcher = interval(120, () => {
|
||||||
podStore.loadKubeMetrics(this.props.owner.getNs());
|
this.props.podStore.loadKubeMetrics(this.props.pods[0]?.getNs());
|
||||||
});
|
});
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.metricsWatcher.start(true);
|
this.metricsWatcher.start(true);
|
||||||
disposeOnUnmount(this, [
|
disposeOnUnmount(this, [
|
||||||
reaction(() => this.props.owner, () => this.metricsWatcher.restart(true)),
|
reaction(() => this.props.pods[0]?.getNs(), () => this.metricsWatcher.restart(true)),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +115,7 @@ export class PodDetailsList extends React.Component<PodDetailsListProps> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const metrics = podStore.getPodKubeMetrics(pod);
|
const metrics = this.props.podStore.getPodKubeMetrics(pod);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow
|
<TableRow
|
||||||
@ -138,7 +139,7 @@ export class PodDetailsList extends React.Component<PodDetailsListProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { pods } = this.props;
|
const { pods, podStore } = this.props;
|
||||||
|
|
||||||
if (!podStore.isLoaded) {
|
if (!podStore.isLoaded) {
|
||||||
return (
|
return (
|
||||||
@ -149,7 +150,11 @@ export class PodDetailsList extends React.Component<PodDetailsListProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!pods.length) {
|
if (!pods.length) {
|
||||||
return null;
|
return (
|
||||||
|
<div>
|
||||||
|
No items found
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const virtual = pods.length > 20;
|
const virtual = pods.length > 20;
|
||||||
@ -197,3 +202,11 @@ export class PodDetailsList extends React.Component<PodDetailsListProps> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const PodDetailsList = withInjectables<Dependencies, PodDetailsListProps>(NonInjectedPodDetailsList, {
|
||||||
|
getProps: (di, props) => ({
|
||||||
|
...props,
|
||||||
|
getDetailsUrl: di.inject(getDetailsUrlInjectable),
|
||||||
|
podStore: di.inject(podStoreInjectable),
|
||||||
|
}),
|
||||||
|
});
|
||||||
@ -133,7 +133,7 @@ class NonInjectedReplicaSetDetails extends React.Component<ReplicaSetDetailsProp
|
|||||||
<PodDetailsStatuses pods={childPods}/>
|
<PodDetailsStatuses pods={childPods}/>
|
||||||
</DrawerItem>
|
</DrawerItem>
|
||||||
<ResourceMetricsText metrics={this.metrics}/>
|
<ResourceMetricsText metrics={this.metrics}/>
|
||||||
<PodDetailsList pods={childPods} owner={replicaSet}/>
|
<PodDetailsList pods={childPods}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -132,7 +132,7 @@ class NonInjectedStatefulSetDetails extends React.Component<StatefulSetDetailsPr
|
|||||||
<PodDetailsStatuses pods={childPods}/>
|
<PodDetailsStatuses pods={childPods}/>
|
||||||
</DrawerItem>
|
</DrawerItem>
|
||||||
<ResourceMetricsText metrics={this.metrics}/>
|
<ResourceMetricsText metrics={this.metrics}/>
|
||||||
<PodDetailsList pods={childPods} owner={statefulSet}/>
|
<PodDetailsList pods={childPods}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user