mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
cleanup Lens repo with tighter linting
Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
1 parent
e468105143
commit
b1ff34879a
470 files changed
+8447
-7443
No files matched your search
@@ -2,7 +2,7 @@ import React from "react";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { Icon } from "../icon";
|
||||
|
||||
export function NoMetrics() {
|
||||
export function NoMetrics(): JSX.Element {
|
||||
return (
|
||||
<div className="flex justify-center align-center">
|
||||
<Icon material="info"/> <Trans>Metrics not available at the moment</Trans>
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
import React from "react";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { IPodMetrics } from "../../api/endpoints";
|
||||
import { getMetricLastPoints, IMetrics } from "../../api/endpoints/metrics.api";
|
||||
import { PodMetricsData } from "../../api/endpoints";
|
||||
import { getMetricLastPoints, Metrics } from "../../api/endpoints/metrics.api";
|
||||
import { bytesToUnits } from "../../utils";
|
||||
import { Badge } from "../badge";
|
||||
import { DrawerItem } from "../drawer";
|
||||
|
||||
interface Props {
|
||||
metrics: IPodMetrics<IMetrics>;
|
||||
metrics: PodMetricsData<Metrics>;
|
||||
}
|
||||
|
||||
export function ResourceMetricsText(props: Props) {
|
||||
if (!props.metrics) return null
|
||||
export function ResourceMetricsText(props: Props): JSX.Element {
|
||||
if (!props.metrics) {
|
||||
return null;
|
||||
}
|
||||
const metrics = getMetricLastPoints(props.metrics);
|
||||
const { cpuUsage, cpuRequests, cpuLimits, memoryUsage, memoryRequests, memoryLimits } = metrics;
|
||||
return (
|
||||
|
||||
@@ -18,32 +18,34 @@ interface Props extends React.HTMLProps<any> {
|
||||
};
|
||||
}
|
||||
|
||||
export type IResourceMetricsValue<T extends KubeObject = any, P = any> = {
|
||||
export interface ResourceMetricsValue<T extends KubeObject = any, P = any> {
|
||||
object: T;
|
||||
tabId: number;
|
||||
params?: P;
|
||||
}
|
||||
|
||||
export const ResourceMetricsContext = createContext<IResourceMetricsValue>(null);
|
||||
export const ResourceMetricsContext = createContext<ResourceMetricsValue>(null);
|
||||
|
||||
const defaultProps: Partial<Props> = {
|
||||
interval: 60 // 1 min
|
||||
};
|
||||
|
||||
ResourceMetrics.defaultProps = defaultProps;
|
||||
|
||||
export function ResourceMetrics({ object, loader, interval, tabs, children, className, params }: Props) {
|
||||
export function ResourceMetrics({ object, loader, interval, tabs, children, className, params }: Props): JSX.Element {
|
||||
const [tabId, setTabId] = useState<number>(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (loader) loader();
|
||||
if (loader) {
|
||||
loader();
|
||||
}
|
||||
}, [object]);
|
||||
|
||||
useInterval(() => {
|
||||
if (loader) loader();
|
||||
if (loader) {
|
||||
loader();
|
||||
}
|
||||
}, interval * 1000);
|
||||
|
||||
const renderContents = () => {
|
||||
const renderContents = (): JSX.Element => {
|
||||
return (
|
||||
<>
|
||||
<div className="switchers">
|
||||
@@ -51,7 +53,7 @@ export function ResourceMetrics({ object, loader, interval, tabs, children, clas
|
||||
asButtons
|
||||
className="flex box grow gaps"
|
||||
value={tabs[tabId]}
|
||||
onChange={value => setTabId(tabs.findIndex(tab => tab == value))}
|
||||
onChange={(value): void => setTabId(tabs.findIndex(tab => tab == value))}
|
||||
>
|
||||
{tabs.map((tab, index) => (
|
||||
<Radio key={index} className="box grow" label={tab} value={tab}/>
|
||||
@@ -68,7 +70,7 @@ export function ResourceMetrics({ object, loader, interval, tabs, children, clas
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={cssNames("ResourceMetrics flex column", className)}>
|
||||
@@ -76,3 +78,5 @@ export function ResourceMetrics({ object, loader, interval, tabs, children, clas
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
ResourceMetrics.defaultProps = defaultProps;
|
||||
Reference in new issue
Block a user