/** * Copyright (c) OpenLens Authors. All rights reserved. * Licensed under MIT License. See LICENSE in root directory for more information. */ import "./resource-metrics.scss"; import React, { createContext, useState } from "react"; import { Radio, RadioGroup } from "../radio"; import type { KubeObject } from "../../../common/k8s-api/kube-object"; import { cssNames } from "../../utils"; import { Spinner } from "../spinner"; import type { MetricsTab } from "../chart/options"; import type { MetricData } from "../../../common/k8s-api/endpoints/metrics.api"; import type { IAsyncComputed } from "@ogre-tools/injectable-react"; export type AtLeastOneMetricTab = [MetricsTab, ...MetricsTab[]]; export interface ResourceMetricsProps { tabs: AtLeastOneMetricTab; object: KubeObject; className?: string; metrics: IAsyncComputed> | null | undefined>; children: React.ReactChild | React.ReactChild[]; } export interface ResourceMetricsValue { object: KubeObject; tab: MetricsTab; metrics: Partial> | null | undefined; } export const ResourceMetricsContext = createContext(null); export function ResourceMetrics({ object, tabs, children, className, metrics }: ResourceMetricsProps) { const [tab, setTab] = useState(tabs[0]); return (
{tabs.map((tab, index) => ( ))}
{children}
); }