From: Jeremy Davis Date: Wed, 16 Sep 2020 13:39:06 +0000 (+0200) Subject: SONAR-13758 Add new code legend to Activity Chart X-Git-Tag: 8.5.0.37579~66 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6eb910a5be078ed233167472827966de9170cb0b;p=sonarqube.git SONAR-13758 Add new code legend to Activity Chart --- diff --git a/server/sonar-docs/package.json b/server/sonar-docs/package.json index c0518493b8d..d504b6cfcd9 100644 --- a/server/sonar-docs/package.json +++ b/server/sonar-docs/package.json @@ -21,7 +21,7 @@ "react-dom": "16.13.0", "react-helmet": "5.2.1", "react-typography": "0.16.19", - "sonar-ui-common": "1.0.20", + "sonar-ui-common": "1.0.22", "typography": "0.16.19" }, "devDependencies": { diff --git a/server/sonar-docs/yarn.lock b/server/sonar-docs/yarn.lock index cc4ff77faaa..7b2495777d6 100644 --- a/server/sonar-docs/yarn.lock +++ b/server/sonar-docs/yarn.lock @@ -12736,10 +12736,10 @@ sockjs@0.3.19: faye-websocket "^0.10.0" uuid "^3.0.1" -sonar-ui-common@1.0.20: - version "1.0.20" - resolved "https://repox.jfrog.io/repox/api/npm/npm/sonar-ui-common/-/sonar-ui-common-1.0.20.tgz#a52edc4f847b93dd7d0d0c686277f20ba3aaa234" - integrity sha1-pS7cT4R7k919DQxoYnfyC6OqojQ= +sonar-ui-common@1.0.22: + version "1.0.22" + resolved "https://repox.jfrog.io/repox/api/npm/npm/sonar-ui-common/-/sonar-ui-common-1.0.22.tgz#938d5293eae683a7149bb0a05ac2e81f0e34f171" + integrity sha1-k41Sk+rmg6cUm7CgWsLoHw408XE= dependencies: "@types/react-select" "1.2.6" classnames "2.2.6" diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index e04e7ea9a9e..d6c3076be72 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -38,7 +38,7 @@ "rehype-slug": "3.0.0", "remark-custom-blocks": "2.5.0", "remark-rehype": "6.0.0", - "sonar-ui-common": "1.0.20", + "sonar-ui-common": "1.0.22", "unist-util-visit": "2.0.2", "valid-url": "1.0.9", "whatwg-fetch": "3.0.0" diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphHistory.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphHistory.tsx index 366cc3aac76..960d2cdc449 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphHistory.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphHistory.tsx @@ -85,13 +85,9 @@ export default class GraphHistory extends React.PureComponent { return (
{isCustom && this.props.removeCustomMetric ? ( - + ) : ( - + )}
@@ -99,6 +95,7 @@ export default class GraphHistory extends React.PureComponent { {({ height, width }) => (
void; series: Serie[]; - showLeakLegend: boolean; } export default function GraphsLegendCustom(props: GraphsLegendCustomProps) { - const { series, showLeakLegend } = props; + const { series } = props; return (
@@ -63,8 +61,6 @@ export default function GraphsLegendCustom(props: GraphsLegendCustomProps) { ); })}
- - {showLeakLegend && }
); } diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendStatic.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendStatic.tsx index 54349d2a99d..5de340e510b 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendStatic.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendStatic.tsx @@ -20,14 +20,12 @@ import * as React from 'react'; import { Serie } from '../../types/project-activity'; import GraphsLegendItem from './GraphsLegendItem'; -import GraphsLegendNewCode from './GraphsLegendNewCode'; export interface GraphsLegendStaticProps { series: Array>; - showLeakLegend: boolean; } -export default function GraphsLegendStatic({ series, showLeakLegend }: GraphsLegendStaticProps) { +export default function GraphsLegendStatic({ series }: GraphsLegendStaticProps) { return (
{series.map((serie, idx) => ( @@ -39,8 +37,6 @@ export default function GraphsLegendStatic({ series, showLeakLegend }: GraphsLeg name={serie.translatedName} /> ))} - - {showLeakLegend && }
); } diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphHistory-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphHistory-test.tsx index 5d2849dbd15..f9c6d9c6ac5 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphHistory-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphHistory-test.tsx @@ -36,21 +36,27 @@ const SERIES = [ } ]; -const DEFAULT_PROPS: GraphHistory['props'] = { - events: [], - graph: DEFAULT_GRAPH, - leakPeriodDate: parseDate('2017-05-16T13:50:02+0200'), - isCustom: false, - measuresHistory: [], - metricsType: 'INT', - removeCustomMetric: () => {}, - showAreas: true, - series: SERIES, - updateGraphZoom: () => {}, - updateSelectedDate: () => {}, - updateTooltip: () => {} -}; - it('should correctly render a graph', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallowRender()).toMatchSnapshot(); + expect(shallowRender({ isCustom: true })).toMatchSnapshot('custom'); }); + +function shallowRender(overrides: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendCustom-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendCustom-test.tsx index 9d437a7a0f1..c925e3cd06f 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendCustom-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendCustom-test.tsx @@ -24,7 +24,6 @@ import GraphsLegendCustom, { GraphsLegendCustomProps } from '../GraphsLegendCust it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ showLeakLegend: true })).toMatchSnapshot('with leak legend'); }); function shallowRender(props: Partial = {}) { @@ -51,7 +50,6 @@ function shallowRender(props: Partial = {}) { type: 'INT' } ]} - showLeakLegend={false} {...props} /> ); diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendStatic-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendStatic-test.tsx index 4fa8d55ed7a..d7307a5b8dd 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendStatic-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendStatic-test.tsx @@ -23,7 +23,6 @@ import GraphsLegendStatic, { GraphsLegendStaticProps } from '../GraphsLegendStat it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ showLeakLegend: true })).toMatchSnapshot('with leak legend'); }); function shallowRender(props: Partial = {}) { @@ -33,7 +32,6 @@ function shallowRender(props: Partial = {}) { { name: 'bugs', translatedName: 'Bugs' }, { name: 'code_smells', translatedName: 'Code Smells' } ]} - showLeakLegend={false} {...props} /> ); diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/__snapshots__/GraphHistory-test.tsx.snap b/server/sonar-web/src/main/js/components/activity-graph/__tests__/__snapshots__/GraphHistory-test.tsx.snap index d3f064bbe89..bcab20a45b0 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/__snapshots__/GraphHistory-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/__snapshots__/GraphHistory-test.tsx.snap @@ -28,7 +28,46 @@ exports[`should correctly render a graph 1`] = ` }, ] } - showLeakLegend={true} + /> +
+ + + +
+
+`; + +exports[`should correctly render a graph: custom 1`] = ` +
+
-
`; diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/__snapshots__/GraphsLegendStatic-test.tsx.snap b/server/sonar-web/src/main/js/components/activity-graph/__tests__/__snapshots__/GraphsLegendStatic-test.tsx.snap index cb0be89ef40..7560341297e 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/__snapshots__/GraphsLegendStatic-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/__snapshots__/GraphsLegendStatic-test.tsx.snap @@ -39,6 +39,5 @@ exports[`should render correctly: with leak legend 1`] = ` metric="code_smells" name="Code Smells" /> -
`; diff --git a/server/sonar-web/yarn.lock b/server/sonar-web/yarn.lock index ab8fe123f4a..a86f53247a6 100644 --- a/server/sonar-web/yarn.lock +++ b/server/sonar-web/yarn.lock @@ -10765,10 +10765,10 @@ sockjs@0.3.19: faye-websocket "^0.10.0" uuid "^3.0.1" -sonar-ui-common@1.0.20: - version "1.0.20" - resolved "https://repox.jfrog.io/repox/api/npm/npm/sonar-ui-common/-/sonar-ui-common-1.0.20.tgz#a52edc4f847b93dd7d0d0c686277f20ba3aaa234" - integrity sha1-pS7cT4R7k919DQxoYnfyC6OqojQ= +sonar-ui-common@1.0.22: + version "1.0.22" + resolved "https://repox.jfrog.io/repox/api/npm/npm/sonar-ui-common/-/sonar-ui-common-1.0.22.tgz#938d5293eae683a7149bb0a05ac2e81f0e34f171" + integrity sha1-k41Sk+rmg6cUm7CgWsLoHw408XE= dependencies: "@types/react-select" "1.2.6" classnames "2.2.6"