1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/+cluster/cluster-metric-switchers.tsx
Alex Andreev a61e20965d
ClusterOverview page refactorings (#1696)
* ClusterOverview page refactorings

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Minor test fix for MainLayoutHeader

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Replacing class name in tests

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Remove unnecessary parenthesis

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
2020-12-11 07:36:47 +02:00

44 lines
1.7 KiB
TypeScript

import "./cluster-metric-switchers.scss";
import React from "react";
import { Trans } from "@lingui/macro";
import { observer } from "mobx-react";
import { nodesStore } from "../+nodes/nodes.store";
import { cssNames } from "../../utils";
import { Radio, RadioGroup } from "../radio";
import { clusterOverviewStore, MetricNodeRole, MetricType } from "./cluster-overview.store";
export const ClusterMetricSwitchers = observer(() => {
const { metricType, metricNodeRole, getMetricsValues, metrics } = clusterOverviewStore;
const { masterNodes, workerNodes } = nodesStore;
const metricsValues = getMetricsValues(metrics);
const disableRoles = !masterNodes.length || !workerNodes.length;
const disableMetrics = !metricsValues.length;
return (
<div className="ClusterMetricSwitchers flex gaps">
<div className="box grow">
<RadioGroup
asButtons
className={cssNames("RadioGroup flex gaps", { disabled: disableRoles })}
value={metricNodeRole}
onChange={(metric: MetricNodeRole) => clusterOverviewStore.metricNodeRole = metric}
>
<Radio label={<Trans>Master</Trans>} value={MetricNodeRole.MASTER}/>
<Radio label={<Trans>Worker</Trans>} value={MetricNodeRole.WORKER}/>
</RadioGroup>
</div>
<div className="box grow metric-switch">
<RadioGroup
asButtons
className={cssNames("RadioGroup flex gaps", { disabled: disableMetrics })}
value={metricType}
onChange={(value: MetricType) => clusterOverviewStore.metricType = value}
>
<Radio label={<Trans>CPU</Trans>} value={MetricType.CPU}/>
<Radio label={<Trans>Memory</Trans>} value={MetricType.MEMORY}/>
</RadioGroup>
</div>
</div>
);
});