From e643b37c7fdfd4fc384d81cb7029df095492e0c2 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Fri, 22 Oct 2021 16:13:43 +0300 Subject: [PATCH] Cluster overview css fixes (#4104) --- integration/__tests__/cluster-pages.tests.ts | 2 +- ...-issues.scss => cluster-issues.module.css} | 73 +++++++++---------- .../components/+cluster/cluster-issues.tsx | 14 ++-- .../+cluster/cluster-metric-switchers.tsx | 6 +- ...etrics.scss => cluster-metrics.module.css} | 8 +- .../components/+cluster/cluster-metrics.tsx | 9 ++- ...rview.scss => cluster-overview.module.css} | 24 +++--- .../components/+cluster/cluster-overview.tsx | 4 +- ...ers.scss => cluster-pie-charts.module.css} | 15 ++-- .../+cluster/cluster-pie-charts.scss | 50 ------------- .../+cluster/cluster-pie-charts.tsx | 18 ++--- 11 files changed, 84 insertions(+), 139 deletions(-) rename src/renderer/components/+cluster/{cluster-issues.scss => cluster-issues.module.css} (66%) rename src/renderer/components/+cluster/{cluster-metrics.scss => cluster-metrics.module.css} (90%) rename src/renderer/components/+cluster/{cluster-overview.scss => cluster-overview.module.css} (80%) rename src/renderer/components/+cluster/{cluster-metric-switchers.scss => cluster-pie-charts.module.css} (80%) delete mode 100644 src/renderer/components/+cluster/cluster-pie-charts.scss diff --git a/integration/__tests__/cluster-pages.tests.ts b/integration/__tests__/cluster-pages.tests.ts index bd31a80102..f54565e1a8 100644 --- a/integration/__tests__/cluster-pages.tests.ts +++ b/integration/__tests__/cluster-pages.tests.ts @@ -74,7 +74,7 @@ const commonPageTests: CommonPageTest[] = [{ page: { name: "Cluster", href: "/overview", - expectedSelector: "div.ClusterOverview div.label", + expectedSelector: "div[data-testid='cluster-overview-page'] div.label", expectedText: "CPU" } }, diff --git a/src/renderer/components/+cluster/cluster-issues.scss b/src/renderer/components/+cluster/cluster-issues.module.css similarity index 66% rename from src/renderer/components/+cluster/cluster-issues.scss rename to src/renderer/components/+cluster/cluster-issues.module.css index aadb46ee39..fc421f1401 100644 --- a/src/renderer/components/+cluster/cluster-issues.scss +++ b/src/renderer/components/+cluster/cluster-issues.module.css @@ -19,61 +19,56 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -.ClusterIssues { + .ClusterIssues { min-height: 350px; position: relative; - grid-column-start: 1; - grid-column-end: 3; + grid-area: issues; + padding: calc(var(--margin) * 2) 0; + background: var(--contentColor); - @include media("<1024px") { - grid-column-start: 1!important; - grid-column-end: 1!important; + &:global(.OnlyClusterIssues) { + grid-row: row1-start / row2-end; + } + + @media (max-width: 1150px) { + grid-area: unset; + + &:global(.OnlyClusterIssues) { + grid-row: auto; + } } .SubHeader { - .Icon { + padding-top: 0; + padding-bottom: 0; + + :global(.Icon) { font-size: 130%; - color: $colorError; + color: var(--colorError); } } - .Table { - .TableHead { - background-color: transparent; - border-bottom: 1px solid $borderFaintColor; - - .TableCell { - padding-top: 0; - } - } - - .TableCell { - white-space: nowrap; - text-overflow: ellipsis; - - &.message { - flex-grow: 3; - } - - &.object { - flex-grow: 2; - } - } + .message { + white-space: nowrap; + text-overflow: ellipsis; + flex-grow: 3; } - .no-issues { - .Icon { - color: white; - } + .object { + white-space: nowrap; + text-overflow: ellipsis; + flex-grow: 2; + } + .noIssues { .ok-title { font-size: large; - color: $textColorAccent; + color: var(--textColorAccent); font-weight: bold; } + + .allGood { + color: white; + } } } - -.OnlyClusterIssues { - grid-row: row1-start / row2-end; -} diff --git a/src/renderer/components/+cluster/cluster-issues.tsx b/src/renderer/components/+cluster/cluster-issues.tsx index 3f9b5c6b90..6165fde8bd 100644 --- a/src/renderer/components/+cluster/cluster-issues.tsx +++ b/src/renderer/components/+cluster/cluster-issues.tsx @@ -19,7 +19,7 @@ * 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 { observer } from "mobx-react"; @@ -121,10 +121,10 @@ export class ClusterIssues extends React.Component { selected={selfLink === kubeSelectedUrlParam.get()} onClick={prevDefault(() => toggleDetails(selfLink))} > - + {message} - + {getName()} @@ -148,8 +148,8 @@ export class ClusterIssues extends React.Component { if (!warnings.length) { return ( -
-
+
+
No issues found
Everything is fine in the Cluster
@@ -158,7 +158,7 @@ export class ClusterIssues extends React.Component { return ( <> - + {" "} <>Warnings: {warnings.length} @@ -186,7 +186,7 @@ export class ClusterIssues extends React.Component { render() { return ( -
+
{this.renderContent()}
); diff --git a/src/renderer/components/+cluster/cluster-metric-switchers.tsx b/src/renderer/components/+cluster/cluster-metric-switchers.tsx index b80dd10527..aa2ff2985f 100644 --- a/src/renderer/components/+cluster/cluster-metric-switchers.tsx +++ b/src/renderer/components/+cluster/cluster-metric-switchers.tsx @@ -19,8 +19,6 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import "./cluster-metric-switchers.scss"; - import React from "react"; import { observer } from "mobx-react"; import { nodesStore } from "../+nodes/nodes.store"; @@ -36,7 +34,7 @@ export const ClusterMetricSwitchers = observer(() => { const disableMetrics = !metricsValues.length; return ( -
+
{
-
+
{ } if (!memoryCapacity || !cpuCapacity) { - return ; + return ; } return ( @@ -106,12 +106,13 @@ export const ClusterMetrics = observer(() => { timeLabelStep={5} showLegend={false} plugins={[ZebraStripes]} + className={styles.chart} /> ); }; return ( -
+
{renderMetrics()}
diff --git a/src/renderer/components/+cluster/cluster-overview.scss b/src/renderer/components/+cluster/cluster-overview.module.css similarity index 80% rename from src/renderer/components/+cluster/cluster-overview.scss rename to src/renderer/components/+cluster/cluster-overview.module.css index 8dba6d65e8..7700ec038b 100644 --- a/src/renderer/components/+cluster/cluster-overview.scss +++ b/src/renderer/components/+cluster/cluster-overview.module.css @@ -20,28 +20,22 @@ */ .ClusterOverview { - $gridGap: $margin * 2; - position: relative; height: 100%; min-height: 650px; display: grid; - grid-gap: $gridGap; - grid-template-columns: repeat(auto-fit, minmax(500px, 1fr)); + grid-gap: calc(var(--margin) * 2); + grid-template-areas: + "barcharts piechars" + "issues issues"; + grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-template-rows: [row1-start] 1fr [row2-start] 1fr; - @include media(">1600px") { - grid-template-columns: 1fr 1fr; - } - - > *:not(.Spinner) { - padding: $gridGap; - background: $contentColor; - - > .SubHeader { - padding-top: 0; - } + @media (max-width: 1150px) { + grid-template-columns: minmax(500px, 1fr); + grid-template-rows: 1fr; + grid-template-areas: none; } } diff --git a/src/renderer/components/+cluster/cluster-overview.tsx b/src/renderer/components/+cluster/cluster-overview.tsx index 248c7de427..b4fa25da45 100644 --- a/src/renderer/components/+cluster/cluster-overview.tsx +++ b/src/renderer/components/+cluster/cluster-overview.tsx @@ -19,7 +19,7 @@ * 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 { reaction } from "mobx"; @@ -101,7 +101,7 @@ export class ClusterOverview extends React.Component { return ( -
+
{this.renderClusterOverview(isLoaded, isMetricHidden)}
diff --git a/src/renderer/components/+cluster/cluster-metric-switchers.scss b/src/renderer/components/+cluster/cluster-pie-charts.module.css similarity index 80% rename from src/renderer/components/+cluster/cluster-metric-switchers.scss rename to src/renderer/components/+cluster/cluster-pie-charts.module.css index ef8dab156f..1998c11989 100644 --- a/src/renderer/components/+cluster/cluster-metric-switchers.scss +++ b/src/renderer/components/+cluster/cluster-pie-charts.module.css @@ -19,10 +19,15 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -.ClusterMetricSwitchers { - margin-bottom: $margin * 2; +.empty { + background: var(--contentColor); + min-height: 280px; + text-align: center; + padding: calc(var(--padding) * 2) 0; +} - .metric-switch { - text-align: right; - } +.chart { + --flex-gap: calc(var(--padding) * 2); + background: var(--contentColor); + padding: calc(var(--padding) * 2) var(--padding); } \ No newline at end of file diff --git a/src/renderer/components/+cluster/cluster-pie-charts.scss b/src/renderer/components/+cluster/cluster-pie-charts.scss deleted file mode 100644 index 4f2c392bb7..0000000000 --- a/src/renderer/components/+cluster/cluster-pie-charts.scss +++ /dev/null @@ -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}; - } - } -} \ No newline at end of file diff --git a/src/renderer/components/+cluster/cluster-pie-charts.tsx b/src/renderer/components/+cluster/cluster-pie-charts.tsx index 76bb6967f6..5079866870 100644 --- a/src/renderer/components/+cluster/cluster-pie-charts.tsx +++ b/src/renderer/components/+cluster/cluster-pie-charts.tsx @@ -19,7 +19,7 @@ * 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 { observer } from "mobx-react"; @@ -29,7 +29,7 @@ import { Icon } from "../icon"; import { nodesStore } from "../+nodes/nodes.store"; import { ChartData, PieChart } from "../chart"; import { ClusterNoMetrics } from "./cluster-no-metrics"; -import { bytesToUnits } from "../../utils"; +import { bytesToUnits, cssNames } from "../../utils"; import { ThemeStore } from "../../theme.store"; import { getMetricLastPoints } from "../../../common/k8s-api/endpoints/metrics.api"; @@ -173,8 +173,8 @@ export const ClusterPieCharts = observer(() => { }; return ( -
-
+
+
{ /> {cpuLimitsOverload && renderLimitWarning()}
-
+
{ /> {memoryLimitsOverload && renderLimitWarning()}
-
+
{ if (!nodes.length) { return ( -
+
No Nodes Available.
@@ -237,14 +237,14 @@ export const ClusterPieCharts = observer(() => { const { memoryCapacity, cpuCapacity, podCapacity } = getMetricLastPoints(clusterOverviewStore.metrics); if (!memoryCapacity || !cpuCapacity || !podCapacity) { - return ; + return ; } return renderCharts(); }; return ( -
+
{renderContent()}
);