mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Adding tolerations table
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
790d833257
commit
140abbe459
@ -1,7 +1,7 @@
|
||||
import get from "lodash/get";
|
||||
import { KubeObject } from "./kube-object";
|
||||
|
||||
interface IToleration {
|
||||
export interface IToleration {
|
||||
key?: string;
|
||||
operator?: string;
|
||||
effect?: string;
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import "./pod-details-tolerations.scss";
|
||||
import React from "react";
|
||||
import { Pod, Deployment, DaemonSet, StatefulSet, ReplicaSet, Job } from "../../api/endpoints";
|
||||
import { DrawerParamToggler, DrawerItem } from "../drawer";
|
||||
import { WorkloadKubeObject } from "../../api/workload-kube-object";
|
||||
import { PodTolerations } from "./pod-tolerations";
|
||||
|
||||
interface Props {
|
||||
workload: Pod | Deployment | DaemonSet | StatefulSet | ReplicaSet | Job;
|
||||
workload: WorkloadKubeObject;
|
||||
}
|
||||
|
||||
export class PodDetailsTolerations extends React.Component<Props> {
|
||||
@ -17,20 +18,7 @@ export class PodDetailsTolerations extends React.Component<Props> {
|
||||
return (
|
||||
<DrawerItem name="Tolerations" className="PodDetailsTolerations">
|
||||
<DrawerParamToggler label={tolerations.length}>
|
||||
{
|
||||
tolerations.map((toleration, index) => {
|
||||
const { key, operator, effect, tolerationSeconds } = toleration;
|
||||
|
||||
return (
|
||||
<div className="toleration" key={index}>
|
||||
<DrawerItem name="Key">{key}</DrawerItem>
|
||||
{operator && <DrawerItem name="Operator">{operator}</DrawerItem>}
|
||||
{effect && <DrawerItem name="Effect">{effect}</DrawerItem>}
|
||||
{!!tolerationSeconds && <DrawerItem name="Effect">{tolerationSeconds}</DrawerItem>}
|
||||
</div>
|
||||
);
|
||||
})
|
||||
}
|
||||
<PodTolerations tolerations={tolerations} />
|
||||
</DrawerParamToggler>
|
||||
</DrawerItem>
|
||||
);
|
||||
|
||||
10
src/renderer/components/+workloads-pods/pod-tolerations.scss
Normal file
10
src/renderer/components/+workloads-pods/pod-tolerations.scss
Normal file
@ -0,0 +1,10 @@
|
||||
.PodTolerations {
|
||||
.TableCell {
|
||||
white-space: normal;
|
||||
word-break: normal;
|
||||
|
||||
&.key {
|
||||
flex-grow: 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
63
src/renderer/components/+workloads-pods/pod-tolerations.tsx
Normal file
63
src/renderer/components/+workloads-pods/pod-tolerations.tsx
Normal file
@ -0,0 +1,63 @@
|
||||
import "./pod-tolerations.scss";
|
||||
import React from "react";
|
||||
import uniqueId from "lodash/uniqueId";
|
||||
|
||||
import { IToleration } from "../../api/workload-kube-object";
|
||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||
|
||||
interface Props {
|
||||
tolerations: IToleration[];
|
||||
}
|
||||
|
||||
enum sortBy {
|
||||
Key = "key",
|
||||
Operator = "operator",
|
||||
Effect = "effect",
|
||||
Seconds = "seconds",
|
||||
}
|
||||
|
||||
const sortingCallbacks = {
|
||||
[sortBy.Key]: (toleration: IToleration) => toleration.key,
|
||||
[sortBy.Operator]: (toleration: IToleration) => toleration.operator,
|
||||
[sortBy.Effect]: (toleration: IToleration) => toleration.effect,
|
||||
[sortBy.Seconds]: (toleration: IToleration) => toleration.tolerationSeconds,
|
||||
};
|
||||
|
||||
const getTableRow = (toleration: IToleration) => {
|
||||
const { key, operator, effect, tolerationSeconds } = toleration;
|
||||
|
||||
return (
|
||||
<TableRow
|
||||
key={uniqueId("toleration-")}
|
||||
sortItem={toleration}
|
||||
nowrap
|
||||
>
|
||||
<TableCell className="key">{key}</TableCell>
|
||||
<TableCell className="operator">{operator}</TableCell>
|
||||
<TableCell className="effect">{effect}</TableCell>
|
||||
<TableCell className="seconds">{tolerationSeconds}</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
};
|
||||
|
||||
export function PodTolerations({ tolerations }: Props) {
|
||||
return (
|
||||
<Table
|
||||
selectable
|
||||
scrollable={false}
|
||||
sortable={sortingCallbacks}
|
||||
sortSyncWithUrl={false}
|
||||
className="PodTolerations"
|
||||
>
|
||||
<TableHead sticky={false}>
|
||||
<TableCell className="key" sortBy={sortBy.Key}>Key</TableCell>
|
||||
<TableCell className="operator" sortBy={sortBy.Operator}>Operator</TableCell>
|
||||
<TableCell className="effect" sortBy={sortBy.Effect}>Effect</TableCell>
|
||||
<TableCell className="seconds" sortBy={sortBy.Seconds}>Seconds</TableCell>
|
||||
</TableHead>
|
||||
{
|
||||
tolerations.map(getTableRow)
|
||||
}
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user