aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Davis <jeremy.davis@sonarsource.com>2019-06-13 15:44:58 +0200
committerSonarTech <sonartech@sonarsource.com>2019-06-14 20:21:12 +0200
commit9c8d2d7b1f6a4d94626fde76edfeaaa231724af2 (patch)
tree717144ad7d6e21f09a67912ac5d1a7ba28d8614d
parentaf99676ca6fd08f4bc03faa0b78f4c900c2d93dc (diff)
downloadsonarqube-9c8d2d7b1f6a4d94626fde76edfeaaa231724af2.tar.gz
sonarqube-9c8d2d7b1f6a4d94626fde76edfeaaa231724af2.zip
SONAR-12195 Activity page: Filter security_review_rating to appear only for portfolio
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx16
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAppContainer-test.tsx38
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityAppContainer-test.tsx.snap74
3 files changed, 123 insertions, 5 deletions
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx
index fcffaf0c373..78e118c7950 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx
@@ -236,6 +236,12 @@ export default class ProjectActivityAppContainer extends React.PureComponent<Pro
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);
@@ -244,15 +250,15 @@ export default class ProjectActivityAppContainer extends React.PureComponent<Pro
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);
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAppContainer-test.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAppContainer-test.tsx
new file mode 100644
index 00000000000..7309e391713
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAppContainer-test.tsx
@@ -0,0 +1,38 @@
+/*
+ * 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}
+ />
+ );
+}
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityAppContainer-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityAppContainer-test.tsx.snap
new file mode 100644
index 00000000000..59c46d170ac
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityAppContainer-test.tsx.snap
@@ -0,0 +1,74 @@
+// 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]}
+/>
+`;