aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/securityReports
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2018-12-05 17:32:18 +0100
committerSonarTech <sonartech@sonarsource.com>2018-12-05 20:20:59 +0100
commit41c98779d38bda9fdfdca182a5f20c73fcff9a84 (patch)
treed895a9f8bfd0276aee5ffacf7bb33a0109436cbd /server/sonar-web/src/main/js/apps/securityReports
parenta9c22c1185c5fd8c8dc4c9388f4a3b967e3f463d (diff)
downloadsonarqube-41c98779d38bda9fdfdca182a5f20c73fcff9a84.tar.gz
sonarqube-41c98779d38bda9fdfdca182a5f20c73fcff9a84.zip
create global type definitions (#1017)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/securityReports')
-rwxr-xr-xserver/sonar-web/src/main/js/apps/securityReports/components/App.tsx7
-rwxr-xr-xserver/sonar-web/src/main/js/apps/securityReports/components/VulnerabilityList.tsx27
-rw-r--r--server/sonar-web/src/main/js/apps/securityReports/components/__tests__/App-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/securityReports/components/__tests__/VulnerabilityList-test.tsx3
4 files changed, 18 insertions, 22 deletions
diff --git a/server/sonar-web/src/main/js/apps/securityReports/components/App.tsx b/server/sonar-web/src/main/js/apps/securityReports/components/App.tsx
index ed50bf28c72..8ab102b5744 100755
--- a/server/sonar-web/src/main/js/apps/securityReports/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/securityReports/components/App.tsx
@@ -24,7 +24,6 @@ import { Link } from 'react-router';
import VulnerabilityList from './VulnerabilityList';
import Suggestions from '../../../app/components/embed-docs-modal/Suggestions';
import { translate } from '../../../helpers/l10n';
-import { Component, BranchLike, SecurityHotspot } from '../../../app/types';
import DeferredSpinner from '../../../components/common/DeferredSpinner';
import Checkbox from '../../../components/controls/Checkbox';
import { RawQuery } from '../../../helpers/query';
@@ -37,15 +36,15 @@ import { Alert } from '../../../components/ui/Alert';
import '../style.css';
interface Props {
- branchLike?: BranchLike;
- component: Component;
+ branchLike?: T.BranchLike;
+ component: T.Component;
location: { pathname: string; query: RawQuery };
params: { type: string };
}
interface State {
loading: boolean;
- findings: Array<SecurityHotspot>;
+ findings: T.SecurityHotspot[];
hasVulnerabilities: boolean;
type: StandardType;
showCWE: boolean;
diff --git a/server/sonar-web/src/main/js/apps/securityReports/components/VulnerabilityList.tsx b/server/sonar-web/src/main/js/apps/securityReports/components/VulnerabilityList.tsx
index 28cbd625f14..8629b9d2639 100755
--- a/server/sonar-web/src/main/js/apps/securityReports/components/VulnerabilityList.tsx
+++ b/server/sonar-web/src/main/js/apps/securityReports/components/VulnerabilityList.tsx
@@ -21,7 +21,6 @@ import * as React from 'react';
import * as classNames from 'classnames';
import { Link } from 'react-router';
import { translate } from '../../../helpers/l10n';
-import { SecurityHotspot, Component, BranchLike, IssueType } from '../../../app/types';
import Rating from '../../../components/ui/Rating';
import { getComponentIssuesUrl, getRulesUrl } from '../../../helpers/urls';
import { getBranchLikeQuery } from '../../../helpers/branches';
@@ -43,9 +42,9 @@ import { isSonarCloud } from '../../../helpers/system';
import * as theme from '../../../app/theme';
interface Props {
- branchLike?: BranchLike;
- component: Component;
- findings: SecurityHotspot[];
+ branchLike?: T.BranchLike;
+ component: T.Component;
+ findings: T.SecurityHotspot[];
showCWE: boolean;
type: StandardType;
}
@@ -86,7 +85,7 @@ export default class VulnerabilityList extends React.PureComponent<Props, State>
);
};
- getName(finding: SecurityHotspot, type: StandardType) {
+ getName(finding: T.SecurityHotspot, type: StandardType) {
const category = finding.category || finding.cwe || 'unknown';
const renderers = {
owaspTop10: renderOwaspTop10Category,
@@ -138,7 +137,7 @@ export default class VulnerabilityList extends React.PureComponent<Props, State>
<Link
className="spacer-left link-no-underline"
to={getRulesUrl(
- { languages, tags, types: [IssueType.Hotspot, IssueType.Vulnerability].join() },
+ { languages, tags, types: ['SECURITY_HOTSPOT', 'VULNERABILITY'].join() },
isSonarCloud() ? this.props.component.organization : undefined
)}>
{translate('security_reports.activate_rules.link')}
@@ -190,14 +189,14 @@ export default class VulnerabilityList extends React.PureComponent<Props, State>
};
renderFinding(
- finding: SecurityHotspot,
+ finding: T.SecurityHotspot,
isCWE?: boolean,
- parent?: SecurityHotspot
+ parent?: T.SecurityHotspot
): React.ReactFragment {
const { branchLike, component, type } = this.props;
const params: { [name: string]: string | undefined } = {
...getBranchLikeQuery(branchLike),
- types: IssueType.Hotspot
+ types: 'SECURITY_HOTSPOT'
};
if (isCWE && parent) {
params['cwe'] = finding.cwe;
@@ -224,7 +223,7 @@ export default class VulnerabilityList extends React.PureComponent<Props, State>
finding.activeRules,
{
...params,
- types: IssueType.Vulnerability,
+ types: 'VULNERABILITY',
resolved: 'false'
},
finding.vulnerabilities,
@@ -233,7 +232,7 @@ export default class VulnerabilityList extends React.PureComponent<Props, State>
className="link-no-underline spacer-left"
to={getComponentIssuesUrl(component.key, {
...params,
- types: IssueType.Vulnerability,
+ types: 'VULNERABILITY',
resolved: 'false'
})}>
<Rating value={finding.vulnerabilityRating || 1} />
@@ -247,7 +246,7 @@ export default class VulnerabilityList extends React.PureComponent<Props, State>
finding.activeRules,
{
...params,
- types: IssueType.Hotspot,
+ types: 'SECURITY_HOTSPOT',
resolved: 'false',
statuses: 'OPEN,REOPENED'
},
@@ -259,7 +258,7 @@ export default class VulnerabilityList extends React.PureComponent<Props, State>
finding.activeRules,
{
...params,
- types: IssueType.Hotspot,
+ types: 'SECURITY_HOTSPOT',
resolutions: 'FIXED',
statuses: 'RESOLVED'
},
@@ -271,7 +270,7 @@ export default class VulnerabilityList extends React.PureComponent<Props, State>
finding.activeRules,
{
...params,
- types: IssueType.Hotspot,
+ types: 'SECURITY_HOTSPOT',
resolutions: 'WONTFIX',
statuses: 'RESOLVED'
},
diff --git a/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/App-test.tsx
index 61c8f980517..b934385a71b 100644
--- a/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/App-test.tsx
+++ b/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/App-test.tsx
@@ -78,14 +78,13 @@ jest.mock('../../../../api/security-reports', () => ({
import * as React from 'react';
import { shallow } from 'enzyme';
-import { Component } from '../../../../app/types';
import App from '../App';
import { waitAndUpdate } from '../../../../helpers/testUtils';
const getSecurityHotspots = require('../../../../api/security-reports')
.getSecurityHotspots as jest.Mock<any>;
-const component = { key: 'foo', name: 'Foo', qualifier: 'TRK' } as Component;
+const component = { key: 'foo', name: 'Foo', qualifier: 'TRK' } as T.Component;
const context = { router: { push: jest.fn() } };
const location = { pathname: 'foo', query: {} };
const locationWithCWE = { pathname: 'foo', query: { showCWE: 'true' } };
diff --git a/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/VulnerabilityList-test.tsx b/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/VulnerabilityList-test.tsx
index 06f6ed58ae1..c9a8902b61a 100644
--- a/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/VulnerabilityList-test.tsx
+++ b/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/VulnerabilityList-test.tsx
@@ -20,7 +20,6 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import VulnerabilityList from '../VulnerabilityList';
-import { Component } from '../../../../app/types';
jest.mock('../../../../helpers/standards.json', () => ({
default: {
@@ -30,7 +29,7 @@ jest.mock('../../../../helpers/standards.json', () => ({
}
}));
-const component = { key: 'foo', name: 'Foo', qualifier: 'TRK' } as Component;
+const component = { key: 'foo', name: 'Foo', qualifier: 'TRK' } as T.Component;
const findings = [
{
activeRules: 1,