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

Cluster overview css fixes (#4104)

This commit is contained in:
Alex Andreev 2021-10-22 16:13:43 +03:00 committed by GitHub
parent 8fa2adf870
commit e643b37c7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 84 additions and 139 deletions

View File

@ -74,7 +74,7 @@ const commonPageTests: CommonPageTest[] = [{
page: { page: {
name: "Cluster", name: "Cluster",
href: "/overview", href: "/overview",
expectedSelector: "div.ClusterOverview div.label", expectedSelector: "div[data-testid='cluster-overview-page'] div.label",
expectedText: "CPU" expectedText: "CPU"
} }
}, },

View File

@ -19,61 +19,56 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
.ClusterIssues { .ClusterIssues {
min-height: 350px; min-height: 350px;
position: relative; position: relative;
grid-column-start: 1; grid-area: issues;
grid-column-end: 3; padding: calc(var(--margin) * 2) 0;
background: var(--contentColor);
@include media("<1024px") { &:global(.OnlyClusterIssues) {
grid-column-start: 1!important; grid-row: row1-start / row2-end;
grid-column-end: 1!important; }
@media (max-width: 1150px) {
grid-area: unset;
&:global(.OnlyClusterIssues) {
grid-row: auto;
}
} }
.SubHeader { .SubHeader {
.Icon { padding-top: 0;
padding-bottom: 0;
:global(.Icon) {
font-size: 130%; font-size: 130%;
color: $colorError; color: var(--colorError);
} }
} }
.Table { .message {
.TableHead { white-space: nowrap;
background-color: transparent; text-overflow: ellipsis;
border-bottom: 1px solid $borderFaintColor; flex-grow: 3;
.TableCell {
padding-top: 0;
}
}
.TableCell {
white-space: nowrap;
text-overflow: ellipsis;
&.message {
flex-grow: 3;
}
&.object {
flex-grow: 2;
}
}
} }
.no-issues { .object {
.Icon { white-space: nowrap;
color: white; text-overflow: ellipsis;
} flex-grow: 2;
}
.noIssues {
.ok-title { .ok-title {
font-size: large; font-size: large;
color: $textColorAccent; color: var(--textColorAccent);
font-weight: bold; font-weight: bold;
} }
.allGood {
color: white;
}
} }
} }
.OnlyClusterIssues {
grid-row: row1-start / row2-end;
}

View File

@ -19,7 +19,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
import "./cluster-issues.scss"; import styles from "./cluster-issues.module.css";
import React from "react"; import React from "react";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
@ -121,10 +121,10 @@ export class ClusterIssues extends React.Component<Props> {
selected={selfLink === kubeSelectedUrlParam.get()} selected={selfLink === kubeSelectedUrlParam.get()}
onClick={prevDefault(() => toggleDetails(selfLink))} onClick={prevDefault(() => toggleDetails(selfLink))}
> >
<TableCell className="message"> <TableCell className={styles.message}>
{message} {message}
</TableCell> </TableCell>
<TableCell className="object"> <TableCell className={styles.object}>
{getName()} {getName()}
</TableCell> </TableCell>
<TableCell className="kind"> <TableCell className="kind">
@ -148,8 +148,8 @@ export class ClusterIssues extends React.Component<Props> {
if (!warnings.length) { if (!warnings.length) {
return ( return (
<div className="no-issues flex column box grow gaps align-center justify-center"> <div className={cssNames(styles.noIssues, "flex column box grow gaps align-center justify-center")}>
<div><Icon material="check" big sticker/></div> <div><Icon className={styles.allGood} material="check" big sticker/></div>
<div className="ok-title">No issues found</div> <div className="ok-title">No issues found</div>
<span>Everything is fine in the Cluster</span> <span>Everything is fine in the Cluster</span>
</div> </div>
@ -158,7 +158,7 @@ export class ClusterIssues extends React.Component<Props> {
return ( return (
<> <>
<SubHeader> <SubHeader className={styles.SubHeader}>
<Icon material="error_outline"/>{" "} <Icon material="error_outline"/>{" "}
<>Warnings: {warnings.length}</> <>Warnings: {warnings.length}</>
</SubHeader> </SubHeader>
@ -186,7 +186,7 @@ export class ClusterIssues extends React.Component<Props> {
render() { render() {
return ( return (
<div className={cssNames("ClusterIssues flex column", this.props.className)}> <div className={cssNames(styles.ClusterIssues, "flex column", this.props.className)}>
{this.renderContent()} {this.renderContent()}
</div> </div>
); );

View File

@ -19,8 +19,6 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
import "./cluster-metric-switchers.scss";
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 { nodesStore } from "../+nodes/nodes.store";
@ -36,7 +34,7 @@ export const ClusterMetricSwitchers = observer(() => {
const disableMetrics = !metricsValues.length; const disableMetrics = !metricsValues.length;
return ( return (
<div className="ClusterMetricSwitchers flex gaps"> <div className="flex gaps" style={{ marginBottom: "calc(var(--margin) * 2)" }}>
<div className="box grow"> <div className="box grow">
<RadioGroup <RadioGroup
asButtons asButtons
@ -48,7 +46,7 @@ export const ClusterMetricSwitchers = observer(() => {
<Radio label="Worker" value={MetricNodeRole.WORKER}/> <Radio label="Worker" value={MetricNodeRole.WORKER}/>
</RadioGroup> </RadioGroup>
</div> </div>
<div className="box grow metric-switch"> <div className="box grow" style={{ textAlign: "right" }}>
<RadioGroup <RadioGroup
asButtons asButtons
className={cssNames("RadioGroup flex gaps", { disabled: disableMetrics })} className={cssNames("RadioGroup flex gaps", { disabled: disableMetrics })}

View File

@ -19,12 +19,14 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
.ClusterMetrics { .ClusterMetrics {
position: relative; position: relative;
min-height: 280px; min-height: 280px;
padding: calc(var(--margin) * 2);
background: var(--contentColor);
.Chart { .chart {
.chart-container { :global(.chart-container) {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }

View File

@ -19,14 +19,14 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
import "./cluster-metrics.scss"; import styles from "./cluster-metrics.module.css";
import React from "react"; import React from "react";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import type { ChartOptions, ChartPoint } from "chart.js"; import type { ChartOptions, ChartPoint } from "chart.js";
import { clusterOverviewStore, MetricType } from "./cluster-overview.store"; import { clusterOverviewStore, MetricType } from "./cluster-overview.store";
import { BarChart } from "../chart"; import { BarChart } from "../chart";
import { bytesToUnits } from "../../utils"; import { bytesToUnits, cssNames } from "../../utils";
import { Spinner } from "../spinner"; import { Spinner } from "../spinner";
import { ZebraStripes } from "../chart/zebra-stripes.plugin"; import { ZebraStripes } from "../chart/zebra-stripes.plugin";
import { ClusterNoMetrics } from "./cluster-no-metrics"; import { ClusterNoMetrics } from "./cluster-no-metrics";
@ -95,7 +95,7 @@ export const ClusterMetrics = observer(() => {
} }
if (!memoryCapacity || !cpuCapacity) { if (!memoryCapacity || !cpuCapacity) {
return <ClusterNoMetrics className="empty"/>; return <ClusterNoMetrics className={styles.empty}/>;
} }
return ( return (
@ -106,12 +106,13 @@ export const ClusterMetrics = observer(() => {
timeLabelStep={5} timeLabelStep={5}
showLegend={false} showLegend={false}
plugins={[ZebraStripes]} plugins={[ZebraStripes]}
className={styles.chart}
/> />
); );
}; };
return ( return (
<div className="ClusterMetrics flex column"> <div className={cssNames(styles.ClusterMetrics, "flex column")}>
<ClusterMetricSwitchers/> <ClusterMetricSwitchers/>
{renderMetrics()} {renderMetrics()}
</div> </div>

View File

@ -20,28 +20,22 @@
*/ */
.ClusterOverview { .ClusterOverview {
$gridGap: $margin * 2;
position: relative; position: relative;
height: 100%; height: 100%;
min-height: 650px; min-height: 650px;
display: grid; display: grid;
grid-gap: $gridGap; grid-gap: calc(var(--margin) * 2);
grid-template-columns: repeat(auto-fit, minmax(500px, 1fr)); grid-template-areas:
"barcharts piechars"
"issues issues";
grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
grid-template-rows: grid-template-rows:
[row1-start] 1fr [row1-start] 1fr
[row2-start] 1fr; [row2-start] 1fr;
@include media(">1600px") { @media (max-width: 1150px) {
grid-template-columns: 1fr 1fr; grid-template-columns: minmax(500px, 1fr);
} grid-template-rows: 1fr;
grid-template-areas: none;
> *:not(.Spinner) {
padding: $gridGap;
background: $contentColor;
> .SubHeader {
padding-top: 0;
}
} }
} }

View File

@ -19,7 +19,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
import "./cluster-overview.scss"; import styles from "./cluster-overview.module.css";
import React from "react"; import React from "react";
import { reaction } from "mobx"; import { reaction } from "mobx";
@ -101,7 +101,7 @@ export class ClusterOverview extends React.Component {
return ( return (
<TabLayout> <TabLayout>
<div className="ClusterOverview"> <div className={styles.ClusterOverview} data-testid="cluster-overview-page">
{this.renderClusterOverview(isLoaded, isMetricHidden)} {this.renderClusterOverview(isLoaded, isMetricHidden)}
</div> </div>
</TabLayout> </TabLayout>

View File

@ -19,10 +19,15 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
.ClusterMetricSwitchers { .empty {
margin-bottom: $margin * 2; background: var(--contentColor);
min-height: 280px;
text-align: center;
padding: calc(var(--padding) * 2) 0;
}
.metric-switch { .chart {
text-align: right; --flex-gap: calc(var(--padding) * 2);
} background: var(--contentColor);
padding: calc(var(--padding) * 2) var(--padding);
} }

View File

@ -1,50 +0,0 @@
/**
* Copyright (c) 2021 OpenLens Authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
.ClusterPieCharts {
background: transparent!important;
padding: 0!important;
.empty {
background: $contentColor;
min-height: 280px;
text-align: center;
padding: $padding * 2;
}
.NodeCharts {
margin-bottom: 0;
}
.chart {
--flex-gap: #{$padding * 2};
background: $contentColor;
padding: $padding * 2 $padding;
.chart-title {
margin-bottom: 0;
}
.legend {
--flex-gap: #{$padding};
}
}
}

View File

@ -19,7 +19,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
import "./cluster-pie-charts.scss"; import styles from "./cluster-pie-charts.module.css";
import React from "react"; import React from "react";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
@ -29,7 +29,7 @@ import { Icon } from "../icon";
import { nodesStore } from "../+nodes/nodes.store"; import { nodesStore } from "../+nodes/nodes.store";
import { ChartData, PieChart } from "../chart"; import { ChartData, PieChart } from "../chart";
import { ClusterNoMetrics } from "./cluster-no-metrics"; import { ClusterNoMetrics } from "./cluster-no-metrics";
import { bytesToUnits } from "../../utils"; import { bytesToUnits, cssNames } from "../../utils";
import { ThemeStore } from "../../theme.store"; import { ThemeStore } from "../../theme.store";
import { getMetricLastPoints } from "../../../common/k8s-api/endpoints/metrics.api"; import { getMetricLastPoints } from "../../../common/k8s-api/endpoints/metrics.api";
@ -173,8 +173,8 @@ export const ClusterPieCharts = observer(() => {
}; };
return ( return (
<div className="NodeCharts flex justify-center box grow gaps"> <div className="flex justify-center box grow gaps">
<div className="chart flex column align-center box grow"> <div className={cssNames(styles.chart, "flex column align-center box grow")}>
<PieChart <PieChart
data={cpuData} data={cpuData}
title="CPU" title="CPU"
@ -188,7 +188,7 @@ export const ClusterPieCharts = observer(() => {
/> />
{cpuLimitsOverload && renderLimitWarning()} {cpuLimitsOverload && renderLimitWarning()}
</div> </div>
<div className="chart flex column align-center box grow"> <div className={cssNames(styles.chart, "flex column align-center box grow")}>
<PieChart <PieChart
data={memoryData} data={memoryData}
title="Memory" title="Memory"
@ -202,7 +202,7 @@ export const ClusterPieCharts = observer(() => {
/> />
{memoryLimitsOverload && renderLimitWarning()} {memoryLimitsOverload && renderLimitWarning()}
</div> </div>
<div className="chart flex column align-center box grow"> <div className={cssNames(styles.chart, "flex column align-center box grow")}>
<PieChart <PieChart
data={podsData} data={podsData}
title="Pods" title="Pods"
@ -220,7 +220,7 @@ export const ClusterPieCharts = observer(() => {
if (!nodes.length) { if (!nodes.length) {
return ( return (
<div className="empty flex column box grow align-center justify-center"> <div className={cssNames(styles.empty, "flex column box grow align-center justify-center")}>
<Icon material="info"/> <Icon material="info"/>
No Nodes Available. No Nodes Available.
</div> </div>
@ -237,14 +237,14 @@ export const ClusterPieCharts = observer(() => {
const { memoryCapacity, cpuCapacity, podCapacity } = getMetricLastPoints(clusterOverviewStore.metrics); const { memoryCapacity, cpuCapacity, podCapacity } = getMetricLastPoints(clusterOverviewStore.metrics);
if (!memoryCapacity || !cpuCapacity || !podCapacity) { if (!memoryCapacity || !cpuCapacity || !podCapacity) {
return <ClusterNoMetrics className="empty"/>; return <ClusterNoMetrics className={styles.empty}/>;
} }
return renderCharts(); return renderCharts();
}; };
return ( return (
<div className="ClusterPieCharts flex"> <div className="flex">
{renderContent()} {renderContent()}
</div> </div>
); );