mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Improve Table typing and remove annotations on callbacks
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
22c9d03edb
commit
defb0ea0dd
55 files changed
+498
-490
No files matched your search
@@ -37,13 +37,6 @@ enum sortBy {
|
||||
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;
|
||||
|
||||
@@ -66,10 +59,17 @@ export function PodTolerations({ tolerations }: Props) {
|
||||
<Table
|
||||
tableId="workloads_pod_tolerations"
|
||||
selectable
|
||||
items={tolerations}
|
||||
scrollable={false}
|
||||
sortable={sortingCallbacks}
|
||||
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>
|
||||
@@ -77,9 +77,6 @@ export function PodTolerations({ tolerations }: Props) {
|
||||
<TableCell className="effect" sortBy={sortBy.Effect}>Effect</TableCell>
|
||||
<TableCell className="seconds" sortBy={sortBy.Seconds}>Seconds</TableCell>
|
||||
</TableHead>
|
||||
{
|
||||
tolerations.map(getTableRow)
|
||||
}
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
@@ -97,21 +97,21 @@ export class Pods extends React.Component<Props> {
|
||||
tableId = "workloads_pods"
|
||||
isConfigurable
|
||||
sortingCallbacks={{
|
||||
[columnId.name]: (pod: Pod) => pod.getName(),
|
||||
[columnId.namespace]: (pod: Pod) => pod.getNs(),
|
||||
[columnId.containers]: (pod: Pod) => pod.getContainers().length,
|
||||
[columnId.restarts]: (pod: Pod) => pod.getRestartsCount(),
|
||||
[columnId.owners]: (pod: Pod) => pod.getOwnerRefs().map(ref => ref.kind),
|
||||
[columnId.qos]: (pod: Pod) => pod.getQosClass(),
|
||||
[columnId.node]: (pod: Pod) => pod.getNodeName(),
|
||||
[columnId.age]: (pod: Pod) => pod.getTimeDiffFromNow(),
|
||||
[columnId.status]: (pod: Pod) => pod.getStatusMessage(),
|
||||
[columnId.name]: pod => pod.getName(),
|
||||
[columnId.namespace]: pod => pod.getNs(),
|
||||
[columnId.containers]: pod => pod.getContainers().length,
|
||||
[columnId.restarts]: pod => pod.getRestartsCount(),
|
||||
[columnId.owners]: pod => pod.getOwnerRefs().map(ref => ref.kind),
|
||||
[columnId.qos]: pod => pod.getQosClass(),
|
||||
[columnId.node]: pod => pod.getNodeName(),
|
||||
[columnId.age]: pod => pod.getTimeDiffFromNow(),
|
||||
[columnId.status]: pod => pod.getStatusMessage(),
|
||||
}}
|
||||
searchFilters={[
|
||||
(pod: Pod) => pod.getSearchFields(),
|
||||
(pod: Pod) => pod.getStatusMessage(),
|
||||
(pod: Pod) => pod.status.podIP,
|
||||
(pod: Pod) => pod.getNodeName(),
|
||||
pod => pod.getSearchFields(),
|
||||
pod => pod.getStatusMessage(),
|
||||
pod => pod.status.podIP,
|
||||
pod => pod.getNodeName(),
|
||||
]}
|
||||
renderHeaderTitle="Pods"
|
||||
renderTableHeader={[
|
||||
@@ -126,7 +126,7 @@ export class Pods extends React.Component<Props> {
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
{ title: "Status", className: "status", sortBy: columnId.status, id: columnId.status },
|
||||
]}
|
||||
renderTableContents={(pod: Pod) => [
|
||||
renderTableContents={pod => [
|
||||
<Badge flat key="name" label={pod.getName()} tooltip={pod.getName()} />,
|
||||
<KubeObjectStatusIcon key="icon" object={pod} />,
|
||||
pod.getNs(),
|
||||
|
||||
Reference in new issue
Block a user