"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": {
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"
"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"
return (
<div className="activity-graph-container flex-grow display-flex-column display-flex-stretch display-flex-justify-center">
{isCustom && this.props.removeCustomMetric ? (
- <GraphsLegendCustom
- removeMetric={this.props.removeCustomMetric}
- series={series}
- showLeakLegend={Boolean(leakPeriodDate)}
- />
+ <GraphsLegendCustom removeMetric={this.props.removeCustomMetric} series={series} />
) : (
- <GraphsLegendStatic series={series} showLeakLegend={Boolean(leakPeriodDate)} />
+ <GraphsLegendStatic series={series} />
)}
<div className="flex-1">
{({ height, width }) => (
<div>
<AdvancedTimeline
+ displayNewCodeLegend={true}
endDate={graphEndDate}
formatYTick={this.formatValue}
height={height}
import { translate } from 'sonar-ui-common/helpers/l10n';
import { Serie } from '../../types/project-activity';
import GraphsLegendItem from './GraphsLegendItem';
-import GraphsLegendNewCode from './GraphsLegendNewCode';
import { hasDataValues } from './utils';
export interface GraphsLegendCustomProps {
removeMetric: (metric: string) => void;
series: Serie[];
- showLeakLegend: boolean;
}
export default function GraphsLegendCustom(props: GraphsLegendCustomProps) {
- const { series, showLeakLegend } = props;
+ const { series } = props;
return (
<div className="activity-graph-legends display-flex-center">
<div className="flex-1">
);
})}
</div>
-
- {showLeakLegend && <GraphsLegendNewCode />}
</div>
);
}
import * as React from 'react';
import { Serie } from '../../types/project-activity';
import GraphsLegendItem from './GraphsLegendItem';
-import GraphsLegendNewCode from './GraphsLegendNewCode';
export interface GraphsLegendStaticProps {
series: Array<Pick<Serie, 'name' | 'translatedName'>>;
- showLeakLegend: boolean;
}
-export default function GraphsLegendStatic({ series, showLeakLegend }: GraphsLegendStaticProps) {
+export default function GraphsLegendStatic({ series }: GraphsLegendStaticProps) {
return (
<div className="activity-graph-legends">
{series.map((serie, idx) => (
name={serie.translatedName}
/>
))}
-
- {showLeakLegend && <GraphsLegendNewCode />}
</div>
);
}
}
];
-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(<GraphHistory {...DEFAULT_PROPS} />)).toMatchSnapshot();
+ expect(shallowRender()).toMatchSnapshot();
+ expect(shallowRender({ isCustom: true })).toMatchSnapshot('custom');
});
+
+function shallowRender(overrides: Partial<GraphHistory['props']> = {}) {
+ return shallow(
+ <GraphHistory
+ events={[]}
+ graph={DEFAULT_GRAPH}
+ leakPeriodDate={parseDate('2017-05-16T13:50:02+0200')}
+ isCustom={false}
+ measuresHistory={[]}
+ metricsType="INT"
+ removeCustomMetric={jest.fn()}
+ showAreas={true}
+ series={SERIES}
+ updateGraphZoom={jest.fn()}
+ updateSelectedDate={jest.fn()}
+ updateTooltip={jest.fn()}
+ {...overrides}
+ />
+ );
+}
it('should render correctly', () => {
expect(shallowRender()).toMatchSnapshot('default');
- expect(shallowRender({ showLeakLegend: true })).toMatchSnapshot('with leak legend');
});
function shallowRender(props: Partial<GraphsLegendCustomProps> = {}) {
type: 'INT'
}
]}
- showLeakLegend={false}
{...props}
/>
);
it('should render correctly', () => {
expect(shallowRender()).toMatchSnapshot('default');
- expect(shallowRender({ showLeakLegend: true })).toMatchSnapshot('with leak legend');
});
function shallowRender(props: Partial<GraphsLegendStaticProps> = {}) {
{ name: 'bugs', translatedName: 'Bugs' },
{ name: 'code_smells', translatedName: 'Code Smells' }
]}
- showLeakLegend={false}
{...props}
/>
);
},
]
}
- showLeakLegend={true}
+ />
+ <div
+ className="flex-1"
+ >
+ <AutoSizer>
+ <Component />
+ </AutoSizer>
+ </div>
+</div>
+`;
+
+exports[`should correctly render a graph: custom 1`] = `
+<div
+ className="activity-graph-container flex-grow display-flex-column display-flex-stretch display-flex-justify-center"
+>
+ <GraphsLegendCustom
+ removeMetric={[MockFunction]}
+ series={
+ Array [
+ Object {
+ "data": Array [
+ Object {
+ "x": 2016-10-27T14:33:50.000Z,
+ "y": 5,
+ },
+ Object {
+ "x": 2016-10-27T10:21:15.000Z,
+ "y": 16,
+ },
+ Object {
+ "x": 2016-10-26T10:17:29.000Z,
+ "y": 12,
+ },
+ ],
+ "name": "bugs",
+ "translatedName": "metric.bugs.name",
+ "type": "INT",
+ },
+ ]
+ }
/>
<div
className="flex-1"
</span>
</Tooltip>
</div>
- <GraphsLegendNewCode />
</div>
`;
metric="code_smells"
name="Code Smells"
/>
- <GraphsLegendNewCode />
</div>
`;
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"