return component.breadcrumbs[current].key;
};
+ filterMetrics({ qualifier }: T.Component, metrics: T.Metric[]) {
+ return ['VW', 'SVW'].includes(qualifier)
+ ? metrics
+ : metrics.filter(metric => metric.key !== 'security_review_rating');
+ }
+
firstLoadData(query: Query, component: T.Component) {
const graphMetrics = getHistoryMetrics(query.graph, query.customMetrics);
const topLevelComponent = this.getTopLevelComponent(component);
getAllMetrics(),
this.fetchMeasuresHistory(graphMetrics)
]).then(
- response => {
+ ([{ analyses, paging }, metrics, measuresHistory]) => {
if (this.mounted) {
this.setState({
- analyses: response[0].analyses,
+ analyses,
graphLoading: false,
initialized: true,
- measuresHistory: response[2],
- metrics: response[1],
- paging: response[0].paging
+ measuresHistory,
+ metrics: this.filterMetrics(component, metrics),
+ paging
});
this.fetchAllActivities(topLevelComponent);
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import * as React from 'react';
+import { shallow } from 'enzyme';
+import ProjectActivityAppContainer from '../ProjectActivityAppContainer';
+import { mockComponent, mockLocation, mockRouter } from '../../../../helpers/testMocks';
+
+it('should render correctly', () => {
+ expect(shallowRender()).toMatchSnapshot();
+});
+
+function shallowRender(props: Partial<ProjectActivityAppContainer['props']> = {}) {
+ return shallow<ProjectActivityAppContainer>(
+ <ProjectActivityAppContainer
+ component={mockComponent({ breadcrumbs: [mockComponent()] })}
+ location={mockLocation()}
+ router={mockRouter()}
+ {...props}
+ />
+ );
+}
--- /dev/null
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render correctly 1`] = `
+<ProjectActivityApp
+ addCustomEvent={[Function]}
+ addVersion={[Function]}
+ analyses={Array []}
+ analysesLoading={false}
+ changeEvent={[Function]}
+ deleteAnalysis={[Function]}
+ deleteEvent={[Function]}
+ graphLoading={true}
+ initializing={true}
+ measuresHistory={Array []}
+ metrics={Array []}
+ project={
+ Object {
+ "breadcrumbs": Array [
+ Object {
+ "breadcrumbs": Array [],
+ "key": "my-project",
+ "name": "MyProject",
+ "organization": "foo",
+ "qualifier": "TRK",
+ "qualityGate": Object {
+ "isDefault": true,
+ "key": "30",
+ "name": "Sonar way",
+ },
+ "qualityProfiles": Array [
+ Object {
+ "deleted": false,
+ "key": "my-qp",
+ "language": "ts",
+ "name": "Sonar way",
+ },
+ ],
+ "tags": Array [],
+ },
+ ],
+ "key": "my-project",
+ "name": "MyProject",
+ "organization": "foo",
+ "qualifier": "TRK",
+ "qualityGate": Object {
+ "isDefault": true,
+ "key": "30",
+ "name": "Sonar way",
+ },
+ "qualityProfiles": Array [
+ Object {
+ "deleted": false,
+ "key": "my-qp",
+ "language": "ts",
+ "name": "Sonar way",
+ },
+ ],
+ "tags": Array [],
+ }
+ }
+ query={
+ Object {
+ "category": "",
+ "customMetrics": Array [],
+ "from": undefined,
+ "graph": "issues",
+ "project": "",
+ "selectedDate": undefined,
+ "to": undefined,
+ }
+ }
+ updateQuery={[Function]}
+/>
+`;