'new_vulnerabilities'
];
+const issueParamsPerMetric: { [key: string]: { [key: string]: string } } = {
+ blocker_violations: { resolved: 'false', severities: 'BLOCKER' },
+ new_blocker_violations: { resolved: 'false', severities: 'BLOCKER' },
+ critical_violations: { resolved: 'false', severities: 'CRITICAL' },
+ new_critical_violations: { resolved: 'false', severities: 'CRITICAL' },
+ major_violations: { resolved: 'false', severities: 'MAJOR' },
+ new_major_violations: { resolved: 'false', severities: 'MAJOR' },
+ minor_violations: { resolved: 'false', severities: 'MINOR' },
+ new_minor_violations: { resolved: 'false', severities: 'MINOR' },
+ info_violations: { resolved: 'false', severities: 'INFO' },
+ new_info_violations: { resolved: 'false', severities: 'INFO' },
+ open_issues: { resolved: 'false', statuses: 'OPEN' },
+ reopened_issues: { resolved: 'false', statuses: 'REOPENED' },
+ confirmed_issues: { resolved: 'false', statuses: 'CONFIRMED' },
+ false_positive_issues: { resolutions: 'FALSE-POSITIVE' },
+ code_smells: { resolved: 'false', types: 'CODE_SMELL' },
+ new_code_smells: { resolved: 'false', types: 'CODE_SMELL' },
+ bugs: { resolved: 'false', types: 'BUG' },
+ new_bugs: { resolved: 'false', types: 'BUG' },
+ vulnerabilities: { resolved: 'false', types: 'VULNERABILITY' },
+ new_vulnerabilities: { resolved: 'false', types: 'VULNERABILITY' }
+};
+
interface Props {
branchLike?: T.BranchLike;
children?: React.ReactNode;
};
propsToIssueParams = () => {
- const params: { [key: string]: string | boolean } = {};
+ const params: { [key: string]: string | boolean } = {
+ ...(issueParamsPerMetric[this.props.metric] || { resolved: 'false' })
+ };
if (this.props.sinceLeakPeriod) {
params.sinceLeakPeriod = true;
}
- switch (this.props.metric) {
- case 'blocker_violations':
- case 'new_blocker_violations':
- Object.assign(params, { resolved: 'false', severities: 'BLOCKER' });
- break;
- case 'critical_violations':
- case 'new_critical_violations':
- Object.assign(params, { resolved: 'false', severities: 'CRITICAL' });
- break;
- case 'major_violations':
- case 'new_major_violations':
- Object.assign(params, { resolved: 'false', severities: 'MAJOR' });
- break;
- case 'minor_violations':
- case 'new_minor_violations':
- Object.assign(params, { resolved: 'false', severities: 'MINOR' });
- break;
- case 'info_violations':
- case 'new_info_violations':
- Object.assign(params, { resolved: 'false', severities: 'INFO' });
- break;
- case 'open_issues':
- Object.assign(params, { resolved: 'false', statuses: 'OPEN' });
- break;
- case 'reopened_issues':
- Object.assign(params, { resolved: 'false', statuses: 'REOPENED' });
- break;
- case 'confirmed_issues':
- Object.assign(params, { resolved: 'false', statuses: 'CONFIRMED' });
- break;
- case 'false_positive_issues':
- Object.assign(params, { resolutions: 'FALSE-POSITIVE' });
- break;
- case 'code_smells':
- case 'new_code_smells':
- Object.assign(params, { resolved: 'false', types: 'CODE_SMELL' });
- break;
- case 'bugs':
- case 'new_bugs':
- Object.assign(params, { resolved: 'false', types: 'BUG' });
- break;
- case 'vulnerabilities':
- case 'new_vulnerabilities':
- Object.assign(params, { resolved: 'false', types: 'VULNERABILITY' });
- break;
- default:
- Object.assign(params, { resolved: 'false' });
- }
return params;
};
const url = getComponentDrilldownUrl({
componentKey: this.props.component,
metric: this.props.metric,
- branchLike: this.props.branchLike
+ branchLike: this.props.branchLike,
+ listView: true
});
return (
<Link className={this.props.className} to={url}>
--- /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 DrilldownLink from '../DrilldownLink';
+
+it('should render correctly', () => {
+ const wrapper = shallowRender();
+ expect(wrapper).toMatchSnapshot();
+});
+it('should render issuesLink correctly', () => {
+ const wrapper = shallowRender({ metric: 'new_violations' });
+ expect(wrapper).toMatchSnapshot();
+});
+
+describe('propsToIssueParams', () => {
+ it('should render correct default parameters', () => {
+ const wrapper = shallowRender();
+ expect(wrapper.instance().propsToIssueParams()).toEqual({ resolved: 'false' });
+ });
+
+ it(`should render correct params`, () => {
+ const wrapper = shallowRender({ metric: 'false_positive_issues', sinceLeakPeriod: true });
+ expect(wrapper.instance().propsToIssueParams()).toEqual({
+ resolutions: 'FALSE-POSITIVE',
+ sinceLeakPeriod: true
+ });
+ });
+});
+
+const shallowRender = (props: Partial<DrilldownLink['props']> = {}, label = 'label') => {
+ return shallow<DrilldownLink>(
+ <DrilldownLink component="project123" metric="other" {...props}>
+ {label}
+ </DrilldownLink>
+ );
+};