From a92c53eb569e4b397950a306810845bec11148f9 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Tue, 25 Oct 2022 12:31:11 -0400 Subject: [PATCH] Remove legacy global for daemonSetStore Signed-off-by: Sebastian Malton --- src/renderer/components/+events/store.ts | 4 +- .../+workloads-daemonsets/daemonsets.tsx | 126 ++++++++---------- 2 files changed, 60 insertions(+), 70 deletions(-) diff --git a/src/renderer/components/+events/store.ts b/src/renderer/components/+events/store.ts index a639ea80be..6910ffb153 100644 --- a/src/renderer/components/+events/store.ts +++ b/src/renderer/components/+events/store.ts @@ -13,13 +13,13 @@ import type { KubeObject } from "../../../common/k8s-api/kube-object"; import { Pod } from "../../../common/k8s-api/endpoints/pod.api"; import type { GetPodById } from "../+workloads-pods/get-pod-by-id.injectable"; -export interface EventStoreDependencies { +interface Dependencies { getPodById: GetPodById; } export class EventStore extends KubeObjectStore { constructor( - protected readonly dependencies: EventStoreDependencies, + protected readonly dependencies: Dependencies, api: KubeEventApi, opts: KubeObjectStoreOptions = {}, ) { diff --git a/src/renderer/components/+workloads-daemonsets/daemonsets.tsx b/src/renderer/components/+workloads-daemonsets/daemonsets.tsx index 795acb59b2..5fc4ac6bc8 100644 --- a/src/renderer/components/+workloads-daemonsets/daemonsets.tsx +++ b/src/renderer/components/+workloads-daemonsets/daemonsets.tsx @@ -14,7 +14,6 @@ import { KubeObjectStatusIcon } from "../kube-object-status-icon"; import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout"; import { KubeObjectAge } from "../kube-object/age"; import type { DaemonSetStore } from "./store"; -import type { PodStore } from "../+workloads-pods/store"; import type { EventStore } from "../+events/store"; import { prevDefault } from "../../utils"; import type { FilterByNamespace } from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable"; @@ -22,7 +21,6 @@ import { withInjectables } from "@ogre-tools/injectable-react"; import daemonSetStoreInjectable from "./store.injectable"; import eventStoreInjectable from "../+events/store.injectable"; import filterByNamespaceInjectable from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable"; -import podStoreInjectable from "../+workloads-pods/store.injectable"; enum columnId { name = "name", @@ -34,77 +32,70 @@ enum columnId { interface Dependencies { daemonSetStore: DaemonSetStore; - podStore: PodStore; eventStore: EventStore; filterByNamespace: FilterByNamespace; } -@observer -class NonInjectedDaemonSets extends React.Component { - getPodsLength(daemonSet: DaemonSet) { - return this.props.daemonSetStore.getChildPods(daemonSet).length; - } +const NonInjectedDaemonSets = observer((props: Dependencies) => { + const { + daemonSetStore, + eventStore, + filterByNamespace, + } = props; - render() { - const { - daemonSetStore, - eventStore, - filterByNamespace, - podStore, - } = this.props; + const getPodsLength = (daemonSet: DaemonSet) => daemonSetStore.getChildPods(daemonSet).length; - return ( - - daemonSet.getName(), - [columnId.namespace]: daemonSet => daemonSet.getNs(), - [columnId.pods]: daemonSet => this.getPodsLength(daemonSet), - [columnId.age]: daemonSet => -daemonSet.getCreationTimestamp(), - }} - searchFilters={[ - daemonSet => daemonSet.getSearchFields(), - daemonSet => daemonSet.getLabels(), - ]} - renderHeaderTitle="Daemon Sets" - renderTableHeader={[ - { title: "Name", className: "name", sortBy: columnId.name, id: columnId.name }, - { title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace }, - { title: "Pods", className: "pods", sortBy: columnId.pods, id: columnId.pods }, - { className: "warning", showWithColumn: columnId.pods }, - { title: "Node Selector", className: "labels scrollable", id: columnId.labels }, - { title: "Age", className: "age", sortBy: columnId.age, id: columnId.age }, - ]} - renderTableContents={daemonSet => [ - daemonSet.getName(), - filterByNamespace(daemonSet.getNs()))} - > - {daemonSet.getNs()} - , - this.getPodsLength(daemonSet), - , - daemonSet.getNodeSelectors().map(selector => ( - - )), - , - ]} - /> - - ); - } -} + return ( + + daemonSet.getName(), + [columnId.namespace]: daemonSet => daemonSet.getNs(), + [columnId.pods]: daemonSet => getPodsLength(daemonSet), + [columnId.age]: daemonSet => -daemonSet.getCreationTimestamp(), + }} + searchFilters={[ + daemonSet => daemonSet.getSearchFields(), + daemonSet => daemonSet.getLabels(), + ]} + renderHeaderTitle="Daemon Sets" + renderTableHeader={[ + { title: "Name", className: "name", sortBy: columnId.name, id: columnId.name }, + { title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace }, + { title: "Pods", className: "pods", sortBy: columnId.pods, id: columnId.pods }, + { className: "warning", showWithColumn: columnId.pods }, + { title: "Node Selector", className: "labels scrollable", id: columnId.labels }, + { title: "Age", className: "age", sortBy: columnId.age, id: columnId.age }, + ]} + renderTableContents={daemonSet => [ + daemonSet.getName(), + filterByNamespace(daemonSet.getNs()))} + > + {daemonSet.getNs()} + , + getPodsLength(daemonSet), + , + daemonSet.getNodeSelectors().map(selector => ( + + )), + , + ]} + /> + + ); +}); export const DaemonSets = withInjectables(NonInjectedDaemonSets, { getProps: (di, props) => ({ @@ -112,6 +103,5 @@ export const DaemonSets = withInjectables(NonInjectedDaemonSets, { daemonSetStore: di.inject(daemonSetStoreInjectable), eventStore: di.inject(eventStoreInjectable), filterByNamespace: di.inject(filterByNamespaceInjectable), - podStore: di.inject(podStoreInjectable), }), });