diff --git a/ui/src/Components/Labels/LabelWithPercent/__snapshots__/index.test.js.snap b/ui/src/Components/Labels/LabelWithPercent/__snapshots__/index.test.js.snap index 78fa95ee5..68faeead3 100644 --- a/ui/src/Components/Labels/LabelWithPercent/__snapshots__/index.test.js.snap +++ b/ui/src/Components/Labels/LabelWithPercent/__snapshots__/index.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[` matches snapshot 1`] = ` +exports[` matches snapshot with offset=0 1`] = ` "
matches snapshot 1`] = `
" `; + +exports[` matches snapshot with offset=25 1`] = ` +" +
+ + + 25 + + + foo: + + + bar + + +
+
+
+
+
+
+
+" +`; diff --git a/ui/src/Components/Labels/LabelWithPercent/index.js b/ui/src/Components/Labels/LabelWithPercent/index.js index 6ff8c7eae..4965e77ca 100644 --- a/ui/src/Components/Labels/LabelWithPercent/index.js +++ b/ui/src/Components/Labels/LabelWithPercent/index.js @@ -17,11 +17,12 @@ const LabelWithPercent = inject("alertStore")( name: PropTypes.string.isRequired, value: PropTypes.string.isRequired, hits: PropTypes.number.isRequired, - percent: PropTypes.number.isRequired + percent: PropTypes.number.isRequired, + offset: PropTypes.number.isRequired }; render() { - const { name, value, hits, percent } = this.props; + const { name, value, hits, percent, offset } = this.props; let cs = this.getClassAndStyle( name, @@ -50,6 +51,16 @@ const LabelWithPercent = inject("alertStore")( {value}
+ {offset === 0 ? null : ( +
+ )}
{ alertStore = new AlertStore([]); }); -const MountedLabelWithPercent = (name, value) => { +const MountedLabelWithPercent = (name, value, hits, percent, offset) => { return mount( - ).find(".components-label"); + ); }; const RenderAndClick = (name, value, clickOptions) => { - const tree = MountedLabelWithPercent(name, value); + const tree = MountedLabelWithPercent(name, value, 25, 50, 0); tree.find(".components-label").simulate("click", clickOptions || {}); }; -describe("", () => { - it("matches snapshot", () => { - const tree = mount( - - ); +describe("", () => { + it("matches snapshot with offset=0", () => { + const tree = MountedLabelWithPercent("foo", "bar", 25, 50, 0); + expect(toDiffableHtml(tree.html())).toMatchSnapshot(); + }); + + it("matches snapshot with offset=25", () => { + const tree = MountedLabelWithPercent("foo", "bar", 25, 50, 25); expect(toDiffableHtml(tree.html())).toMatchSnapshot(); }); @@ -62,41 +60,17 @@ describe("", () => { }); it("uses bg-danger when percent is >66", () => { - const tree = mount( - - ); + const tree = MountedLabelWithPercent("foo", "bar", 25, 67, 0); expect(tree.html()).toMatch(/progress-bar bg-danger/); }); it("uses bg-warning when percent is >33", () => { - const tree = mount( - - ); + const tree = MountedLabelWithPercent("foo", "bar", 25, 66, 0); expect(tree.html()).toMatch(/progress-bar bg-warning/); }); it("uses bg-success when percent is <=33", () => { - const tree = mount( - - ); + const tree = MountedLabelWithPercent("foo", "bar", 25, 33, 0); expect(tree.html()).toMatch(/progress-bar bg-success/); }); }); diff --git a/ui/src/Components/OverviewModal/OverviewModalContent.js b/ui/src/Components/OverviewModal/OverviewModalContent.js index e41e83a1b..cc18854db 100644 --- a/ui/src/Components/OverviewModal/OverviewModalContent.js +++ b/ui/src/Components/OverviewModal/OverviewModalContent.js @@ -23,13 +23,17 @@ const LabelsTable = observer(({ alertStore }) => ( - {nameStats.values.slice(0, 9).map(valueStats => ( + {nameStats.values.slice(0, 9).map((valueStats, i, array) => ( ns.percent) + .reduce((a, b) => a + b, 0)} /> ))} diff --git a/ui/src/Components/OverviewModal/__snapshots__/OverviewModalContent.test.js.snap b/ui/src/Components/OverviewModal/__snapshots__/OverviewModalContent.test.js.snap index c5af0ee00..53950a672 100644 --- a/ui/src/Components/OverviewModal/__snapshots__/OverviewModalContent.test.js.snap +++ b/ui/src/Components/OverviewModal/__snapshots__/OverviewModalContent.test.js.snap @@ -80,6 +80,14 @@ exports[` matches snapshot with labels to show 1`] = `
+
+
matches snapshot with labels to show 1`] = `
+
+