From 2c58082b6b53c4c0d4cee02c0c87728188af9b5a Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Fri, 26 Aug 2022 16:54:12 +0300 Subject: [PATCH] Clean up pods component code Signed-off-by: Alex Andreev --- .../components/+workloads-pods/pods.tsx | 133 +----------------- 1 file changed, 2 insertions(+), 131 deletions(-) diff --git a/src/renderer/components/+workloads-pods/pods.tsx b/src/renderer/components/+workloads-pods/pods.tsx index f4e4e97de3..3500b7b373 100644 --- a/src/renderer/components/+workloads-pods/pods.tsx +++ b/src/renderer/components/+workloads-pods/pods.tsx @@ -3,17 +3,13 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ -// import "./pods.scss"; - import React, { Fragment } from "react"; import { disposeOnUnmount, observer } from "mobx-react"; import { Link } from "react-router-dom"; -import { KubeObjectListLayout } from "../kube-object-list-layout"; import type { NodeApi, Pod } from "../../../common/k8s-api/endpoints"; import { StatusBrick } from "../status-brick"; -import { cssNames, getConvertedParts, object, stopPropagation } from "../../utils"; +import { cssNames, object, stopPropagation } from "../../utils"; import startCase from "lodash/startCase"; -import kebabCase from "lodash/kebabCase"; import type { ApiManager } from "../../../common/k8s-api/api-manager"; import { KubeObjectStatusIcon } from "../kube-object-status-icon"; import { Badge } from "../badge"; @@ -35,18 +31,6 @@ import subscribeToStoresDisposersInjectable from "../../kube-watch-api/subscribe import { KubeObjectMenu } from "../kube-object-menu"; import toggleKubeDetailsPaneInjectable, { ToggleKubeDetailsPane } from "../kube-detail-params/toggle-details.injectable"; -enum columnId { - name = "name", - namespace = "namespace", - containers = "containers", - restarts = "restarts", - age = "age", - qos = "qos", - node = "node", - owners = "owners", - status = "status", -} - interface Dependencies { getDetailsUrl: GetDetailsUrl; apiManager: ApiManager; @@ -158,32 +142,12 @@ class NonInjectedPods extends React.Component { render() { const { podStore } = this.props; - // const cols = React.useMemo[]>(() => ([ - // { - // header: "Name", - // cell: (pod) => pod.getValue() - // }, - // { - // id: "warning", - // cell: props => , - // enableSorting: false, - // enableResizing: false, - // minSize: 30, - // size: 30 - // }, - // { - // header: "Namespace", - // cell: info => info.getValue(), - // minSize: 110 - // }, - - // ]), []); - const columns = [ columnHelper.accessor(row => row.getName(), { id: "name", header: "Name", cell: info => ( + // TODO: Multi-line table cells // // {info.getValue()} // @@ -268,99 +232,6 @@ class NonInjectedPods extends React.Component { ); } - - render1() { - const { apiManager, getDetailsUrl, podStore, eventStore, nodeApi } = this.props; - - return ( - - getConvertedParts(pod.getName()), - [columnId.namespace]: pod => pod.getNs(), - [columnId.containers]: pod => pod.getContainerStatuses().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.getCreationTimestamp(), - [columnId.status]: pod => pod.getStatusMessage(), - }} - searchFilters={[ - pod => pod.getSearchFields(), - pod => pod.getStatusMessage(), - pod => pod.status?.podIP, - pod => pod.getNodeName(), - ]} - renderHeaderTitle="Pods" - renderTableHeader={[ - { title: "Name", className: "name", sortBy: columnId.name, id: columnId.name }, - { className: "warning", showWithColumn: columnId.name }, - { title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace }, - { title: "Containers", className: "containers", sortBy: columnId.containers, id: columnId.containers }, - { title: "Restarts", className: "restarts", sortBy: columnId.restarts, id: columnId.restarts }, - { title: "Controlled By", className: "owners", sortBy: columnId.owners, id: columnId.owners }, - { title: "Node", className: "node", sortBy: columnId.node, id: columnId.node }, - { title: "QoS", className: "qos", sortBy: columnId.qos, id: columnId.qos }, - { title: "Age", className: "age", sortBy: columnId.age, id: columnId.age }, - { title: "Status", className: "status", sortBy: columnId.status, id: columnId.status }, - ]} - renderTableContents={pod => [ - , - , - pod.getNs(), - this.renderContainersStatus(pod), - pod.getRestartsCount(), - pod.getOwnerRefs().map(ref => { - const { kind, name } = ref; - const detailsLink = getDetailsUrl(apiManager.lookupApiLink(ref, pod)); - - return ( - - - {kind} - - - ); - }), - pod.getNodeName() ? ( - - - {pod.getNodeName()} - - - ) - : "", - pod.getQosClass(), - , - { title: pod.getStatusMessage(), className: kebabCase(pod.getStatusMessage()) }, - ]} - /> - - ); - } } export const Pods = withInjectables(NonInjectedPods, {