1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Remove legacy global for daemonSetStore

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-10-25 12:31:11 -04:00
parent 4a39e4b50b
commit a92c53eb56
2 changed files with 60 additions and 70 deletions

View File

@ -13,13 +13,13 @@ import type { KubeObject } from "../../../common/k8s-api/kube-object";
import { Pod } from "../../../common/k8s-api/endpoints/pod.api"; import { Pod } from "../../../common/k8s-api/endpoints/pod.api";
import type { GetPodById } from "../+workloads-pods/get-pod-by-id.injectable"; import type { GetPodById } from "../+workloads-pods/get-pod-by-id.injectable";
export interface EventStoreDependencies { interface Dependencies {
getPodById: GetPodById; getPodById: GetPodById;
} }
export class EventStore extends KubeObjectStore<KubeEvent, KubeEventApi> { export class EventStore extends KubeObjectStore<KubeEvent, KubeEventApi> {
constructor( constructor(
protected readonly dependencies: EventStoreDependencies, protected readonly dependencies: Dependencies,
api: KubeEventApi, api: KubeEventApi,
opts: KubeObjectStoreOptions = {}, opts: KubeObjectStoreOptions = {},
) { ) {

View File

@ -14,7 +14,6 @@ import { KubeObjectStatusIcon } from "../kube-object-status-icon";
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout"; import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
import { KubeObjectAge } from "../kube-object/age"; import { KubeObjectAge } from "../kube-object/age";
import type { DaemonSetStore } from "./store"; import type { DaemonSetStore } from "./store";
import type { PodStore } from "../+workloads-pods/store";
import type { EventStore } from "../+events/store"; import type { EventStore } from "../+events/store";
import { prevDefault } from "../../utils"; import { prevDefault } from "../../utils";
import type { FilterByNamespace } from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable"; 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 daemonSetStoreInjectable from "./store.injectable";
import eventStoreInjectable from "../+events/store.injectable"; import eventStoreInjectable from "../+events/store.injectable";
import filterByNamespaceInjectable from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable"; import filterByNamespaceInjectable from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable";
import podStoreInjectable from "../+workloads-pods/store.injectable";
enum columnId { enum columnId {
name = "name", name = "name",
@ -34,24 +32,18 @@ enum columnId {
interface Dependencies { interface Dependencies {
daemonSetStore: DaemonSetStore; daemonSetStore: DaemonSetStore;
podStore: PodStore;
eventStore: EventStore; eventStore: EventStore;
filterByNamespace: FilterByNamespace; filterByNamespace: FilterByNamespace;
} }
@observer const NonInjectedDaemonSets = observer((props: Dependencies) => {
class NonInjectedDaemonSets extends React.Component<Dependencies> {
getPodsLength(daemonSet: DaemonSet) {
return this.props.daemonSetStore.getChildPods(daemonSet).length;
}
render() {
const { const {
daemonSetStore, daemonSetStore,
eventStore, eventStore,
filterByNamespace, filterByNamespace,
podStore, } = props;
} = this.props;
const getPodsLength = (daemonSet: DaemonSet) => daemonSetStore.getChildPods(daemonSet).length;
return ( return (
<SiblingsInTabLayout> <SiblingsInTabLayout>
@ -60,11 +52,11 @@ class NonInjectedDaemonSets extends React.Component<Dependencies> {
tableId="workload_daemonsets" tableId="workload_daemonsets"
className="DaemonSets" className="DaemonSets"
store={daemonSetStore} store={daemonSetStore}
dependentStores={[podStore, eventStore]} // status icon component uses event store dependentStores={[eventStore]} // status icon component uses event store
sortingCallbacks={{ sortingCallbacks={{
[columnId.name]: daemonSet => daemonSet.getName(), [columnId.name]: daemonSet => daemonSet.getName(),
[columnId.namespace]: daemonSet => daemonSet.getNs(), [columnId.namespace]: daemonSet => daemonSet.getNs(),
[columnId.pods]: daemonSet => this.getPodsLength(daemonSet), [columnId.pods]: daemonSet => getPodsLength(daemonSet),
[columnId.age]: daemonSet => -daemonSet.getCreationTimestamp(), [columnId.age]: daemonSet => -daemonSet.getCreationTimestamp(),
}} }}
searchFilters={[ searchFilters={[
@ -89,7 +81,7 @@ class NonInjectedDaemonSets extends React.Component<Dependencies> {
> >
{daemonSet.getNs()} {daemonSet.getNs()}
</a>, </a>,
this.getPodsLength(daemonSet), getPodsLength(daemonSet),
<KubeObjectStatusIcon key="icon" object={daemonSet} />, <KubeObjectStatusIcon key="icon" object={daemonSet} />,
daemonSet.getNodeSelectors().map(selector => ( daemonSet.getNodeSelectors().map(selector => (
<Badge <Badge
@ -103,8 +95,7 @@ class NonInjectedDaemonSets extends React.Component<Dependencies> {
/> />
</SiblingsInTabLayout> </SiblingsInTabLayout>
); );
} });
}
export const DaemonSets = withInjectables<Dependencies>(NonInjectedDaemonSets, { export const DaemonSets = withInjectables<Dependencies>(NonInjectedDaemonSets, {
getProps: (di, props) => ({ getProps: (di, props) => ({
@ -112,6 +103,5 @@ export const DaemonSets = withInjectables<Dependencies>(NonInjectedDaemonSets, {
daemonSetStore: di.inject(daemonSetStoreInjectable), daemonSetStore: di.inject(daemonSetStoreInjectable),
eventStore: di.inject(eventStoreInjectable), eventStore: di.inject(eventStoreInjectable),
filterByNamespace: di.inject(filterByNamespaceInjectable), filterByNamespace: di.inject(filterByNamespaceInjectable),
podStore: di.inject(podStoreInjectable),
}), }),
}); });