diff --git a/web/ui/react-app/src/pages/targets/ScrapePoolContent.tsx b/web/ui/react-app/src/pages/targets/ScrapePoolContent.tsx index e1cbce6fc..36c996a3a 100644 --- a/web/ui/react-app/src/pages/targets/ScrapePoolContent.tsx +++ b/web/ui/react-app/src/pages/targets/ScrapePoolContent.tsx @@ -35,12 +35,7 @@ const ScrapePoolContentTable: FC> = ({ items }) {target.health.toUpperCase()} - + {formatRelative(target.lastScrape, now())} diff --git a/web/ui/react-app/src/pages/targets/TargetLabels.module.css b/web/ui/react-app/src/pages/targets/TargetLabels.module.css deleted file mode 100644 index 9c3768818..000000000 --- a/web/ui/react-app/src/pages/targets/TargetLabels.module.css +++ /dev/null @@ -1,3 +0,0 @@ -.discovered { - white-space: nowrap; -} diff --git a/web/ui/react-app/src/pages/targets/TargetLabels.test.tsx b/web/ui/react-app/src/pages/targets/TargetLabels.test.tsx index 3ebe34f64..b897a8cf7 100644 --- a/web/ui/react-app/src/pages/targets/TargetLabels.test.tsx +++ b/web/ui/react-app/src/pages/targets/TargetLabels.test.tsx @@ -17,15 +17,12 @@ describe('targetLabels', () => { job: 'node_exporter', foo: 'bar', }, - idx: 1, - scrapePool: 'cortex/node-exporter_group/0', }; const targetLabels = shallow(); it('renders a div of series labels', () => { const div = targetLabels.find('div').filterWhere((elem) => elem.hasClass('series-labels-container')); expect(div).toHaveLength(1); - expect(div.prop('id')).toEqual('series-labels-cortex/node-exporter_group/0-1'); }); it('wraps each label in a label badge', () => { @@ -38,15 +35,4 @@ describe('targetLabels', () => { }); expect(targetLabels.find(Badge)).toHaveLength(3); }); - - it('renders a tooltip for discovered labels', () => { - const tooltip = targetLabels.find(Tooltip); - expect(tooltip).toHaveLength(1); - expect(tooltip.prop('isOpen')).toBe(false); - expect(tooltip.prop('target')).toEqual('series-labels-cortex\\/node-exporter_group\\/0-1'); - }); - - it('renders discovered labels', () => { - expect(toJson(targetLabels)).toMatchSnapshot(); - }); }); diff --git a/web/ui/react-app/src/pages/targets/TargetLabels.tsx b/web/ui/react-app/src/pages/targets/TargetLabels.tsx index d85c58304..e75dd2b76 100644 --- a/web/ui/react-app/src/pages/targets/TargetLabels.tsx +++ b/web/ui/react-app/src/pages/targets/TargetLabels.tsx @@ -1,7 +1,7 @@ -import React, { FC, Fragment, useState } from 'react'; -import { Badge, Tooltip } from 'reactstrap'; -import 'css.escape'; -import styles from './TargetLabels.module.css'; +import { faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import React, { FC, useState } from 'react'; +import { Badge, Button } from 'reactstrap'; interface Labels { [key: string]: string; @@ -10,21 +10,14 @@ interface Labels { export interface TargetLabelsProps { discoveredLabels: Labels; labels: Labels; - idx: number; - scrapePool: string; } -const formatLabels = (labels: Labels): string[] => Object.keys(labels).map((key) => `${key}="${labels[key]}"`); - -const TargetLabels: FC = ({ discoveredLabels, labels, idx, scrapePool }) => { - const [tooltipOpen, setTooltipOpen] = useState(false); - - const toggle = (): void => setTooltipOpen(!tooltipOpen); - const id = `series-labels-${scrapePool}-${idx}`; +const TargetLabels: FC = ({ discoveredLabels, labels }) => { + const [showDiscovered, setShowDiscovered] = useState(false); return ( <> -
+
{Object.keys(labels).map((labelName) => { return ( @@ -32,22 +25,28 @@ const TargetLabels: FC = ({ discoveredLabels, labels, idx, sc ); })} +
- - Before relabeling: - {formatLabels(discoveredLabels).map((s: string, labelIndex: number) => ( - -
- {s} -
- ))} -
+ {showDiscovered && ( + <> +
Discovered labels:
+ {Object.keys(discoveredLabels).map((labelName) => ( +
+ + {`${labelName}="${discoveredLabels[labelName]}"`} + +
+ ))} + + )} ); }; diff --git a/web/ui/react-app/src/pages/targets/__snapshots__/TargetLabels.test.tsx.snap b/web/ui/react-app/src/pages/targets/__snapshots__/TargetLabels.test.tsx.snap deleted file mode 100644 index 3c5c856f0..000000000 --- a/web/ui/react-app/src/pages/targets/__snapshots__/TargetLabels.test.tsx.snap +++ /dev/null @@ -1,81 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`targetLabels renders discovered labels 1`] = ` - -
- - instance="localhost:9100" - - - job="node_exporter" - - - foo="bar" - -
- - - Before relabeling: - -
- - __address__="localhost:9100" - -
- - __metrics_path__="/metrics" - -
- - __scheme__="http" - -
- - job="node_exporter" - -
-
-`;