From 7d1495056a9f5a8ba61550923aa687f0057ca84e Mon Sep 17 00:00:00 2001 From: Yury Molodov Date: Tue, 18 Jul 2023 11:44:31 +0200 Subject: [PATCH] vmui: add tip to Explore Metrics page (#4615) * feat: add tip to Explore Metrics page (#4248) * fix: update description page --- .../ExploreMetricsHeader.tsx | 152 ++++++++++++------ .../ExploreMetricsHeader/style.scss | 20 +++ app/vmui/packages/vmui/src/router/index.ts | 2 +- app/vmui/packages/vmui/src/utils/storage.ts | 1 + 4 files changed, 122 insertions(+), 53 deletions(-) diff --git a/app/vmui/packages/vmui/src/components/ExploreMetrics/ExploreMetricsHeader/ExploreMetricsHeader.tsx b/app/vmui/packages/vmui/src/components/ExploreMetrics/ExploreMetricsHeader/ExploreMetricsHeader.tsx index 911178b46..9d2558104 100644 --- a/app/vmui/packages/vmui/src/components/ExploreMetrics/ExploreMetricsHeader/ExploreMetricsHeader.tsx +++ b/app/vmui/packages/vmui/src/components/ExploreMetrics/ExploreMetricsHeader/ExploreMetricsHeader.tsx @@ -1,9 +1,15 @@ -import React, { FC, useMemo } from "preact/compat"; +import React, { FC, useEffect, useMemo } from "preact/compat"; import Select from "../../Main/Select/Select"; import "./style.scss"; import { GRAPH_SIZES } from "../../../constants/graph"; import classNames from "classnames"; import useDeviceDetect from "../../../hooks/useDeviceDetect"; +import useBoolean from "../../../hooks/useBoolean"; +import { getFromStorage, saveToStorage } from "../../../utils/storage"; +import Alert from "../../Main/Alert/Alert"; +import Button from "../../Main/Button/Button"; +import { CloseIcon, TipIcon } from "../../Main/Icons"; +import Tooltip from "../../Main/Tooltip/Tooltip"; interface ExploreMetricsHeaderProps { jobs: string[] @@ -38,59 +44,101 @@ const ExploreMetricsHeader: FC = ({ const noMetricsText = useMemo(() => job ? "" : "No metric names. Please select job", [job]); const { isMobile } = useDeviceDetect(); + const { + value: showTips, + toggle: toggleShowTips, + setFalse: setHideTips, + } = useBoolean(getFromStorage("EXPLORE_METRICS_TIPS") !== "false"); + + useEffect(() => { + saveToStorage("EXPLORE_METRICS_TIPS", `${showTips}`); + }, [showTips]); + return ( -
-
- +
+
+ + +
+
+ -
-
- -
-
+ + {showTips && ( + +
+

+ Please note: this page is solely designed for exploring Prometheus metrics. + Prometheus metrics always contain job and instance labels + (see these docs), and this page relies on them as filters.
+ Please use this page for Prometheus metrics only, in accordance with their naming conventions. +

+
+
+ )} + ); }; diff --git a/app/vmui/packages/vmui/src/components/ExploreMetrics/ExploreMetricsHeader/style.scss b/app/vmui/packages/vmui/src/components/ExploreMetrics/ExploreMetricsHeader/style.scss index 8eb2d0db3..4b598ed47 100644 --- a/app/vmui/packages/vmui/src/components/ExploreMetrics/ExploreMetricsHeader/style.scss +++ b/app/vmui/packages/vmui/src/components/ExploreMetrics/ExploreMetricsHeader/style.scss @@ -26,6 +26,26 @@ &__size { flex-grow: 1; min-width: 150px; + display: grid; + grid-template-columns: 1fr auto; + align-items: center; + gap: $padding-global; + } + + &-description { + display: grid; + grid-template-columns: 1fr auto; + align-items: flex-start; + gap: $padding-small; + + button { + color: inherit; + min-height: 29px; + } + + code { + margin: 0 3px; + } } &-metrics { diff --git a/app/vmui/packages/vmui/src/router/index.ts b/app/vmui/packages/vmui/src/router/index.ts index 9bacbe696..4e6446123 100644 --- a/app/vmui/packages/vmui/src/router/index.ts +++ b/app/vmui/packages/vmui/src/router/index.ts @@ -42,7 +42,7 @@ export const routerOptions: {[key: string]: RouterOptions} = { ...routerOptionsDefault }, [router.metrics]: { - title: "Explore metrics", + title: "Explore Prometheus metrics", header: { tenant: true, stepControl: true, diff --git a/app/vmui/packages/vmui/src/utils/storage.ts b/app/vmui/packages/vmui/src/utils/storage.ts index 8a28d0298..05734dfd2 100644 --- a/app/vmui/packages/vmui/src/utils/storage.ts +++ b/app/vmui/packages/vmui/src/utils/storage.ts @@ -9,6 +9,7 @@ export type StorageKeys = "BASIC_AUTH_DATA" | "TIMEZONE" | "THEME" | "LOGS_LIMIT" + | "EXPLORE_METRICS_TIPS" export const saveToStorage = (key: StorageKeys, value: string | boolean | Record): void => { if (value) {