mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
convert all KubeObjectStores to injectable with legacy global backups
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
096ab7b601
commit
930af6c6fd
@ -3,7 +3,6 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { once } from "lodash/fp";
|
|
||||||
import type { ClusterId } from "../cluster-types";
|
import type { ClusterId } from "../cluster-types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,12 +25,3 @@ export function getClusterIdFromHost(host: string): ClusterId | undefined {
|
|||||||
export function getClusterFrameUrl(clusterId: ClusterId) {
|
export function getClusterFrameUrl(clusterId: ClusterId) {
|
||||||
return `//${clusterId}.${location.host}`;
|
return `//${clusterId}.${location.host}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true only if code is running within a cluster iframe context
|
|
||||||
*/
|
|
||||||
export const isClusterPageContext = once(() => {
|
|
||||||
if (typeof window === "undefined") return false;
|
|
||||||
|
|
||||||
return !!getClusterIdFromHost(window.location.host);
|
|
||||||
});
|
|
||||||
|
|||||||
@ -87,31 +87,31 @@ export {
|
|||||||
} from "./kube-object-status";
|
} from "./kube-object-status";
|
||||||
|
|
||||||
// stores
|
// stores
|
||||||
export type { EventStore } from "../../renderer/components/+events/event.store";
|
export type { EventStore } from "../../renderer/components/+events/store";
|
||||||
export type { PodStore as PodsStore } from "../../renderer/components/+workloads-pods/store";
|
export type { PodStore as PodsStore } from "../../renderer/components/+workloads-pods/store";
|
||||||
export type { NodesStore } from "../../renderer/components/+nodes/nodes.store";
|
export type { NodeStore as NodesStore } from "../../renderer/components/+nodes/store";
|
||||||
export type { DeploymentStore } from "../../renderer/components/+workloads-deployments/store";
|
export type { DeploymentStore } from "../../renderer/components/+workloads-deployments/store";
|
||||||
export type { DaemonSetStore } from "../../renderer/components/+workloads-daemonsets/store";
|
export type { DaemonSetStore } from "../../renderer/components/+workloads-daemonsets/store";
|
||||||
export type { StatefulSetStore } from "../../renderer/components/+workloads-statefulsets/store";
|
export type { StatefulSetStore } from "../../renderer/components/+workloads-statefulsets/store";
|
||||||
export type { JobStore } from "../../renderer/components/+workloads-jobs/store";
|
export type { JobStore } from "../../renderer/components/+workloads-jobs/store";
|
||||||
export type { CronJobStore } from "../../renderer/components/+workloads-cronjobs/store";
|
export type { CronJobStore } from "../../renderer/components/+workloads-cronjobs/store";
|
||||||
export type { ConfigMapStore as ConfigMapsStore } from "../../renderer/components/+config-maps/config-maps.store";
|
export type { ConfigMapStore as ConfigMapsStore } from "../../renderer/components/+config-maps/store";
|
||||||
export type { SecretStore as SecretsStore } from "../../renderer/components/+config-secrets/secrets.store";
|
export type { SecretStore as SecretsStore } from "../../renderer/components/+config-secrets/store";
|
||||||
export type { ReplicaSetStore } from "../../renderer/components/+workloads-replicasets/store";
|
export type { ReplicaSetStore } from "../../renderer/components/+workloads-replicasets/store";
|
||||||
export type { ResourceQuotaStore as ResourceQuotasStore } from "../../renderer/components/+config-resource-quotas/resource-quotas.store";
|
export type { ResourceQuotaStore as ResourceQuotasStore } from "../../renderer/components/+config-resource-quotas/store";
|
||||||
export type { LimitRangeStore as LimitRangesStore } from "../../renderer/components/+config-limit-ranges/store";
|
export type { LimitRangeStore as LimitRangesStore } from "../../renderer/components/+config-limit-ranges/store";
|
||||||
export type { HorizontalPodAutoscalerStore as HPAStore } from "../../renderer/components/+config-autoscalers/store";
|
export type { HorizontalPodAutoscalerStore as HPAStore } from "../../renderer/components/+config-autoscalers/store";
|
||||||
export type { PodDisruptionBudgetStore as PodDisruptionBudgetsStore } from "../../renderer/components/+config-pod-disruption-budgets/pod-disruption-budgets.store";
|
export type { PodDisruptionBudgetStore as PodDisruptionBudgetsStore } from "../../renderer/components/+config-pod-disruption-budgets/store";
|
||||||
export type { ServiceStore } from "../../renderer/components/+network-services/services.store";
|
export type { ServiceStore } from "../../renderer/components/+network-services/store";
|
||||||
export type { EndpointStore } from "../../renderer/components/+network-endpoints/endpoints.store";
|
export type { EndpointsStore as EndpointStore } from "../../renderer/components/+network-endpoints/store";
|
||||||
export type { IngressStore } from "../../renderer/components/+network-ingresses/ingress.store";
|
export type { IngressStore } from "../../renderer/components/+network-ingresses/store";
|
||||||
export type { NetworkPolicyStore } from "../../renderer/components/+network-policies/network-policy.store";
|
export type { NetworkPolicyStore } from "../../renderer/components/+network-policies/store";
|
||||||
export type { PersistentVolumesStore } from "../../renderer/components/+storage-volumes/volumes.store";
|
export type { PersistentVolumeStore as PersistentVolumesStore } from "../../renderer/components/+storage-volumes/store";
|
||||||
export type { PersistentVolumeClaimStore as VolumeClaimStore } from "../../renderer/components/+storage-volume-claims/volume-claim.store";
|
export type { PersistentVolumeClaimStore as VolumeClaimStore } from "../../renderer/components/+storage-volume-claims/store";
|
||||||
export type { StorageClassStore } from "../../renderer/components/+storage-classes/storage-class.store";
|
export type { StorageClassStore } from "../../renderer/components/+storage-classes/store";
|
||||||
export type { NamespaceStore } from "../../renderer/components/+namespaces/namespace-store/namespace.store";
|
export type { NamespaceStore } from "../../renderer/components/+namespaces/namespace-store/namespace.store";
|
||||||
export type { ServiceAccountStore as ServiceAccountsStore } from "../../renderer/components/+user-management/+service-accounts/store";
|
export type { ServiceAccountStore as ServiceAccountsStore } from "../../renderer/components/+user-management/+service-accounts/store";
|
||||||
export type { RoleStore as RolesStore } from "../../renderer/components/+user-management/+roles/store";
|
export type { RoleStore as RolesStore } from "../../renderer/components/+user-management/+roles/store";
|
||||||
export type { RoleBindingStore as RoleBindingsStore } from "../../renderer/components/+user-management/+role-bindings/store";
|
export type { RoleBindingStore as RoleBindingsStore } from "../../renderer/components/+user-management/+role-bindings/store";
|
||||||
export type { CRDStore } from "../../renderer/components/+custom-resources/crd.store";
|
export type { CustomResourceDefinitionStore as CRDStore } from "../../renderer/components/+custom-resources/definition.store";
|
||||||
export type { CRDResourceStore } from "../../renderer/components/+custom-resources/crd-resource.store";
|
export type { CustomResourceStore as CRDResourceStore } from "../../renderer/components/+custom-resources/resource.store";
|
||||||
|
|||||||
@ -11,8 +11,8 @@ import { computed, makeObservable } from "mobx";
|
|||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { SubHeader } from "../layout/sub-header";
|
import { SubHeader } from "../layout/sub-header";
|
||||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||||
import { nodesStore } from "../+nodes/nodes.store";
|
import { nodeStore } from "../+nodes/legacy-store";
|
||||||
import { eventStore } from "../+events/event.store";
|
import { eventStore } from "../+events/legacy-store";
|
||||||
import { cssNames, prevDefault } from "../../utils";
|
import { cssNames, prevDefault } from "../../utils";
|
||||||
import type { ItemObject } from "../../../common/item.store";
|
import type { ItemObject } from "../../../common/item.store";
|
||||||
import { Spinner } from "../spinner";
|
import { Spinner } from "../spinner";
|
||||||
@ -48,7 +48,7 @@ export class ClusterIssues extends React.Component<ClusterIssuesProps> {
|
|||||||
|
|
||||||
@computed get warnings(): Warning[] {
|
@computed get warnings(): Warning[] {
|
||||||
return [
|
return [
|
||||||
...nodesStore.items.flatMap(node => (
|
...nodeStore.items.flatMap(node => (
|
||||||
node.getWarningConditions()
|
node.getWarningConditions()
|
||||||
.map(({ message }) => ({
|
.map(({ message }) => ({
|
||||||
selfLink: node.selfLink,
|
selfLink: node.selfLink,
|
||||||
|
|||||||
@ -5,20 +5,25 @@
|
|||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { nodesStore } from "../+nodes/nodes.store";
|
import type { NodeStore } from "../+nodes/store";
|
||||||
import { cssNames } from "../../utils";
|
import { cssNames } from "../../utils";
|
||||||
import { Radio, RadioGroup } from "../radio";
|
import { Radio, RadioGroup } from "../radio";
|
||||||
import type { ClusterOverviewStore } from "./cluster-overview-store/cluster-overview-store";
|
import type { ClusterOverviewStore } from "./cluster-overview-store/cluster-overview-store";
|
||||||
import { MetricNodeRole, MetricType } from "./cluster-overview-store/cluster-overview-store";
|
import { MetricNodeRole, MetricType } from "./cluster-overview-store/cluster-overview-store";
|
||||||
import clusterOverviewStoreInjectable from "./cluster-overview-store/cluster-overview-store.injectable";
|
import clusterOverviewStoreInjectable from "./cluster-overview-store/cluster-overview-store.injectable";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
|
import nodeStoreInjectable from "../+nodes/store.injectable";
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
clusterOverviewStore: ClusterOverviewStore;
|
clusterOverviewStore: ClusterOverviewStore;
|
||||||
|
nodeStore: NodeStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NonInjectedClusterMetricSwitchers = observer(({ clusterOverviewStore }: Dependencies) => {
|
const NonInjectedClusterMetricSwitchers = observer(({
|
||||||
const { masterNodes, workerNodes } = nodesStore;
|
clusterOverviewStore,
|
||||||
|
nodeStore,
|
||||||
|
}: Dependencies) => {
|
||||||
|
const { masterNodes, workerNodes } = nodeStore;
|
||||||
const metricsValues = clusterOverviewStore.getMetricsValues(clusterOverviewStore.metrics);
|
const metricsValues = clusterOverviewStore.getMetricsValues(clusterOverviewStore.metrics);
|
||||||
const disableRoles = !masterNodes.length || !workerNodes.length;
|
const disableRoles = !masterNodes.length || !workerNodes.length;
|
||||||
const disableMetrics = !metricsValues.length;
|
const disableMetrics = !metricsValues.length;
|
||||||
@ -51,13 +56,10 @@ const NonInjectedClusterMetricSwitchers = observer(({ clusterOverviewStore }: De
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ClusterMetricSwitchers = withInjectables<Dependencies>(
|
export const ClusterMetricSwitchers = withInjectables<Dependencies>(NonInjectedClusterMetricSwitchers, {
|
||||||
NonInjectedClusterMetricSwitchers,
|
getProps: (di) => ({
|
||||||
|
clusterOverviewStore: di.inject(clusterOverviewStoreInjectable),
|
||||||
{
|
nodeStore: di.inject(nodeStoreInjectable),
|
||||||
getProps: (di) => ({
|
}),
|
||||||
clusterOverviewStore: di.inject(clusterOverviewStoreInjectable),
|
});
|
||||||
}),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import { getMetricsByNodeNames, type ClusterMetricData } from "../../../../commo
|
|||||||
import type { StorageLayer } from "../../../utils";
|
import type { StorageLayer } from "../../../utils";
|
||||||
import { autoBind } from "../../../utils";
|
import { autoBind } from "../../../utils";
|
||||||
import { type IMetricsReqParams, normalizeMetrics } from "../../../../common/k8s-api/endpoints/metrics.api";
|
import { type IMetricsReqParams, normalizeMetrics } from "../../../../common/k8s-api/endpoints/metrics.api";
|
||||||
import { nodesStore } from "../../+nodes/nodes.store";
|
import type { NodeStore } from "../../+nodes/store";
|
||||||
|
|
||||||
export enum MetricType {
|
export enum MetricType {
|
||||||
MEMORY = "memory",
|
MEMORY = "memory",
|
||||||
@ -28,7 +28,8 @@ export interface ClusterOverviewStorageState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
storage: StorageLayer<ClusterOverviewStorageState>;
|
readonly storage: StorageLayer<ClusterOverviewStorageState>;
|
||||||
|
readonly nodeStore: NodeStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ClusterOverviewStore extends KubeObjectStore<Cluster, ClusterApi> implements ClusterOverviewStorageState {
|
export class ClusterOverviewStore extends KubeObjectStore<Cluster, ClusterApi> implements ClusterOverviewStorageState {
|
||||||
@ -69,8 +70,8 @@ export class ClusterOverviewStore extends KubeObjectStore<Cluster, ClusterApi> i
|
|||||||
});
|
});
|
||||||
|
|
||||||
// check which node type to select
|
// check which node type to select
|
||||||
reaction(() => nodesStore.items.length, () => {
|
reaction(() => this.dependencies.nodeStore.items.length, () => {
|
||||||
const { masterNodes, workerNodes } = nodesStore;
|
const { masterNodes, workerNodes } = this.dependencies.nodeStore;
|
||||||
|
|
||||||
if (!masterNodes.length) this.metricNodeRole = MetricNodeRole.WORKER;
|
if (!masterNodes.length) this.metricNodeRole = MetricNodeRole.WORKER;
|
||||||
if (!workerNodes.length) this.metricNodeRole = MetricNodeRole.MASTER;
|
if (!workerNodes.length) this.metricNodeRole = MetricNodeRole.MASTER;
|
||||||
@ -79,8 +80,8 @@ export class ClusterOverviewStore extends KubeObjectStore<Cluster, ClusterApi> i
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
async loadMetrics(params?: IMetricsReqParams) {
|
async loadMetrics(params?: IMetricsReqParams) {
|
||||||
await when(() => nodesStore.isLoaded);
|
await when(() => this.dependencies.nodeStore.isLoaded);
|
||||||
const { masterNodes, workerNodes } = nodesStore;
|
const { masterNodes, workerNodes } = this.dependencies.nodeStore;
|
||||||
const nodes = this.metricNodeRole === MetricNodeRole.MASTER && masterNodes.length ? masterNodes : workerNodes;
|
const nodes = this.metricNodeRole === MetricNodeRole.MASTER && masterNodes.length ? masterNodes : workerNodes;
|
||||||
|
|
||||||
this.metrics = await getMetricsByNodeNames(nodes.map(node => node.getName()), params);
|
this.metrics = await getMetricsByNodeNames(nodes.map(node => node.getName()), params);
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import styles from "./cluster-overview.module.scss";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { reaction } from "mobx";
|
import { reaction } from "mobx";
|
||||||
import { disposeOnUnmount, observer } from "mobx-react";
|
import { disposeOnUnmount, observer } from "mobx-react";
|
||||||
import { nodesStore } from "../+nodes/nodes.store";
|
import type { NodeStore } from "../+nodes/store";
|
||||||
import type { PodStore } from "../+workloads-pods/store";
|
import type { PodStore } from "../+workloads-pods/store";
|
||||||
import { interval } from "../../utils";
|
import { interval } from "../../utils";
|
||||||
import { TabLayout } from "../layout/tab-layout";
|
import { TabLayout } from "../layout/tab-layout";
|
||||||
@ -19,7 +19,7 @@ import type { ClusterOverviewStore } from "./cluster-overview-store/cluster-over
|
|||||||
import { ClusterPieCharts } from "./cluster-pie-charts";
|
import { ClusterPieCharts } from "./cluster-pie-charts";
|
||||||
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
||||||
import { ClusterMetricsResourceType } from "../../../common/cluster-types";
|
import { ClusterMetricsResourceType } from "../../../common/cluster-types";
|
||||||
import { eventStore } from "../+events/event.store";
|
import type { EventStore } from "../+events/store";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import clusterOverviewStoreInjectable from "./cluster-overview-store/cluster-overview-store.injectable";
|
import clusterOverviewStoreInjectable from "./cluster-overview-store/cluster-overview-store.injectable";
|
||||||
import type { SubscribeStores } from "../../kube-watch-api/kube-watch-api";
|
import type { SubscribeStores } from "../../kube-watch-api/kube-watch-api";
|
||||||
@ -28,12 +28,16 @@ import hostedClusterInjectable from "../../../common/cluster-store/hosted-cluste
|
|||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
||||||
import podStoreInjectable from "../+workloads-pods/store.injectable";
|
import podStoreInjectable from "../+workloads-pods/store.injectable";
|
||||||
|
import eventStoreInjectable from "../+events/store.injectable";
|
||||||
|
import nodeStoreInjectable from "../+nodes/store.injectable";
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
subscribeStores: SubscribeStores;
|
subscribeStores: SubscribeStores;
|
||||||
clusterOverviewStore: ClusterOverviewStore;
|
clusterOverviewStore: ClusterOverviewStore;
|
||||||
hostedCluster: Cluster;
|
hostedCluster: Cluster;
|
||||||
podStore: PodStore;
|
podStore: PodStore;
|
||||||
|
eventStore: EventStore;
|
||||||
|
nodeStore: NodeStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
@ -52,8 +56,8 @@ class NonInjectedClusterOverview extends React.Component<Dependencies> {
|
|||||||
disposeOnUnmount(this, [
|
disposeOnUnmount(this, [
|
||||||
this.props.subscribeStores([
|
this.props.subscribeStores([
|
||||||
this.props.podStore,
|
this.props.podStore,
|
||||||
eventStore,
|
this.props.eventStore,
|
||||||
nodesStore,
|
this.props.nodeStore,
|
||||||
]),
|
]),
|
||||||
|
|
||||||
reaction(
|
reaction(
|
||||||
@ -94,7 +98,8 @@ class NonInjectedClusterOverview extends React.Component<Dependencies> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const isLoaded = nodesStore.isLoaded && eventStore.isLoaded;
|
const { eventStore, nodeStore } = this.props;
|
||||||
|
const isLoaded = nodeStore.isLoaded && eventStore.isLoaded;
|
||||||
const isMetricHidden = getActiveClusterEntity()?.isMetricHidden(ClusterMetricsResourceType.Cluster);
|
const isMetricHidden = getActiveClusterEntity()?.isMetricHidden(ClusterMetricsResourceType.Cluster);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -118,6 +123,8 @@ export const ClusterOverview = withInjectables<Dependencies>(NonInjectedClusterO
|
|||||||
clusterOverviewStore: di.inject(clusterOverviewStoreInjectable),
|
clusterOverviewStore: di.inject(clusterOverviewStoreInjectable),
|
||||||
hostedCluster,
|
hostedCluster,
|
||||||
podStore: di.inject(podStoreInjectable),
|
podStore: di.inject(podStoreInjectable),
|
||||||
|
eventStore: di.inject(eventStoreInjectable),
|
||||||
|
nodeStore: di.inject(nodeStoreInjectable),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import type { ClusterOverviewStore } from "./cluster-overview-store/cluster-over
|
|||||||
import { MetricNodeRole } from "./cluster-overview-store/cluster-overview-store";
|
import { MetricNodeRole } from "./cluster-overview-store/cluster-overview-store";
|
||||||
import { Spinner } from "../spinner";
|
import { Spinner } from "../spinner";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { nodesStore } from "../+nodes/nodes.store";
|
import type { NodeStore } from "../+nodes/store";
|
||||||
import type { PieChartData } from "../chart";
|
import type { PieChartData } from "../chart";
|
||||||
import { PieChart } from "../chart";
|
import { PieChart } from "../chart";
|
||||||
import { ClusterNoMetrics } from "./cluster-no-metrics";
|
import { ClusterNoMetrics } from "./cluster-no-metrics";
|
||||||
@ -20,6 +20,7 @@ import { ThemeStore } from "../../theme.store";
|
|||||||
import { getMetricLastPoints } from "../../../common/k8s-api/endpoints/metrics.api";
|
import { getMetricLastPoints } from "../../../common/k8s-api/endpoints/metrics.api";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import clusterOverviewStoreInjectable from "./cluster-overview-store/cluster-overview-store.injectable";
|
import clusterOverviewStoreInjectable from "./cluster-overview-store/cluster-overview-store.injectable";
|
||||||
|
import nodeStoreInjectable from "../+nodes/store.injectable";
|
||||||
|
|
||||||
function createLabels(rawLabelData: [string, number | undefined][]): string[] {
|
function createLabels(rawLabelData: [string, number | undefined][]): string[] {
|
||||||
return rawLabelData.map(([key, value]) => `${key}: ${value?.toFixed(2) || "N/A"}`);
|
return rawLabelData.map(([key, value]) => `${key}: ${value?.toFixed(2) || "N/A"}`);
|
||||||
@ -27,9 +28,13 @@ function createLabels(rawLabelData: [string, number | undefined][]): string[] {
|
|||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
clusterOverviewStore: ClusterOverviewStore;
|
clusterOverviewStore: ClusterOverviewStore;
|
||||||
|
nodeStore: NodeStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NonInjectedClusterPieCharts = observer(({ clusterOverviewStore }: Dependencies) => {
|
const NonInjectedClusterPieCharts = observer(({
|
||||||
|
clusterOverviewStore,
|
||||||
|
nodeStore,
|
||||||
|
}: Dependencies) => {
|
||||||
const renderLimitWarning = () => {
|
const renderLimitWarning = () => {
|
||||||
return (
|
return (
|
||||||
<div className="node-warning flex gaps align-center">
|
<div className="node-warning flex gaps align-center">
|
||||||
@ -210,7 +215,7 @@ const NonInjectedClusterPieCharts = observer(({ clusterOverviewStore }: Dependen
|
|||||||
};
|
};
|
||||||
|
|
||||||
const renderContent = ({ metricNodeRole, metricsLoaded }: ClusterOverviewStore) => {
|
const renderContent = ({ metricNodeRole, metricsLoaded }: ClusterOverviewStore) => {
|
||||||
const { masterNodes, workerNodes } = nodesStore;
|
const { masterNodes, workerNodes } = nodeStore;
|
||||||
const nodes = metricNodeRole === MetricNodeRole.MASTER ? masterNodes : workerNodes;
|
const nodes = metricNodeRole === MetricNodeRole.MASTER ? masterNodes : workerNodes;
|
||||||
|
|
||||||
if (!nodes.length) {
|
if (!nodes.length) {
|
||||||
@ -249,12 +254,9 @@ const NonInjectedClusterPieCharts = observer(({ clusterOverviewStore }: Dependen
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ClusterPieCharts = withInjectables<Dependencies>(
|
export const ClusterPieCharts = withInjectables<Dependencies>(NonInjectedClusterPieCharts, {
|
||||||
NonInjectedClusterPieCharts,
|
getProps: (di) => ({
|
||||||
|
clusterOverviewStore: di.inject(clusterOverviewStoreInjectable),
|
||||||
{
|
nodeStore: di.inject(nodeStoreInjectable),
|
||||||
getProps: (di) => ({
|
}),
|
||||||
clusterOverviewStore: di.inject(clusterOverviewStoreInjectable),
|
});
|
||||||
}),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import React from "react";
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import type { HorizontalPodAutoscaler } from "../../../common/k8s-api/endpoints/horizontal-pod-autoscaler.api";
|
import type { HorizontalPodAutoscaler } from "../../../common/k8s-api/endpoints/horizontal-pod-autoscaler.api";
|
||||||
import { hpaStore } from "./hpa.store";
|
import { horizontalPodAutoscalerStore } from "./legacy-store";
|
||||||
import { Badge } from "../badge";
|
import { Badge } from "../badge";
|
||||||
import { cssNames } from "../../utils";
|
import { cssNames } from "../../utils";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
@ -54,7 +54,7 @@ export class HorizontalPodAutoscalers extends React.Component {
|
|||||||
isConfigurable
|
isConfigurable
|
||||||
tableId="configuration_hpa"
|
tableId="configuration_hpa"
|
||||||
className="HorizontalPodAutoscalers"
|
className="HorizontalPodAutoscalers"
|
||||||
store={hpaStore}
|
store={horizontalPodAutoscalerStore}
|
||||||
sortingCallbacks={{
|
sortingCallbacks={{
|
||||||
[columnId.name]: hpa => hpa.getName(),
|
[columnId.name]: hpa => hpa.getName(),
|
||||||
[columnId.namespace]: hpa => hpa.getNs(),
|
[columnId.namespace]: hpa => hpa.getNs(),
|
||||||
|
|||||||
12
src/renderer/components/+config-autoscalers/legacy-store.ts
Normal file
12
src/renderer/components/+config-autoscalers/legacy-store.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import horizontalPodAutoscalerStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(horizontalPodAutoscalerStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const horizontalPodAutoscalerStore = asLegacyGlobalForExtensionApi(horizontalPodAutoscalerStoreInjectable);
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import horizontalPodAutoscalerApiInjectable from "../../../common/k8s-api/endpoints/horizontal-pod-autoscaler.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { HorizontalPodAutoscalerStore } from "./store";
|
||||||
|
|
||||||
|
const horizontalPodAutoscalerStoreInjectable = getInjectable({
|
||||||
|
id: "horizontal-pod-autoscaler-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "horizontalPodAutoscalerStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(horizontalPodAutoscalerApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new HorizontalPodAutoscalerStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default horizontalPodAutoscalerStoreInjectable;
|
||||||
@ -5,17 +5,6 @@
|
|||||||
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import type { HorizontalPodAutoscaler, HorizontalPodAutoscalerApi } from "../../../common/k8s-api/endpoints/horizontal-pod-autoscaler.api";
|
import type { HorizontalPodAutoscaler, HorizontalPodAutoscalerApi } from "../../../common/k8s-api/endpoints/horizontal-pod-autoscaler.api";
|
||||||
import { horizontalPodAutoscalerApi } from "../../../common/k8s-api/endpoints/horizontal-pod-autoscaler.api";
|
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import { isClusterPageContext } from "../../utils";
|
|
||||||
|
|
||||||
export class HorizontalPodAutoscalerStore extends KubeObjectStore<HorizontalPodAutoscaler, HorizontalPodAutoscalerApi> {
|
export class HorizontalPodAutoscalerStore extends KubeObjectStore<HorizontalPodAutoscaler, HorizontalPodAutoscalerApi> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const hpaStore = isClusterPageContext()
|
|
||||||
? new HorizontalPodAutoscalerStore(horizontalPodAutoscalerApi)
|
|
||||||
: undefined as never;
|
|
||||||
|
|
||||||
if (isClusterPageContext()) {
|
|
||||||
apiManager.registerStore(hpaStore);
|
|
||||||
}
|
|
||||||
12
src/renderer/components/+config-limit-ranges/legacy-store.ts
Normal file
12
src/renderer/components/+config-limit-ranges/legacy-store.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import limitRangeStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(limitRangeStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const limitRangeStore = asLegacyGlobalForExtensionApi(limitRangeStoreInjectable);
|
||||||
@ -7,7 +7,7 @@ import "./limit-ranges.scss";
|
|||||||
|
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { limitRangeStore } from "./limit-ranges.store";
|
import { limitRangeStore } from "./legacy-store";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import limitRangeApiInjectable from "../../../common/k8s-api/endpoints/limit-range.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { LimitRangeStore } from "./store";
|
||||||
|
|
||||||
|
const limitRangeStoreInjectable = getInjectable({
|
||||||
|
id: "limit-range-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "limitRangeStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(limitRangeApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new LimitRangeStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default limitRangeStoreInjectable;
|
||||||
@ -4,18 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import type { LimitRange, LimitRangeApi } from "../../../common/k8s-api/endpoints/limit-range.api";
|
import type { LimitRange, LimitRangeApi } from "../../../common/k8s-api/endpoints/limit-range.api";
|
||||||
import { limitRangeApi } from "../../../common/k8s-api/endpoints/limit-range.api";
|
|
||||||
import { isClusterPageContext } from "../../utils";
|
|
||||||
|
|
||||||
export class LimitRangeStore extends KubeObjectStore<LimitRange, LimitRangeApi> {
|
export class LimitRangeStore extends KubeObjectStore<LimitRange, LimitRangeApi> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const limitRangeStore = isClusterPageContext()
|
|
||||||
? new LimitRangeStore(limitRangeApi)
|
|
||||||
: undefined as never;
|
|
||||||
|
|
||||||
if (isClusterPageContext()) {
|
|
||||||
apiManager.registerStore(limitRangeStore);
|
|
||||||
}
|
|
||||||
@ -12,7 +12,7 @@ import { DrawerTitle } from "../drawer";
|
|||||||
import { Notifications } from "../notifications";
|
import { Notifications } from "../notifications";
|
||||||
import { Input } from "../input";
|
import { Input } from "../input";
|
||||||
import { Button } from "../button";
|
import { Button } from "../button";
|
||||||
import { configMapStore } from "./config-maps.store";
|
import { configMapStore } from "./legacy-store";
|
||||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||||
import { ConfigMap } from "../../../common/k8s-api/endpoints";
|
import { ConfigMap } from "../../../common/k8s-api/endpoints";
|
||||||
import { KubeObjectMeta } from "../kube-object-meta";
|
import { KubeObjectMeta } from "../kube-object-meta";
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import "./config-maps.scss";
|
|||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { configMapStore } from "./config-maps.store";
|
import { configMapStore } from "./legacy-store";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
||||||
|
|||||||
12
src/renderer/components/+config-maps/legacy-store.ts
Normal file
12
src/renderer/components/+config-maps/legacy-store.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import configMapStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(configMapStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const configMapStore = asLegacyGlobalForExtensionApi(configMapStoreInjectable);
|
||||||
27
src/renderer/components/+config-maps/store.injectable.ts
Normal file
27
src/renderer/components/+config-maps/store.injectable.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import configMapApiInjectable from "../../../common/k8s-api/endpoints/config-map.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { ConfigMapStore } from "./store";
|
||||||
|
|
||||||
|
const configMapStoreInjectable = getInjectable({
|
||||||
|
id: "config-map-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "configMapStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(configMapApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new ConfigMapStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default configMapStoreInjectable;
|
||||||
@ -5,17 +5,6 @@
|
|||||||
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import type { ConfigMap, ConfigMapApi, ConfigMapData } from "../../../common/k8s-api/endpoints/config-map.api";
|
import type { ConfigMap, ConfigMapApi, ConfigMapData } from "../../../common/k8s-api/endpoints/config-map.api";
|
||||||
import { configMapApi } from "../../../common/k8s-api/endpoints/config-map.api";
|
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import { isClusterPageContext } from "../../utils";
|
|
||||||
|
|
||||||
export class ConfigMapStore extends KubeObjectStore<ConfigMap, ConfigMapApi, ConfigMapData> {
|
export class ConfigMapStore extends KubeObjectStore<ConfigMap, ConfigMapApi, ConfigMapData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const configMapStore = isClusterPageContext()
|
|
||||||
? new ConfigMapStore(configMapApi)
|
|
||||||
: undefined as never;
|
|
||||||
|
|
||||||
if (isClusterPageContext()) {
|
|
||||||
apiManager.registerStore(configMapStore);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import podDisruptionBudgetStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(podDisruptionBudgetStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const podDisruptionBudgetStore = asLegacyGlobalForExtensionApi(podDisruptionBudgetStoreInjectable);
|
||||||
@ -7,7 +7,7 @@ import "./pod-disruption-budgets.scss";
|
|||||||
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { podDisruptionBudgetsStore } from "./pod-disruption-budgets.store";
|
import { podDisruptionBudgetStore } from "./legacy-store";
|
||||||
import type { PodDisruptionBudget } from "../../../common/k8s-api/endpoints/pod-disruption-budget.api";
|
import type { PodDisruptionBudget } from "../../../common/k8s-api/endpoints/pod-disruption-budget.api";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||||
@ -37,7 +37,7 @@ export class PodDisruptionBudgets extends React.Component<PodDisruptionBudgetsPr
|
|||||||
isConfigurable
|
isConfigurable
|
||||||
tableId="configuration_distribution_budgets"
|
tableId="configuration_distribution_budgets"
|
||||||
className="PodDisruptionBudgets"
|
className="PodDisruptionBudgets"
|
||||||
store={podDisruptionBudgetsStore}
|
store={podDisruptionBudgetStore}
|
||||||
sortingCallbacks={{
|
sortingCallbacks={{
|
||||||
[columnId.name]: pdb => pdb.getName(),
|
[columnId.name]: pdb => pdb.getName(),
|
||||||
[columnId.namespace]: pdb => pdb.getNs(),
|
[columnId.namespace]: pdb => pdb.getNs(),
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import podDisruptionBudgetApiInjectable from "../../../common/k8s-api/endpoints/pod-disruption-budget.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { PodDisruptionBudgetStore } from "./store";
|
||||||
|
|
||||||
|
const podDisruptionBudgetStoreInjectable = getInjectable({
|
||||||
|
id: "pod-disruption-budget-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "podDisruptionBudgetStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(podDisruptionBudgetApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new PodDisruptionBudgetStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default podDisruptionBudgetStoreInjectable;
|
||||||
@ -5,17 +5,6 @@
|
|||||||
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import type { PodDisruptionBudget, PodDisruptionBudgetApi } from "../../../common/k8s-api/endpoints/pod-disruption-budget.api";
|
import type { PodDisruptionBudget, PodDisruptionBudgetApi } from "../../../common/k8s-api/endpoints/pod-disruption-budget.api";
|
||||||
import { podDisruptionBudgetApi } from "../../../common/k8s-api/endpoints/pod-disruption-budget.api";
|
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import { isClusterPageContext } from "../../utils";
|
|
||||||
|
|
||||||
export class PodDisruptionBudgetStore extends KubeObjectStore<PodDisruptionBudget, PodDisruptionBudgetApi> {
|
export class PodDisruptionBudgetStore extends KubeObjectStore<PodDisruptionBudget, PodDisruptionBudgetApi> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const podDisruptionBudgetsStore = isClusterPageContext()
|
|
||||||
? new PodDisruptionBudgetStore(podDisruptionBudgetApi)
|
|
||||||
: undefined as never;
|
|
||||||
|
|
||||||
if (isClusterPageContext()) {
|
|
||||||
apiManager.registerStore(podDisruptionBudgetsStore);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import resourceQuotaStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(resourceQuotaStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const resourceQuotaStore = asLegacyGlobalForExtensionApi(resourceQuotaStoreInjectable);
|
||||||
@ -9,7 +9,7 @@ import React from "react";
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { AddQuotaDialog } from "./add-quota-dialog";
|
import { AddQuotaDialog } from "./add-quota-dialog";
|
||||||
import { resourceQuotaStore } from "./resource-quotas.store";
|
import { resourceQuotaStore } from "./legacy-store";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
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";
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import resourceQuotaApiInjectable from "../../../common/k8s-api/endpoints/resource-quota.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { ResourceQuotaStore } from "./store";
|
||||||
|
|
||||||
|
const resourceQuotaStoreInjectable = getInjectable({
|
||||||
|
id: "resource-quota-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "resourceQuotaStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(resourceQuotaApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new ResourceQuotaStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default resourceQuotaStoreInjectable;
|
||||||
@ -5,17 +5,6 @@
|
|||||||
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import type { ResourceQuota, ResourceQuotaApi } from "../../../common/k8s-api/endpoints/resource-quota.api";
|
import type { ResourceQuota, ResourceQuotaApi } from "../../../common/k8s-api/endpoints/resource-quota.api";
|
||||||
import { resourceQuotaApi } from "../../../common/k8s-api/endpoints/resource-quota.api";
|
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import { isClusterPageContext } from "../../utils";
|
|
||||||
|
|
||||||
export class ResourceQuotaStore extends KubeObjectStore<ResourceQuota, ResourceQuotaApi> {
|
export class ResourceQuotaStore extends KubeObjectStore<ResourceQuota, ResourceQuotaApi> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const resourceQuotaStore = isClusterPageContext()
|
|
||||||
? new ResourceQuotaStore(resourceQuotaApi)
|
|
||||||
: undefined as never;
|
|
||||||
|
|
||||||
if (isClusterPageContext()) {
|
|
||||||
apiManager.registerStore(resourceQuotaStore);
|
|
||||||
}
|
|
||||||
12
src/renderer/components/+config-secrets/legacy-store.ts
Normal file
12
src/renderer/components/+config-secrets/legacy-store.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import secretStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(secretStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const secretStore = asLegacyGlobalForExtensionApi(secretStoreInjectable);
|
||||||
@ -14,7 +14,7 @@ import { Button } from "../button";
|
|||||||
import { Notifications } from "../notifications";
|
import { Notifications } from "../notifications";
|
||||||
import { base64, toggle } from "../../utils";
|
import { base64, toggle } from "../../utils";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { secretStore } from "./secrets.store";
|
import { secretStore } from "./legacy-store";
|
||||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||||
import { Secret } from "../../../common/k8s-api/endpoints";
|
import { Secret } from "../../../common/k8s-api/endpoints";
|
||||||
import { KubeObjectMeta } from "../kube-object-meta";
|
import { KubeObjectMeta } from "../kube-object-meta";
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import { observer } from "mobx-react";
|
|||||||
import { AddSecretDialog } from "./add-secret-dialog";
|
import { AddSecretDialog } from "./add-secret-dialog";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { Badge } from "../badge";
|
import { Badge } from "../badge";
|
||||||
import { secretStore } from "./secrets.store";
|
import { secretStore } from "./legacy-store";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
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";
|
||||||
|
|||||||
27
src/renderer/components/+config-secrets/store.injectable.ts
Normal file
27
src/renderer/components/+config-secrets/store.injectable.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import secretApiInjectable from "../../../common/k8s-api/endpoints/secret.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { SecretStore } from "./store";
|
||||||
|
|
||||||
|
const secretStoreInjectable = getInjectable({
|
||||||
|
id: "secret-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "secretStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(secretApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new SecretStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default secretStoreInjectable;
|
||||||
@ -5,17 +5,6 @@
|
|||||||
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import type { Secret, SecretApi, SecretData } from "../../../common/k8s-api/endpoints";
|
import type { Secret, SecretApi, SecretData } from "../../../common/k8s-api/endpoints";
|
||||||
import { secretApi } from "../../../common/k8s-api/endpoints";
|
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import { isClusterPageContext } from "../../utils";
|
|
||||||
|
|
||||||
export class SecretStore extends KubeObjectStore<Secret, SecretApi, SecretData> {
|
export class SecretStore extends KubeObjectStore<Secret, SecretApi, SecretData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const secretStore = isClusterPageContext()
|
|
||||||
? new SecretStore(secretApi)
|
|
||||||
: undefined as never;
|
|
||||||
|
|
||||||
if (isClusterPageContext()) {
|
|
||||||
apiManager.registerStore(secretStore);
|
|
||||||
}
|
|
||||||
@ -11,7 +11,7 @@ import { observer } from "mobx-react";
|
|||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { iter, stopPropagation } from "../../utils";
|
import { iter, stopPropagation } from "../../utils";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { crdStore } from "./crd.store";
|
import { customResourceDefinitionStore } from "./legacy-store";
|
||||||
import { Select } from "../select";
|
import { Select } from "../select";
|
||||||
import { createPageParam } from "../../navigation";
|
import { createPageParam } from "../../navigation";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
@ -42,10 +42,10 @@ export class CustomResourceDefinitions extends React.Component {
|
|||||||
|
|
||||||
@computed get items() {
|
@computed get items() {
|
||||||
if (this.selectedGroups.size) {
|
if (this.selectedGroups.size) {
|
||||||
return crdStore.items.filter(item => this.selectedGroups.has(item.getGroup()));
|
return customResourceDefinitionStore.items.filter(item => this.selectedGroups.has(item.getGroup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return crdStore.items; // show all by default
|
return customResourceDefinitionStore.items; // show all by default
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleSelection = (options: readonly ({ group: string })[]) => {
|
toggleSelection = (options: readonly ({ group: string })[]) => {
|
||||||
@ -76,8 +76,8 @@ export class CustomResourceDefinitions extends React.Component {
|
|||||||
isConfigurable
|
isConfigurable
|
||||||
tableId="crd"
|
tableId="crd"
|
||||||
className="CrdList"
|
className="CrdList"
|
||||||
store={crdStore}
|
store={customResourceDefinitionStore}
|
||||||
// Don't subscribe the `crdStore` because <Sidebar> already has and is always mounted
|
// Don't subscribe the `customResourceDefinitionStore` because <Sidebar> already has and is always mounted
|
||||||
subscribeStores={false}
|
subscribeStores={false}
|
||||||
items={items}
|
items={items}
|
||||||
sortingCallbacks={{
|
sortingCallbacks={{
|
||||||
@ -103,7 +103,7 @@ export class CustomResourceDefinitions extends React.Component {
|
|||||||
<Select
|
<Select
|
||||||
className="group-select"
|
className="group-select"
|
||||||
placeholder={this.getPlaceholder()}
|
placeholder={this.getPlaceholder()}
|
||||||
options={Object.keys(crdStore.groups).map(group => ({ group }))}
|
options={Object.keys(customResourceDefinitionStore.groups).map(group => ({ group }))}
|
||||||
onChange={this.toggleSelection}
|
onChange={this.toggleSelection}
|
||||||
closeMenuOnSelect={false}
|
closeMenuOnSelect={false}
|
||||||
controlShouldRenderValue={false}
|
controlShouldRenderValue={false}
|
||||||
|
|||||||
@ -10,13 +10,15 @@ import { observer } from "mobx-react";
|
|||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import type { IComputedValue } from "mobx";
|
import type { IComputedValue } from "mobx";
|
||||||
import { computed, makeObservable } from "mobx";
|
import { computed, makeObservable } from "mobx";
|
||||||
import { crdStore } from "./crd.store";
|
import type { ApiManager } from "../../../common/k8s-api/api-manager";
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import { safeJSONPathValue } from "../../utils/jsonPath";
|
import { safeJSONPathValue } from "../../utils/jsonPath";
|
||||||
import { TabLayout } from "../layout/tab-layout-2";
|
import { TabLayout } from "../layout/tab-layout-2";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import customResourcesRouteParametersInjectable from "./custom-resources-route-parameters.injectable";
|
import customResourcesRouteParametersInjectable from "./custom-resources-route-parameters.injectable";
|
||||||
import { KubeObjectAge } from "../kube-object/age";
|
import { KubeObjectAge } from "../kube-object/age";
|
||||||
|
import type { CustomResourceDefinitionStore } from "./definition.store";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import customResourceDefinitionStoreInjectable from "./definition.store.injectable";
|
||||||
|
|
||||||
enum columnId {
|
enum columnId {
|
||||||
name = "name",
|
name = "name",
|
||||||
@ -27,21 +29,23 @@ enum columnId {
|
|||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
group: IComputedValue<string>;
|
group: IComputedValue<string>;
|
||||||
name: IComputedValue<string>;
|
name: IComputedValue<string>;
|
||||||
|
apiManager: ApiManager;
|
||||||
|
customResourceDefinitionStore: CustomResourceDefinitionStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
class NonInjectedCrdResources extends React.Component<Dependencies> {
|
class NonInjectedCustomResources extends React.Component<Dependencies> {
|
||||||
constructor(props: Dependencies) {
|
constructor(props: Dependencies) {
|
||||||
super(props);
|
super(props);
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@computed get crd() {
|
@computed get crd() {
|
||||||
return crdStore.getByGroup(this.props.group.get(), this.props.name.get());
|
return this.props.customResourceDefinitionStore.getByGroup(this.props.group.get(), this.props.name.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@computed get store() {
|
@computed get store() {
|
||||||
return apiManager.getStore(this.crd?.getResourceApiBase());
|
return this.props.apiManager.getStore(this.crd?.getResourceApiBase());
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -120,18 +124,11 @@ class NonInjectedCrdResources extends React.Component<Dependencies> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CrdResources = withInjectables<Dependencies>(
|
export const CustomResources = withInjectables<Dependencies>(NonInjectedCustomResources, {
|
||||||
NonInjectedCrdResources,
|
getProps: (di) => ({
|
||||||
|
...di.inject(customResourcesRouteParametersInjectable),
|
||||||
{
|
apiManager: di.inject(apiManagerInjectable),
|
||||||
getProps: (di) => {
|
customResourceDefinitionStore: di.inject(customResourceDefinitionStoreInjectable),
|
||||||
const routeParameters = di.inject(customResourcesRouteParametersInjectable);
|
}),
|
||||||
|
});
|
||||||
return {
|
|
||||||
group: routeParameters.group,
|
|
||||||
name: routeParameters.name,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { CrdResources } from "./crd-resources";
|
import { CustomResources } from "./crd-resources";
|
||||||
import customResourcesRouteInjectable from "../../../common/front-end-routing/routes/cluster/custom-resources/custom-resources/custom-resources-route.injectable";
|
import customResourcesRouteInjectable from "../../../common/front-end-routing/routes/cluster/custom-resources/custom-resources/custom-resources-route.injectable";
|
||||||
import { routeSpecificComponentInjectionToken } from "../../routes/route-specific-component-injection-token";
|
import { routeSpecificComponentInjectionToken } from "../../routes/route-specific-component-injection-token";
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ const customResourcesRouteComponentInjectable = getInjectable({
|
|||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => ({
|
||||||
route: di.inject(customResourcesRouteInjectable),
|
route: di.inject(customResourcesRouteInjectable),
|
||||||
Component: CrdResources,
|
Component: CustomResources,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
injectionToken: routeSpecificComponentInjectionToken,
|
injectionToken: routeSpecificComponentInjectionToken,
|
||||||
|
|||||||
@ -5,23 +5,24 @@
|
|||||||
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { computed } from "mobx";
|
import { computed } from "mobx";
|
||||||
import { crdStore } from "./crd.store";
|
|
||||||
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
||||||
import currentlyInClusterFrameInjectable from "../../routes/currently-in-cluster-frame.injectable";
|
import currentlyInClusterFrameInjectable from "../../routes/currently-in-cluster-frame.injectable";
|
||||||
|
import customResourceDefinitionStoreInjectable from "./definition.store.injectable";
|
||||||
|
|
||||||
const customResourceDefinitionsInjectable = getInjectable({
|
const customResourceDefinitionsInjectable = getInjectable({
|
||||||
id: "custom-resource-definitions",
|
id: "custom-resource-definitions",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const currentlyInClusterFrame = di.inject(currentlyInClusterFrameInjectable);
|
const currentlyInClusterFrame = di.inject(currentlyInClusterFrameInjectable);
|
||||||
|
const store = di.inject(customResourceDefinitionStoreInjectable);
|
||||||
|
|
||||||
if (currentlyInClusterFrame) {
|
if (currentlyInClusterFrame) {
|
||||||
const subscribeStores = di.inject(subscribeStoresInjectable);
|
const subscribeStores = di.inject(subscribeStoresInjectable);
|
||||||
|
|
||||||
subscribeStores([crdStore]);
|
subscribeStores([store]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return computed(() => [...crdStore.items]);
|
return computed(() => [...store.items]);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import customResourceDefinitionApiInjectable from "../../../common/k8s-api/endpoints/custom-resource-definition.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { CustomResourceDefinitionStore } from "./definition.store";
|
||||||
|
import initCustomResourceStoreInjectable from "./init-resource-store.injectable";
|
||||||
|
|
||||||
|
const customResourceDefinitionStoreInjectable = getInjectable({
|
||||||
|
id: "custom-resource-definition-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "customResourceDefinitionStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(customResourceDefinitionApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new CustomResourceDefinitionStore({
|
||||||
|
initCustomResourceStore: di.inject(initCustomResourceStoreInjectable),
|
||||||
|
}, api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default customResourceDefinitionStoreInjectable;
|
||||||
@ -4,39 +4,29 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { computed, reaction, makeObservable } from "mobx";
|
import { computed, reaction, makeObservable } from "mobx";
|
||||||
|
import type { KubeObjectStoreOptions } from "../../../common/k8s-api/kube-object.store";
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import { autoBind, isClusterPageContext } from "../../utils";
|
import { autoBind } from "../../utils";
|
||||||
import type { CustomResourceDefinition, CustomResourceDefinitionApi } from "../../../common/k8s-api/endpoints/custom-resource-definition.api";
|
import type { CustomResourceDefinition, CustomResourceDefinitionApi } from "../../../common/k8s-api/endpoints/custom-resource-definition.api";
|
||||||
import { crdApi } from "../../../common/k8s-api/endpoints/custom-resource-definition.api";
|
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
import type { InitCustomResourceStore } from "./init-resource-store.injectable";
|
||||||
import { KubeApi } from "../../../common/k8s-api/kube-api";
|
|
||||||
import { CRDResourceStore } from "./crd-resource.store";
|
|
||||||
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
|
||||||
|
|
||||||
function initStore(crd: CustomResourceDefinition) {
|
export interface CustomResourceDefinitionStoreDependencies {
|
||||||
const objectConstructor = class extends KubeObject {
|
initCustomResourceStore: InitCustomResourceStore;
|
||||||
static readonly kind = crd.getResourceKind();
|
|
||||||
static readonly namespaced = crd.isNamespaced();
|
|
||||||
static readonly apiBase = crd.getResourceApiBase();
|
|
||||||
};
|
|
||||||
|
|
||||||
const api = apiManager.getApi(objectConstructor.apiBase)
|
|
||||||
?? new KubeApi({ objectConstructor });
|
|
||||||
|
|
||||||
if (!apiManager.getStore(api)) {
|
|
||||||
apiManager.registerStore(new CRDResourceStore(api));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CRDStore extends KubeObjectStore<CustomResourceDefinition, CustomResourceDefinitionApi> {
|
export class CustomResourceDefinitionStore extends KubeObjectStore<CustomResourceDefinition, CustomResourceDefinitionApi> {
|
||||||
constructor() {
|
constructor(
|
||||||
super(crdApi);
|
protected readonly dependencies: CustomResourceDefinitionStoreDependencies,
|
||||||
|
api: CustomResourceDefinitionApi,
|
||||||
|
opts?: KubeObjectStoreOptions,
|
||||||
|
) {
|
||||||
|
super(api, opts);
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
autoBind(this);
|
autoBind(this);
|
||||||
|
|
||||||
// auto-init stores for crd-s
|
// auto-init stores for crd-s
|
||||||
reaction(() => this.getItems(), items => items.forEach(initStore));
|
reaction(() => this.getItems(), items => items.forEach(this.dependencies.initCustomResourceStore));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected sortItems(items: CustomResourceDefinition[]) {
|
protected sortItems(items: CustomResourceDefinition[]) {
|
||||||
@ -69,11 +59,3 @@ export class CRDStore extends KubeObjectStore<CustomResourceDefinition, CustomRe
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const crdStore = isClusterPageContext()
|
|
||||||
? new CRDStore()
|
|
||||||
: undefined as never;
|
|
||||||
|
|
||||||
if (isClusterPageContext()) {
|
|
||||||
apiManager.registerStore(crdStore);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import type { CustomResourceDefinition } from "../../../common/k8s-api/endpoints";
|
||||||
|
import { KubeApi } from "../../../common/k8s-api/kube-api";
|
||||||
|
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||||
|
import { CustomResourceStore } from "./resource.store";
|
||||||
|
|
||||||
|
export type InitCustomResourceStore = (crd: CustomResourceDefinition) => void;
|
||||||
|
|
||||||
|
const initCustomResourceStoreInjectable = getInjectable({
|
||||||
|
id: "init-custom-resource-store",
|
||||||
|
instantiate: (di): InitCustomResourceStore => {
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
|
||||||
|
return (crd) => {
|
||||||
|
const objectConstructor = class extends KubeObject {
|
||||||
|
static readonly kind = crd.getResourceKind();
|
||||||
|
static readonly namespaced = crd.isNamespaced();
|
||||||
|
static readonly apiBase = crd.getResourceApiBase();
|
||||||
|
};
|
||||||
|
|
||||||
|
const api = apiManager.getApi(objectConstructor.apiBase)
|
||||||
|
?? new KubeApi({ objectConstructor });
|
||||||
|
|
||||||
|
if (!apiManager.getStore(api)) {
|
||||||
|
apiManager.registerStore(new CustomResourceStore(api));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default initCustomResourceStoreInjectable;
|
||||||
12
src/renderer/components/+custom-resources/legacy-store.ts
Normal file
12
src/renderer/components/+custom-resources/legacy-store.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import customResourceDefinitionStoreInjectable from "./definition.store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(customResourceDefinitionStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const customResourceDefinitionStore = asLegacyGlobalForExtensionApi(customResourceDefinitionStoreInjectable);
|
||||||
@ -7,7 +7,7 @@ import type { KubeApi } from "../../../common/k8s-api/kube-api";
|
|||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||||
|
|
||||||
export class CRDResourceStore<K extends KubeObject> extends KubeObjectStore<K, KubeApi<K>> {
|
export class CustomResourceStore<K extends KubeObject> extends KubeObjectStore<K, KubeApi<K>> {
|
||||||
constructor(api: KubeApi<K>) {
|
constructor(api: KubeApi<K>) {
|
||||||
super(api);
|
super(api);
|
||||||
}
|
}
|
||||||
@ -10,8 +10,7 @@ import { computed, observable, makeObservable } from "mobx";
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { orderBy } from "lodash";
|
import { orderBy } from "lodash";
|
||||||
import { TabLayout } from "../layout/tab-layout-2";
|
import { TabLayout } from "../layout/tab-layout-2";
|
||||||
import type { EventStore } from "./event.store";
|
import type { EventStore } from "./store";
|
||||||
import { eventStore } from "./event.store";
|
|
||||||
import type { KubeObjectListLayoutProps } from "../kube-object-list-layout";
|
import type { KubeObjectListLayoutProps } from "../kube-object-list-layout";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import type { KubeEvent, KubeEventApi, KubeEventData } from "../../../common/k8s-api/endpoints/events.api";
|
import type { KubeEvent, KubeEventApi, KubeEventData } from "../../../common/k8s-api/endpoints/events.api";
|
||||||
@ -23,11 +22,13 @@ import type { IClassName } from "../../utils";
|
|||||||
import { cssNames, stopPropagation } from "../../utils";
|
import { cssNames, stopPropagation } from "../../utils";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { getDetailsUrl } from "../kube-detail-params";
|
import { getDetailsUrl } from "../kube-detail-params";
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
import type { ApiManager } from "../../../common/k8s-api/api-manager";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import navigateToEventsInjectable from "../../../common/front-end-routing/routes/cluster/events/navigate-to-events.injectable";
|
import navigateToEventsInjectable from "../../../common/front-end-routing/routes/cluster/events/navigate-to-events.injectable";
|
||||||
import { KubeObjectAge } from "../kube-object/age";
|
import { KubeObjectAge } from "../kube-object/age";
|
||||||
import { ReactiveDuration } from "../duration/reactive-duration";
|
import { ReactiveDuration } from "../duration/reactive-duration";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import eventStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
enum columnId {
|
enum columnId {
|
||||||
message = "message",
|
message = "message",
|
||||||
@ -52,6 +53,8 @@ const defaultProps: Partial<EventsProps> = {
|
|||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
navigateToEvents: () => void;
|
navigateToEvents: () => void;
|
||||||
|
eventStore: EventStore;
|
||||||
|
apiManager: ApiManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
@ -77,12 +80,8 @@ class NonInjectedEvents extends React.Component<Dependencies & EventsProps> {
|
|||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
get store(): EventStore {
|
|
||||||
return eventStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
@computed get items(): KubeEvent[] {
|
@computed get items(): KubeEvent[] {
|
||||||
const items = this.store.contextItems;
|
const items = this.props.eventStore.contextItems;
|
||||||
const { sortBy, orderBy: order } = this.sorting;
|
const { sortBy, orderBy: order } = this.sorting;
|
||||||
|
|
||||||
// we must sort items before passing to "KubeObjectListLayout -> Table"
|
// we must sort items before passing to "KubeObjectListLayout -> Table"
|
||||||
@ -101,8 +100,8 @@ class NonInjectedEvents extends React.Component<Dependencies & EventsProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
customizeHeader: HeaderCustomizer = ({ info, title, ...headerPlaceholders }) => {
|
customizeHeader: HeaderCustomizer = ({ info, title, ...headerPlaceholders }) => {
|
||||||
const { compact } = this.props;
|
const { compact, eventStore } = this.props;
|
||||||
const { store, items, visibleItems } = this;
|
const { items, visibleItems } = this;
|
||||||
const allEventsAreShown = visibleItems.length === items.length;
|
const allEventsAreShown = visibleItems.length === items.length;
|
||||||
|
|
||||||
// handle "compact"-mode header
|
// handle "compact"-mode header
|
||||||
@ -133,7 +132,7 @@ class NonInjectedEvents extends React.Component<Dependencies & EventsProps> {
|
|||||||
small
|
small
|
||||||
material="help_outline"
|
material="help_outline"
|
||||||
className="help-icon"
|
className="help-icon"
|
||||||
tooltip={`Limited to ${store.limit}`}
|
tooltip={`Limited to ${eventStore.limit}`}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
@ -143,15 +142,14 @@ class NonInjectedEvents extends React.Component<Dependencies & EventsProps> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { store } = this;
|
const { apiManager, eventStore, compact, compactLimit, className, ...layoutProps } = this.props;
|
||||||
const { compact, compactLimit, className, ...layoutProps } = this.props;
|
|
||||||
|
|
||||||
const events = (
|
const events = (
|
||||||
<KubeObjectListLayout
|
<KubeObjectListLayout
|
||||||
{...layoutProps}
|
{...layoutProps}
|
||||||
isConfigurable
|
isConfigurable
|
||||||
tableId="events"
|
tableId="events"
|
||||||
store={store}
|
store={eventStore}
|
||||||
className={cssNames("Events", className, { compact })}
|
className={cssNames("Events", className, { compact })}
|
||||||
renderHeaderTitle="Events"
|
renderHeaderTitle="Events"
|
||||||
customizeHeader={this.customizeHeader}
|
customizeHeader={this.customizeHeader}
|
||||||
@ -227,13 +225,11 @@ class NonInjectedEvents extends React.Component<Dependencies & EventsProps> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Events = withInjectables<Dependencies, EventsProps>(
|
export const Events = withInjectables<Dependencies, EventsProps>(NonInjectedEvents, {
|
||||||
NonInjectedEvents,
|
getProps: (di, props) => ({
|
||||||
|
...props,
|
||||||
{
|
navigateToEvents: di.inject(navigateToEventsInjectable),
|
||||||
getProps: (di, props) => ({
|
apiManager: di.inject(apiManagerInjectable),
|
||||||
navigateToEvents: di.inject(navigateToEventsInjectable),
|
eventStore: di.inject(eventStoreInjectable),
|
||||||
...props,
|
}),
|
||||||
}),
|
});
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|||||||
@ -11,12 +11,13 @@ import { KubeObject } from "../../../common/k8s-api/kube-object";
|
|||||||
import { DrawerItem, DrawerTitle } from "../drawer";
|
import { DrawerItem, DrawerTitle } from "../drawer";
|
||||||
import { cssNames } from "../../utils";
|
import { cssNames } from "../../utils";
|
||||||
import { LocaleDate } from "../locale-date";
|
import { LocaleDate } from "../locale-date";
|
||||||
import { eventStore } from "./event.store";
|
import type { EventStore } from "./store";
|
||||||
import logger from "../../../common/logger";
|
import logger from "../../../common/logger";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
|
|
||||||
import type { SubscribeStores } from "../../kube-watch-api/kube-watch-api";
|
import type { SubscribeStores } from "../../kube-watch-api/kube-watch-api";
|
||||||
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
||||||
|
import eventStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
export interface KubeEventDetailsProps {
|
export interface KubeEventDetailsProps {
|
||||||
object: KubeObject;
|
object: KubeObject;
|
||||||
@ -24,6 +25,7 @@ export interface KubeEventDetailsProps {
|
|||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
subscribeStores: SubscribeStores;
|
subscribeStores: SubscribeStores;
|
||||||
|
eventStore: EventStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
@ -31,13 +33,13 @@ class NonInjectedKubeEventDetails extends React.Component<KubeEventDetailsProps
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
disposeOnUnmount(this, [
|
disposeOnUnmount(this, [
|
||||||
this.props.subscribeStores([
|
this.props.subscribeStores([
|
||||||
eventStore,
|
this.props.eventStore,
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { object } = this.props;
|
const { object, eventStore } = this.props;
|
||||||
|
|
||||||
if (!object) {
|
if (!object) {
|
||||||
return null;
|
return null;
|
||||||
@ -90,6 +92,7 @@ export const KubeEventDetails = withInjectables<Dependencies, KubeEventDetailsPr
|
|||||||
getProps: (di, props) => ({
|
getProps: (di, props) => ({
|
||||||
...props,
|
...props,
|
||||||
subscribeStores: di.inject(subscribeStoresInjectable),
|
subscribeStores: di.inject(subscribeStoresInjectable),
|
||||||
|
eventStore: di.inject(eventStoreInjectable),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import "./kube-event-icon.scss";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||||
import { eventStore } from "./event.store";
|
import { eventStore } from "./legacy-store";
|
||||||
import { cssNames } from "../../utils";
|
import { cssNames } from "../../utils";
|
||||||
import type { KubeEvent } from "../../../common/k8s-api/endpoints/events.api";
|
import type { KubeEvent } from "../../../common/k8s-api/endpoints/events.api";
|
||||||
import { KubeObjectAge } from "../kube-object/age";
|
import { KubeObjectAge } from "../kube-object/age";
|
||||||
|
|||||||
12
src/renderer/components/+events/legacy-store.ts
Normal file
12
src/renderer/components/+events/legacy-store.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import eventStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(eventStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const eventStore = asLegacyGlobalForExtensionApi(eventStoreInjectable);
|
||||||
30
src/renderer/components/+events/store.injectable.ts
Normal file
30
src/renderer/components/+events/store.injectable.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import getPodByIdInjectable from "../+workloads-pods/get-pod-by-id.injectable";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import kubeEventApiInjectable from "../../../common/k8s-api/endpoints/events.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { EventStore } from "./store";
|
||||||
|
|
||||||
|
const eventStoreInjectable = getInjectable({
|
||||||
|
id: "event-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "eventStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(kubeEventApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new EventStore({
|
||||||
|
getPodById: di.inject(getPodByIdInjectable),
|
||||||
|
}, api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default eventStoreInjectable;
|
||||||
@ -5,18 +5,25 @@
|
|||||||
|
|
||||||
import groupBy from "lodash/groupBy";
|
import groupBy from "lodash/groupBy";
|
||||||
import compact from "lodash/compact";
|
import compact from "lodash/compact";
|
||||||
|
import type { KubeObjectStoreOptions } from "../../../common/k8s-api/kube-object.store";
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import { autoBind, isClusterPageContext } from "../../utils";
|
import { autoBind } from "../../utils";
|
||||||
import type { KubeEvent, KubeEventApi } from "../../../common/k8s-api/endpoints/events.api";
|
import type { KubeEvent, KubeEventApi } from "../../../common/k8s-api/endpoints/events.api";
|
||||||
import { eventApi } from "../../../common/k8s-api/endpoints/events.api";
|
|
||||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
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 { podStore } from "../+workloads-pods/legacy-store";
|
import type { GetPodById } from "../+workloads-pods/get-pod-by-id.injectable";
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
|
export interface EventStoreDependencies {
|
||||||
|
getPodById: GetPodById;
|
||||||
|
}
|
||||||
|
|
||||||
export class EventStore extends KubeObjectStore<KubeEvent, KubeEventApi> {
|
export class EventStore extends KubeObjectStore<KubeEvent, KubeEventApi> {
|
||||||
constructor(api: KubeEventApi) {
|
constructor(
|
||||||
super(api, { limit: 1000 });
|
protected readonly dependencies: EventStoreDependencies,
|
||||||
|
api: KubeEventApi,
|
||||||
|
opts: KubeObjectStoreOptions = {},
|
||||||
|
) {
|
||||||
|
super(api, { limit: 1000, ...opts });
|
||||||
autoBind(this);
|
autoBind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,9 +55,11 @@ export class EventStore extends KubeObjectStore<KubeEvent, KubeEventApi> {
|
|||||||
const { kind, uid } = recent.involvedObject;
|
const { kind, uid } = recent.involvedObject;
|
||||||
|
|
||||||
if (kind == Pod.kind) { // Wipe out running pods
|
if (kind == Pod.kind) { // Wipe out running pods
|
||||||
const pod = podStore.getById(uid);
|
const pod = this.dependencies.getPodById(uid);
|
||||||
|
|
||||||
if (!pod || (!pod.hasIssues() && (pod.spec?.priority ?? 0) < 500000)) return undefined;
|
if (!pod || (!pod.hasIssues() && (pod.spec?.priority ?? 0) < 500000)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return recent;
|
return recent;
|
||||||
@ -63,11 +72,3 @@ export class EventStore extends KubeObjectStore<KubeEvent, KubeEventApi> {
|
|||||||
return this.getWarnings().length;
|
return this.getWarnings().length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const eventStore = isClusterPageContext()
|
|
||||||
? new EventStore(eventApi)
|
|
||||||
: undefined as never;
|
|
||||||
|
|
||||||
if (isClusterPageContext()) {
|
|
||||||
apiManager.registerStore(eventStore);
|
|
||||||
}
|
|
||||||
@ -14,9 +14,9 @@ import { getMetricsForNamespace, type PodMetricData, Namespace } from "../../../
|
|||||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { Spinner } from "../spinner";
|
import { Spinner } from "../spinner";
|
||||||
import { resourceQuotaStore } from "../+config-resource-quotas/resource-quotas.store";
|
import { resourceQuotaStore } from "../+config-resource-quotas/legacy-store";
|
||||||
import { KubeObjectMeta } from "../kube-object-meta";
|
import { KubeObjectMeta } from "../kube-object-meta";
|
||||||
import { limitRangeStore } from "../+config-limit-ranges/limit-ranges.store";
|
import { limitRangeStore } from "../+config-limit-ranges/legacy-store";
|
||||||
import { ResourceMetrics } from "../resource-metrics";
|
import { ResourceMetrics } from "../resource-metrics";
|
||||||
import { PodCharts, podMetricTabs } from "../+workloads-pods/pod-charts";
|
import { PodCharts, podMetricTabs } from "../+workloads-pods/pod-charts";
|
||||||
import { ClusterMetricsResourceType } from "../../../common/cluster-types";
|
import { ClusterMetricsResourceType } from "../../../common/cluster-types";
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
|
||||||
import type { Endpoints, EndpointsApi, EndpointsData } from "../../../common/k8s-api/endpoints/endpoint.api";
|
|
||||||
import { endpointsApi } from "../../../common/k8s-api/endpoints/endpoint.api";
|
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import { isClusterPageContext } from "../../utils";
|
|
||||||
|
|
||||||
export class EndpointStore extends KubeObjectStore<Endpoints, EndpointsApi, EndpointsData> {
|
|
||||||
}
|
|
||||||
|
|
||||||
export const endpointStore = isClusterPageContext()
|
|
||||||
? new EndpointStore(endpointsApi)
|
|
||||||
: undefined as never;
|
|
||||||
|
|
||||||
if (isClusterPageContext()) {
|
|
||||||
apiManager.registerStore(endpointStore);
|
|
||||||
}
|
|
||||||
@ -7,7 +7,7 @@ import "./endpoints.scss";
|
|||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { endpointStore } from "./endpoints.store";
|
import { endpointsStore } from "./legacy-store";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
||||||
@ -29,7 +29,7 @@ export class Endpoints extends React.Component {
|
|||||||
isConfigurable
|
isConfigurable
|
||||||
tableId="network_endpoints"
|
tableId="network_endpoints"
|
||||||
className="Endpoints"
|
className="Endpoints"
|
||||||
store={endpointStore}
|
store={endpointsStore}
|
||||||
sortingCallbacks={{
|
sortingCallbacks={{
|
||||||
[columnId.name]: endpoint => endpoint.getName(),
|
[columnId.name]: endpoint => endpoint.getName(),
|
||||||
[columnId.namespace]: endpoint => endpoint.getNs(),
|
[columnId.namespace]: endpoint => endpoint.getNs(),
|
||||||
|
|||||||
12
src/renderer/components/+network-endpoints/legacy-store.ts
Normal file
12
src/renderer/components/+network-endpoints/legacy-store.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import endpointsStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(endpointsStoreInjectable)`
|
||||||
|
*/
|
||||||
|
export const endpointsStore = asLegacyGlobalForExtensionApi(endpointsStoreInjectable);
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import endpointsApiInjectable from "../../../common/k8s-api/endpoints/endpoint.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { EndpointsStore } from "./store";
|
||||||
|
|
||||||
|
const endpointsStoreInjectable = getInjectable({
|
||||||
|
id: "endpoints-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "endpointsStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(endpointsApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new EndpointsStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default endpointsStoreInjectable;
|
||||||
10
src/renderer/components/+network-endpoints/store.ts
Normal file
10
src/renderer/components/+network-endpoints/store.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
|
import type { Endpoints, EndpointsApi, EndpointsData } from "../../../common/k8s-api/endpoints/endpoint.api";
|
||||||
|
|
||||||
|
export class EndpointsStore extends KubeObjectStore<Endpoints, EndpointsApi, EndpointsData> {
|
||||||
|
}
|
||||||
@ -7,7 +7,7 @@ import "./ingresses.scss";
|
|||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { ingressStore } from "./ingress.store";
|
import { ingressStore } from "./legacy-store";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
||||||
|
|||||||
12
src/renderer/components/+network-ingresses/legacy-store.ts
Normal file
12
src/renderer/components/+network-ingresses/legacy-store.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import ingressStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(ingressStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const ingressStore = asLegacyGlobalForExtensionApi(ingressStoreInjectable);
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import ingressApiInjectable from "../../../common/k8s-api/endpoints/ingress.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { IngressStore } from "./store";
|
||||||
|
|
||||||
|
const ingressStoreInjectable = getInjectable({
|
||||||
|
id: "ingress-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "ingressStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(ingressApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new IngressStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default ingressStoreInjectable;
|
||||||
@ -2,19 +2,8 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import type { Ingress, IngressApi } from "../../../common/k8s-api/endpoints";
|
import type { Ingress, IngressApi } from "../../../common/k8s-api/endpoints";
|
||||||
import { ingressApi } from "../../../common/k8s-api/endpoints";
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import { isClusterPageContext } from "../../utils";
|
|
||||||
|
|
||||||
export class IngressStore extends KubeObjectStore<Ingress, IngressApi> {
|
export class IngressStore extends KubeObjectStore<Ingress, IngressApi> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ingressStore = isClusterPageContext()
|
|
||||||
? new IngressStore(ingressApi)
|
|
||||||
: undefined as never;
|
|
||||||
|
|
||||||
if (isClusterPageContext()) {
|
|
||||||
apiManager.registerStore(ingressStore);
|
|
||||||
}
|
|
||||||
12
src/renderer/components/+network-policies/legacy-store.ts
Normal file
12
src/renderer/components/+network-policies/legacy-store.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import networkPolicyStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(networkPolicyStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const networkPolicyStore = asLegacyGlobalForExtensionApi(networkPolicyStoreInjectable);
|
||||||
@ -8,7 +8,7 @@ import "./network-policies.scss";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { networkPolicyStore } from "./network-policy.store";
|
import { networkPolicyStore } from "./legacy-store";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
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";
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import networkPolicyApiInjectable from "../../../common/k8s-api/endpoints/network-policy.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { NetworkPolicyStore } from "./store";
|
||||||
|
|
||||||
|
const networkPolicyStoreInjectable = getInjectable({
|
||||||
|
id: "network-policy-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "networkPolicyStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(networkPolicyApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new NetworkPolicyStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default networkPolicyStoreInjectable;
|
||||||
@ -5,11 +5,6 @@
|
|||||||
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import type { NetworkPolicy, NetworkPolicyApi } from "../../../common/k8s-api/endpoints/network-policy.api";
|
import type { NetworkPolicy, NetworkPolicyApi } from "../../../common/k8s-api/endpoints/network-policy.api";
|
||||||
import { networkPolicyApi } from "../../../common/k8s-api/endpoints/network-policy.api";
|
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
|
|
||||||
export class NetworkPolicyStore extends KubeObjectStore<NetworkPolicy, NetworkPolicyApi> {
|
export class NetworkPolicyStore extends KubeObjectStore<NetworkPolicy, NetworkPolicyApi> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const networkPolicyStore = new NetworkPolicyStore(networkPolicyApi);
|
|
||||||
apiManager.registerStore(networkPolicyStore);
|
|
||||||
12
src/renderer/components/+network-services/legacy-store.ts
Normal file
12
src/renderer/components/+network-services/legacy-store.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import serviceStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(serviceStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const serviceStore = asLegacyGlobalForExtensionApi(serviceStoreInjectable);
|
||||||
@ -7,7 +7,7 @@ import { observer } from "mobx-react";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Table, TableHead, TableCell, TableRow } from "../table";
|
import { Table, TableHead, TableCell, TableRow } from "../table";
|
||||||
import { prevDefault } from "../../utils";
|
import { prevDefault } from "../../utils";
|
||||||
import { endpointStore } from "../+network-endpoints/endpoints.store";
|
import { endpointsStore } from "../+network-endpoints/legacy-store";
|
||||||
import { Spinner } from "../spinner";
|
import { Spinner } from "../spinner";
|
||||||
import { showDetails } from "../kube-detail-params";
|
import { showDetails } from "../kube-detail-params";
|
||||||
import logger from "../../../common/logger";
|
import logger from "../../../common/logger";
|
||||||
@ -22,7 +22,7 @@ export class ServiceDetailsEndpoint extends React.Component<ServiceDetailsEndpoi
|
|||||||
render() {
|
render() {
|
||||||
const { endpoints } = this.props;
|
const { endpoints } = this.props;
|
||||||
|
|
||||||
if (!endpoints && !endpointStore.isLoaded) return (
|
if (!endpoints && !endpointsStore.isLoaded) return (
|
||||||
<div className="PodDetailsList flex justify-center"><Spinner/></div>
|
<div className="PodDetailsList flex justify-center"><Spinner/></div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import type { KubeObjectDetailsProps } from "../kube-object-details";
|
|||||||
import { Service } from "../../../common/k8s-api/endpoints";
|
import { Service } from "../../../common/k8s-api/endpoints";
|
||||||
import { KubeObjectMeta } from "../kube-object-meta";
|
import { KubeObjectMeta } from "../kube-object-meta";
|
||||||
import { ServicePortComponent } from "./service-port-component";
|
import { ServicePortComponent } from "./service-port-component";
|
||||||
import { endpointStore } from "../+network-endpoints/endpoints.store";
|
import type { EndpointsStore } from "../+network-endpoints/store";
|
||||||
import { ServiceDetailsEndpoint } from "./service-details-endpoint";
|
import { ServiceDetailsEndpoint } from "./service-details-endpoint";
|
||||||
import type { PortForwardStore } from "../../port-forward";
|
import type { PortForwardStore } from "../../port-forward";
|
||||||
import logger from "../../../common/logger";
|
import logger from "../../../common/logger";
|
||||||
@ -21,6 +21,7 @@ import { withInjectables } from "@ogre-tools/injectable-react";
|
|||||||
import portForwardStoreInjectable from "../../port-forward/port-forward-store/port-forward-store.injectable";
|
import portForwardStoreInjectable from "../../port-forward/port-forward-store/port-forward-store.injectable";
|
||||||
import type { SubscribeStores } from "../../kube-watch-api/kube-watch-api";
|
import type { SubscribeStores } from "../../kube-watch-api/kube-watch-api";
|
||||||
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
||||||
|
import endpointsStoreInjectable from "../+network-endpoints/store.injectable";
|
||||||
|
|
||||||
export interface ServiceDetailsProps extends KubeObjectDetailsProps<Service> {
|
export interface ServiceDetailsProps extends KubeObjectDetailsProps<Service> {
|
||||||
}
|
}
|
||||||
@ -28,25 +29,31 @@ export interface ServiceDetailsProps extends KubeObjectDetailsProps<Service> {
|
|||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
subscribeStores: SubscribeStores;
|
subscribeStores: SubscribeStores;
|
||||||
portForwardStore: PortForwardStore;
|
portForwardStore: PortForwardStore;
|
||||||
|
endpointsStore: EndpointsStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
class NonInjectedServiceDetails extends React.Component<ServiceDetailsProps & Dependencies> {
|
class NonInjectedServiceDetails extends React.Component<ServiceDetailsProps & Dependencies> {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { object: service } = this.props;
|
const {
|
||||||
|
object: service,
|
||||||
|
subscribeStores,
|
||||||
|
endpointsStore,
|
||||||
|
portForwardStore,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
disposeOnUnmount(this, [
|
disposeOnUnmount(this, [
|
||||||
this.props.subscribeStores([
|
subscribeStores([
|
||||||
endpointStore,
|
endpointsStore,
|
||||||
], {
|
], {
|
||||||
namespaces: [service.getNs()],
|
namespaces: [service.getNs()],
|
||||||
}),
|
}),
|
||||||
this.props.portForwardStore.watch(),
|
portForwardStore.watch(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { object: service } = this.props;
|
const { object: service, endpointsStore } = this.props;
|
||||||
|
|
||||||
if (!service) {
|
if (!service) {
|
||||||
return null;
|
return null;
|
||||||
@ -59,7 +66,7 @@ class NonInjectedServiceDetails extends React.Component<ServiceDetailsProps & De
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { spec } = service;
|
const { spec } = service;
|
||||||
const endpoints = endpointStore.getByName(service.getName(), service.getNs());
|
const endpoints = endpointsStore.getByName(service.getName(), service.getNs());
|
||||||
const externalIps = service.getExternalIps();
|
const externalIps = service.getExternalIps();
|
||||||
|
|
||||||
if (externalIps.length === 0 && spec?.externalName) {
|
if (externalIps.length === 0 && spec?.externalName) {
|
||||||
@ -150,5 +157,6 @@ export const ServiceDetails = withInjectables<Dependencies, ServiceDetailsProps>
|
|||||||
...props,
|
...props,
|
||||||
subscribeStores: di.inject(subscribeStoresInjectable),
|
subscribeStores: di.inject(subscribeStoresInjectable),
|
||||||
portForwardStore: di.inject(portForwardStoreInjectable),
|
portForwardStore: di.inject(portForwardStoreInjectable),
|
||||||
|
endpointsStore: di.inject(endpointsStoreInjectable),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import React from "react";
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { Badge } from "../badge";
|
import { Badge } from "../badge";
|
||||||
import { serviceStore } from "./services.store";
|
import { serviceStore } from "./legacy-store";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
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";
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import serviceApiInjectable from "../../../common/k8s-api/endpoints/service.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { ServiceStore } from "./store";
|
||||||
|
|
||||||
|
const serviceStoreInjectable = getInjectable({
|
||||||
|
id: "service-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "serviceStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(serviceApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new ServiceStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default serviceStoreInjectable;
|
||||||
@ -5,11 +5,6 @@
|
|||||||
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import type { Service, ServiceApi } from "../../../common/k8s-api/endpoints/service.api";
|
import type { Service, ServiceApi } from "../../../common/k8s-api/endpoints/service.api";
|
||||||
import { serviceApi } from "../../../common/k8s-api/endpoints/service.api";
|
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
|
|
||||||
export class ServiceStore extends KubeObjectStore<Service, ServiceApi> {
|
export class ServiceStore extends KubeObjectStore<Service, ServiceApi> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const serviceStore = new ServiceStore(serviceApi);
|
|
||||||
apiManager.registerStore(serviceStore);
|
|
||||||
12
src/renderer/components/+nodes/legacy-store.ts
Normal file
12
src/renderer/components/+nodes/legacy-store.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import nodeStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(nodeStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const nodeStore = asLegacyGlobalForExtensionApi(nodeStoreInjectable);
|
||||||
@ -8,7 +8,7 @@ import React from "react";
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { cssNames, interval } from "../../utils";
|
import { cssNames, interval } from "../../utils";
|
||||||
import { TabLayout } from "../layout/tab-layout-2";
|
import { TabLayout } from "../layout/tab-layout-2";
|
||||||
import { nodesStore } from "./nodes.store";
|
import { nodeStore } from "./legacy-store";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import type { NodeMetricData, Node } from "../../../common/k8s-api/endpoints/node.api";
|
import type { NodeMetricData, Node } from "../../../common/k8s-api/endpoints/node.api";
|
||||||
import { formatNodeTaint, getMetricsForAllNodes } from "../../../common/k8s-api/endpoints/node.api";
|
import { formatNodeTaint, getMetricsForAllNodes } from "../../../common/k8s-api/endpoints/node.api";
|
||||||
@ -19,7 +19,7 @@ import kebabCase from "lodash/kebabCase";
|
|||||||
import upperFirst from "lodash/upperFirst";
|
import upperFirst from "lodash/upperFirst";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
import { Badge } from "../badge/badge";
|
import { Badge } from "../badge/badge";
|
||||||
import { eventStore } from "../+events/event.store";
|
import { eventStore } from "../+events/legacy-store";
|
||||||
import { makeObservable, observable } from "mobx";
|
import { makeObservable, observable } from "mobx";
|
||||||
import isEmpty from "lodash/isEmpty";
|
import isEmpty from "lodash/isEmpty";
|
||||||
import { KubeObjectAge } from "../kube-object/age";
|
import { KubeObjectAge } from "../kube-object/age";
|
||||||
@ -181,8 +181,8 @@ export class NodesRoute extends React.Component {
|
|||||||
isConfigurable
|
isConfigurable
|
||||||
tableId="nodes"
|
tableId="nodes"
|
||||||
className="Nodes"
|
className="Nodes"
|
||||||
store={nodesStore}
|
store={nodeStore}
|
||||||
isReady={nodesStore.isLoaded}
|
isReady={nodeStore.isLoaded}
|
||||||
dependentStores={[eventStore]}
|
dependentStores={[eventStore]}
|
||||||
isSelectable={false}
|
isSelectable={false}
|
||||||
sortingCallbacks={{
|
sortingCallbacks={{
|
||||||
|
|||||||
27
src/renderer/components/+nodes/store.injectable.ts
Normal file
27
src/renderer/components/+nodes/store.injectable.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import nodeApiInjectable from "../../../common/k8s-api/endpoints/node.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { NodeStore } from "./store";
|
||||||
|
|
||||||
|
const nodeStoreInjectable = getInjectable({
|
||||||
|
id: "node-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "nodeStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(nodeApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new NodeStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default nodeStoreInjectable;
|
||||||
@ -5,15 +5,14 @@
|
|||||||
import { sum } from "lodash";
|
import { sum } from "lodash";
|
||||||
import { computed, makeObservable } from "mobx";
|
import { computed, makeObservable } from "mobx";
|
||||||
|
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import type { Node, NodeApi } from "../../../common/k8s-api/endpoints";
|
import type { Node, NodeApi } from "../../../common/k8s-api/endpoints";
|
||||||
import { nodeApi } from "../../../common/k8s-api/endpoints";
|
import type { KubeObjectStoreOptions } from "../../../common/k8s-api/kube-object.store";
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import { autoBind, isClusterPageContext } from "../../utils";
|
import { autoBind } from "../../utils";
|
||||||
|
|
||||||
export class NodesStore extends KubeObjectStore<Node, NodeApi> {
|
export class NodeStore extends KubeObjectStore<Node, NodeApi> {
|
||||||
constructor() {
|
constructor(api: NodeApi, opts?: KubeObjectStoreOptions) {
|
||||||
super(nodeApi);
|
super(api, opts);
|
||||||
|
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
autoBind(this);
|
autoBind(this);
|
||||||
@ -28,14 +27,6 @@ export class NodesStore extends KubeObjectStore<Node, NodeApi> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getWarningsCount(): number {
|
getWarningsCount(): number {
|
||||||
return sum(this.items.map((node: Node) => node.getWarningConditions().length));
|
return sum(this.items.map((node) => node.getWarningConditions().length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const nodesStore = isClusterPageContext()
|
|
||||||
? new NodesStore()
|
|
||||||
: undefined as never;
|
|
||||||
|
|
||||||
if (isClusterPageContext()) {
|
|
||||||
apiManager.registerStore(nodesStore);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import podSecurityPolicyStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(podSecurityPolicyStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const podSecurityPolicyStore = asLegacyGlobalForExtensionApi(podSecurityPolicyStoreInjectable);
|
||||||
@ -8,7 +8,7 @@ import "./pod-security-policies.scss";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { podSecurityPolicyStore } from "./pod-security-policies.store";
|
import { podSecurityPolicyStore } from "./legacy-store";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
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";
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import podSecurityPolicyApiInjectable from "../../../common/k8s-api/endpoints/pod-security-policy.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { PodSecurityPolicyStore } from "./store";
|
||||||
|
|
||||||
|
const podSecurityPolicyStoreInjectable = getInjectable({
|
||||||
|
id: "pod-security-policy-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "podSecurityPolicyStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(podSecurityPolicyApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new PodSecurityPolicyStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default podSecurityPolicyStoreInjectable;
|
||||||
@ -4,12 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type { PodSecurityPolicy, PodSecurityPolicyApi } from "../../../common/k8s-api/endpoints";
|
import type { PodSecurityPolicy, PodSecurityPolicyApi } from "../../../common/k8s-api/endpoints";
|
||||||
import { podSecurityPolicyApi } from "../../../common/k8s-api/endpoints";
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
|
|
||||||
export class PodSecurityPolicyStore extends KubeObjectStore<PodSecurityPolicy, PodSecurityPolicyApi> {
|
export class PodSecurityPolicyStore extends KubeObjectStore<PodSecurityPolicy, PodSecurityPolicyApi> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const podSecurityPolicyStore = new PodSecurityPolicyStore(podSecurityPolicyApi);
|
|
||||||
apiManager.registerStore(podSecurityPolicyStore);
|
|
||||||
12
src/renderer/components/+storage-classes/legacy-store.ts
Normal file
12
src/renderer/components/+storage-classes/legacy-store.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import storageClassStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(storageClassStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const storageClassStore = asLegacyGlobalForExtensionApi(storageClassStoreInjectable);
|
||||||
@ -13,19 +13,23 @@ import { disposeOnUnmount, observer } from "mobx-react";
|
|||||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||||
import { StorageClass } from "../../../common/k8s-api/endpoints";
|
import { StorageClass } from "../../../common/k8s-api/endpoints";
|
||||||
import { KubeObjectMeta } from "../kube-object-meta";
|
import { KubeObjectMeta } from "../kube-object-meta";
|
||||||
import { storageClassStore } from "./storage-class.store";
|
import type { StorageClassStore } from "./store";
|
||||||
import { VolumeDetailsList } from "../+storage-volumes/volume-details-list";
|
import { VolumeDetailsList } from "../+storage-volumes/volume-details-list";
|
||||||
import { volumesStore } from "../+storage-volumes/volumes.store";
|
import type { PersistentVolumeStore } from "../+storage-volumes/store";
|
||||||
import logger from "../../../common/logger";
|
import logger from "../../../common/logger";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import type { SubscribeStores } from "../../kube-watch-api/kube-watch-api";
|
import type { SubscribeStores } from "../../kube-watch-api/kube-watch-api";
|
||||||
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
||||||
|
import storageClassStoreInjectable from "./store.injectable";
|
||||||
|
import persistentVolumeStoreInjectable from "../+storage-volumes/store.injectable";
|
||||||
|
|
||||||
export interface StorageClassDetailsProps extends KubeObjectDetailsProps<StorageClass> {
|
export interface StorageClassDetailsProps extends KubeObjectDetailsProps<StorageClass> {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
subscribeStores: SubscribeStores;
|
subscribeStores: SubscribeStores;
|
||||||
|
storageClassStore: StorageClassStore;
|
||||||
|
persistentVolumeStore: PersistentVolumeStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
@ -33,13 +37,13 @@ class NonInjectedStorageClassDetails extends React.Component<StorageClassDetails
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
disposeOnUnmount(this, [
|
disposeOnUnmount(this, [
|
||||||
this.props.subscribeStores([
|
this.props.subscribeStores([
|
||||||
volumesStore,
|
this.props.persistentVolumeStore,
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { object: storageClass } = this.props;
|
const { object: storageClass, storageClassStore } = this.props;
|
||||||
|
|
||||||
if (!storageClass) {
|
if (!storageClass) {
|
||||||
return null;
|
return null;
|
||||||
@ -97,6 +101,8 @@ export const StorageClassDetails = withInjectables<Dependencies, StorageClassDet
|
|||||||
getProps: (di, props) => ({
|
getProps: (di, props) => ({
|
||||||
...props,
|
...props,
|
||||||
subscribeStores: di.inject(subscribeStoresInjectable),
|
subscribeStores: di.inject(subscribeStoresInjectable),
|
||||||
|
storageClassStore: di.inject(storageClassStoreInjectable),
|
||||||
|
persistentVolumeStore: di.inject(persistentVolumeStoreInjectable),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,19 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
|
||||||
import type { StorageClass, StorageClassApi, StorageClassData } from "../../../common/k8s-api/endpoints/storage-class.api";
|
|
||||||
import { storageClassApi } from "../../../common/k8s-api/endpoints/storage-class.api";
|
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import { volumesStore } from "../+storage-volumes/volumes.store";
|
|
||||||
|
|
||||||
export class StorageClassStore extends KubeObjectStore<StorageClass, StorageClassApi, StorageClassData> {
|
|
||||||
getPersistentVolumes(storageClass: StorageClass) {
|
|
||||||
return volumesStore.getByStorageClass(storageClass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const storageClassStore = new StorageClassStore(storageClassApi);
|
|
||||||
apiManager.registerStore(storageClassStore);
|
|
||||||
@ -8,7 +8,7 @@ import "./storage-classes.scss";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { storageClassStore } from "./storage-class.store";
|
import { storageClassStore } from "./legacy-store";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
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";
|
||||||
|
|||||||
30
src/renderer/components/+storage-classes/store.injectable.ts
Normal file
30
src/renderer/components/+storage-classes/store.injectable.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import getPersistentVolumesByStorageClassInjectable from "../+storage-volumes/get-persisten-volumes-by-storage-class.injectable";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import storageClassApiInjectable from "../../../common/k8s-api/endpoints/storage-class.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { StorageClassStore } from "./store";
|
||||||
|
|
||||||
|
const storageClassStoreInjectable = getInjectable({
|
||||||
|
id: "storage-class-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "storageClassStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(storageClassApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new StorageClassStore({
|
||||||
|
getPersistentVolumesByStorageClass: di.inject(getPersistentVolumesByStorageClassInjectable),
|
||||||
|
}, api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default storageClassStoreInjectable;
|
||||||
27
src/renderer/components/+storage-classes/store.ts
Normal file
27
src/renderer/components/+storage-classes/store.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { KubeObjectStoreOptions } from "../../../common/k8s-api/kube-object.store";
|
||||||
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
|
import type { StorageClass, StorageClassApi, StorageClassData } from "../../../common/k8s-api/endpoints/storage-class.api";
|
||||||
|
import type { GetPersistentVolumesByStorageClass } from "../+storage-volumes/get-persisten-volumes-by-storage-class.injectable";
|
||||||
|
|
||||||
|
export interface StorageClassStoreDependencies {
|
||||||
|
getPersistentVolumesByStorageClass: GetPersistentVolumesByStorageClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class StorageClassStore extends KubeObjectStore<StorageClass, StorageClassApi, StorageClassData> {
|
||||||
|
constructor(
|
||||||
|
protected readonly dependencies: StorageClassStoreDependencies,
|
||||||
|
api: StorageClassApi,
|
||||||
|
opts?: KubeObjectStoreOptions,
|
||||||
|
) {
|
||||||
|
super(api, opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
getPersistentVolumes(storageClass: StorageClass) {
|
||||||
|
return this.dependencies.getPersistentVolumesByStorageClass(storageClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import persistentVolumeClaimStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(persistentVolumeClaimStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const persistentVolumeClaimStore = asLegacyGlobalForExtensionApi(persistentVolumeClaimStoreInjectable);
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import persistentVolumeClaimApiInjectable from "../../../common/k8s-api/endpoints/persistent-volume-claim.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { PersistentVolumeClaimStore } from "./store";
|
||||||
|
|
||||||
|
const persistentVolumeClaimStoreInjectable = getInjectable({
|
||||||
|
id: "persistent-volume-claim-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "persistentVolumeClaimStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(persistentVolumeClaimApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new PersistentVolumeClaimStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default persistentVolumeClaimStoreInjectable;
|
||||||
@ -2,13 +2,8 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import type { PersistentVolumeClaim, PersistentVolumeClaimApi } from "../../../common/k8s-api/endpoints";
|
import type { PersistentVolumeClaim, PersistentVolumeClaimApi } from "../../../common/k8s-api/endpoints";
|
||||||
import { persistentVolumeClaimApi } from "../../../common/k8s-api/endpoints";
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
|
|
||||||
export class PersistentVolumeClaimStore extends KubeObjectStore<PersistentVolumeClaim, PersistentVolumeClaimApi> {
|
export class PersistentVolumeClaimStore extends KubeObjectStore<PersistentVolumeClaim, PersistentVolumeClaimApi> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const persistentVolumeClaimStore = new PersistentVolumeClaimStore(persistentVolumeClaimApi);
|
|
||||||
apiManager.registerStore(persistentVolumeClaimStore);
|
|
||||||
@ -8,7 +8,7 @@ import "./volume-claims.scss";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { persistentVolumeClaimStore } from "./volume-claim.store";
|
import { persistentVolumeClaimStore } from "./legacy-store";
|
||||||
import { podStore } from "../+workloads-pods/legacy-store";
|
import { podStore } from "../+workloads-pods/legacy-store";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { unitsToBytes } from "../../../common/utils/convertMemory";
|
import { unitsToBytes } from "../../../common/utils/convertMemory";
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import type { PersistentVolume, StorageClass } from "../../../common/k8s-api/endpoints";
|
||||||
|
import persistentVolumeStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
export type GetPersistentVolumesByStorageClass = (obj: StorageClass) => PersistentVolume[];
|
||||||
|
|
||||||
|
const getPersistentVolumesByStorageClassInjectable = getInjectable({
|
||||||
|
id: "get-persistent-volumes-by-storage-class",
|
||||||
|
instantiate: (di): GetPersistentVolumesByStorageClass => {
|
||||||
|
const store = di.inject(persistentVolumeStoreInjectable);
|
||||||
|
|
||||||
|
return (obj) => store.getByStorageClass(obj);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default getPersistentVolumesByStorageClassInjectable;
|
||||||
12
src/renderer/components/+storage-volumes/legacy-store.ts
Normal file
12
src/renderer/components/+storage-volumes/legacy-store.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import persistentVolumeStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(persistentVolumeStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const persistentVolumeStore = asLegacyGlobalForExtensionApi(persistentVolumeStoreInjectable);
|
||||||
27
src/renderer/components/+storage-volumes/store.injectable.ts
Normal file
27
src/renderer/components/+storage-volumes/store.injectable.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import persistentVolumeApiInjectable from "../../../common/k8s-api/endpoints/persistent-volume.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { PersistentVolumeStore } from "./store";
|
||||||
|
|
||||||
|
const persistentVolumeStoreInjectable = getInjectable({
|
||||||
|
id: "persistent-volume-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "persistentVolumeStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(persistentVolumeApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new PersistentVolumeStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default persistentVolumeStoreInjectable;
|
||||||
@ -5,17 +5,13 @@
|
|||||||
|
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import type { PersistentVolume, PersistentVolumeApi } from "../../../common/k8s-api/endpoints/persistent-volume.api";
|
import type { PersistentVolume, PersistentVolumeApi } from "../../../common/k8s-api/endpoints/persistent-volume.api";
|
||||||
import { persistentVolumeApi } from "../../../common/k8s-api/endpoints/persistent-volume.api";
|
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import type { StorageClass } from "../../../common/k8s-api/endpoints/storage-class.api";
|
import type { StorageClass } from "../../../common/k8s-api/endpoints/storage-class.api";
|
||||||
|
|
||||||
export class PersistentVolumesStore extends KubeObjectStore<PersistentVolume, PersistentVolumeApi> {
|
export class PersistentVolumeStore extends KubeObjectStore<PersistentVolume, PersistentVolumeApi> {
|
||||||
getByStorageClass(storageClass: StorageClass): PersistentVolume[] {
|
getByStorageClass(storageClass: StorageClass): PersistentVolume[] {
|
||||||
return this.items.filter(volume =>
|
const storageClassName = storageClass.getName();
|
||||||
volume.getStorageClassName() === storageClass.getName(),
|
|
||||||
);
|
return this.items
|
||||||
|
.filter(volume => volume.getStorageClassName() === storageClassName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const volumesStore = new PersistentVolumesStore(persistentVolumeApi);
|
|
||||||
apiManager.registerStore(volumesStore);
|
|
||||||
@ -16,7 +16,7 @@ import { Spinner } from "../spinner/spinner";
|
|||||||
import { DrawerTitle } from "../drawer/drawer-title";
|
import { DrawerTitle } from "../drawer/drawer-title";
|
||||||
import { Table } from "../table/table";
|
import { Table } from "../table/table";
|
||||||
import { TableHead } from "../table/table-head";
|
import { TableHead } from "../table/table-head";
|
||||||
import { volumesStore } from "./volumes.store";
|
import { persistentVolumeStore } from "./legacy-store";
|
||||||
import kebabCase from "lodash/kebabCase";
|
import kebabCase from "lodash/kebabCase";
|
||||||
|
|
||||||
export interface VolumeDetailsListProps {
|
export interface VolumeDetailsListProps {
|
||||||
@ -64,7 +64,7 @@ export class VolumeDetailsList extends React.Component<VolumeDetailsListProps> {
|
|||||||
const virtual = persistentVolumes.length > 100;
|
const virtual = persistentVolumes.length > 100;
|
||||||
|
|
||||||
if (!persistentVolumes.length) {
|
if (!persistentVolumes.length) {
|
||||||
return !volumesStore.isLoaded && <Spinner center/>;
|
return !persistentVolumeStore.isLoaded && <Spinner center/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import { Link } from "react-router-dom";
|
|||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { getDetailsUrl } from "../kube-detail-params";
|
import { getDetailsUrl } from "../kube-detail-params";
|
||||||
import { stopPropagation } from "../../utils";
|
import { stopPropagation } from "../../utils";
|
||||||
import { volumesStore } from "./volumes.store";
|
import { persistentVolumeStore } from "./legacy-store";
|
||||||
import { persistentVolumeClaimApi, storageClassApi } from "../../../common/k8s-api/endpoints";
|
import { persistentVolumeClaimApi, storageClassApi } from "../../../common/k8s-api/endpoints";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
||||||
@ -35,7 +35,7 @@ export class PersistentVolumes extends React.Component {
|
|||||||
isConfigurable
|
isConfigurable
|
||||||
tableId="storage_volumes"
|
tableId="storage_volumes"
|
||||||
className="PersistentVolumes"
|
className="PersistentVolumes"
|
||||||
store={volumesStore}
|
store={persistentVolumeStore}
|
||||||
sortingCallbacks={{
|
sortingCallbacks={{
|
||||||
[columnId.name]: volume => volume.getName(),
|
[columnId.name]: volume => volume.getName(),
|
||||||
[columnId.storageClass]: volume => volume.getStorageClass(),
|
[columnId.storageClass]: volume => volume.getStorageClass(),
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import type { KubeObjectDetailsProps } from "../../kube-object-details";
|
|||||||
import { KubeObjectMeta } from "../../kube-object-meta";
|
import { KubeObjectMeta } from "../../kube-object-meta";
|
||||||
import { Table, TableCell, TableHead, TableRow } from "../../table";
|
import { Table, TableCell, TableHead, TableRow } from "../../table";
|
||||||
import { RoleBindingDialog } from "./dialog";
|
import { RoleBindingDialog } from "./dialog";
|
||||||
import { roleBindingStore } from "./store";
|
import { roleBindingStore } from "./legacy-store";
|
||||||
import { ObservableHashSet } from "../../../../common/utils/hash-set";
|
import { ObservableHashSet } from "../../../../common/utils/hash-set";
|
||||||
import { hashSubject } from "../hashers";
|
import { hashSubject } from "../hashers";
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import { SubTitle } from "../../layout/sub-title";
|
|||||||
import { Notifications } from "../../notifications";
|
import { Notifications } from "../../notifications";
|
||||||
import { Select } from "../../select";
|
import { Select } from "../../select";
|
||||||
import { Wizard, WizardStep } from "../../wizard";
|
import { Wizard, WizardStep } from "../../wizard";
|
||||||
import { roleBindingStore } from "./store";
|
import { roleBindingStore } from "./legacy-store";
|
||||||
import { clusterRoleStore } from "../+cluster-roles/legacy-store";
|
import { clusterRoleStore } from "../+cluster-roles/legacy-store";
|
||||||
import { Input } from "../../input";
|
import { Input } from "../../input";
|
||||||
import { ObservableHashSet, nFircate } from "../../../utils";
|
import { ObservableHashSet, nFircate } from "../../../utils";
|
||||||
|
|||||||
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import roleBindingStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(roleBindingStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const roleBindingStore = asLegacyGlobalForExtensionApi(roleBindingStoreInjectable);
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import apiManagerInjectable from "../../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
|
import roleBindingApiInjectable from "../../../../common/k8s-api/endpoints/role-binding.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../../create-stores-apis.injectable";
|
||||||
|
import { RoleBindingStore } from "./store";
|
||||||
|
|
||||||
|
const roleBindingStoreInjectable = getInjectable({
|
||||||
|
id: "role-binding-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "roleBindingStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(roleBindingApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new RoleBindingStore(api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default roleBindingStoreInjectable;
|
||||||
@ -3,12 +3,10 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { apiManager } from "../../../../common/k8s-api/api-manager";
|
|
||||||
import type { RoleBinding, RoleBindingApi, RoleBindingData } from "../../../../common/k8s-api/endpoints";
|
import type { RoleBinding, RoleBindingApi, RoleBindingData } from "../../../../common/k8s-api/endpoints";
|
||||||
import { roleBindingApi } from "../../../../common/k8s-api/endpoints";
|
|
||||||
import type { Subject } from "../../../../common/k8s-api/endpoints/types/subject";
|
import type { Subject } from "../../../../common/k8s-api/endpoints/types/subject";
|
||||||
import { KubeObjectStore } from "../../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../../common/k8s-api/kube-object.store";
|
||||||
import { HashSet, isClusterPageContext } from "../../../utils";
|
import { HashSet } from "../../../utils";
|
||||||
import { hashSubject } from "../hashers";
|
import { hashSubject } from "../hashers";
|
||||||
|
|
||||||
export class RoleBindingStore extends KubeObjectStore<RoleBinding, RoleBindingApi, RoleBindingData> {
|
export class RoleBindingStore extends KubeObjectStore<RoleBinding, RoleBindingApi, RoleBindingData> {
|
||||||
@ -36,11 +34,3 @@ export class RoleBindingStore extends KubeObjectStore<RoleBinding, RoleBindingAp
|
|||||||
return this.updateSubjects(roleBinding, currentSubjects.toJSON());
|
return this.updateSubjects(roleBinding, currentSubjects.toJSON());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const roleBindingStore = isClusterPageContext()
|
|
||||||
? new RoleBindingStore(roleBindingApi)
|
|
||||||
: undefined as never;
|
|
||||||
|
|
||||||
if (isClusterPageContext()) {
|
|
||||||
apiManager.registerStore(roleBindingStore);
|
|
||||||
}
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import React from "react";
|
|||||||
import { KubeObjectListLayout } from "../../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../../kube-object-list-layout";
|
||||||
import { KubeObjectStatusIcon } from "../../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../../kube-object-status-icon";
|
||||||
import { RoleBindingDialog } from "./dialog";
|
import { RoleBindingDialog } from "./dialog";
|
||||||
import { roleBindingStore } from "./store";
|
import { roleBindingStore } from "./legacy-store";
|
||||||
import { roleStore } from "../+roles/legacy-store";
|
import { roleStore } from "../+roles/legacy-store";
|
||||||
import { clusterRoleStore } from "../+cluster-roles/legacy-store";
|
import { clusterRoleStore } from "../+cluster-roles/legacy-store";
|
||||||
import { serviceAccountStore } from "../+service-accounts/legacy-store";
|
import { serviceAccountStore } from "../+service-accounts/legacy-store";
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import { disposeOnUnmount, observer } from "mobx-react";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
import { secretStore } from "../../+config-secrets/secrets.store";
|
import { secretStore } from "../../+config-secrets/legacy-store";
|
||||||
import type { Secret, ServiceAccount } from "../../../../common/k8s-api/endpoints";
|
import type { Secret, ServiceAccount } from "../../../../common/k8s-api/endpoints";
|
||||||
import { DrawerItem, DrawerTitle } from "../../drawer";
|
import { DrawerItem, DrawerTitle } from "../../drawer";
|
||||||
import { Icon } from "../../icon";
|
import { Icon } from "../../icon";
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import React from "react";
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { cronJobStore } from "./legacy-store";
|
import { cronJobStore } from "./legacy-store";
|
||||||
import { jobStore } from "../+workloads-jobs/legacy-store";
|
import { jobStore } from "../+workloads-jobs/legacy-store";
|
||||||
import { eventStore } from "../+events/event.store";
|
import { eventStore } from "../+events/legacy-store";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user