1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/+workloads-pods/pod-tolerations.tsx
2022-03-01 13:06:53 -05:00

70 lines
2.1 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import "./pod-tolerations.scss";
import React from "react";
import uniqueId from "lodash/uniqueId";
import type { IToleration } from "../../../common/k8s-api/workload-kube-object";
import { Table, TableCell, TableHead, TableRow } from "../table";
export interface PodTolerationsProps {
tolerations: IToleration[];
}
enum sortBy {
Key = "key",
Operator = "operator",
Effect = "effect",
Seconds = "seconds",
Value = "value",
}
const getTableRow = (toleration: IToleration) => {
const { key, operator, effect, tolerationSeconds, value } = toleration;
return (
<TableRow
key={uniqueId("toleration-")}
sortItem={toleration}
nowrap
>
<TableCell className="key">{key}</TableCell>
<TableCell className="operator">{operator}</TableCell>
<TableCell className="value">{value}</TableCell>
<TableCell className="effect">{effect}</TableCell>
<TableCell className="seconds">{tolerationSeconds}</TableCell>
</TableRow>
);
};
export function PodTolerations({ tolerations }: PodTolerationsProps) {
return (
<Table
tableId="workloads_pod_tolerations"
selectable
items={tolerations}
scrollable={false}
sortable={{
[sortBy.Key]: toleration => toleration.key,
[sortBy.Operator]: toleration => toleration.operator,
[sortBy.Effect]: toleration => toleration.effect,
[sortBy.Seconds]: toleration => toleration.tolerationSeconds,
}}
sortSyncWithUrl={false}
className="PodTolerations"
renderRow={getTableRow}
>
<TableHead sticky={false}>
<TableCell className="key" sortBy={sortBy.Key}>Key</TableCell>
<TableCell className="operator" sortBy={sortBy.Operator}>Operator</TableCell>
<TableCell className="value" sortBy={sortBy.Value}>Value</TableCell>
<TableCell className="effect" sortBy={sortBy.Effect}>Effect</TableCell>
<TableCell className="seconds" sortBy={sortBy.Seconds}>Seconds</TableCell>
</TableHead>
</Table>
);
}