diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2018-08-22 13:47:56 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-08-24 20:21:20 +0200 |
commit | fae8b544d6c105606bb8a6c584bbe24ee2d94834 (patch) | |
tree | b7ac8b6a6759c7cc404bde744bf83cfa32aa8a5e /server/sonar-web/src/main/js/apps/issues | |
parent | fe5472dfe520e0681034fbd9996ccd030627b09b (diff) | |
download | sonarqube-fae8b544d6c105606bb8a6c584bbe24ee2d94834.tar.gz sonarqube-fae8b544d6c105606bb8a6c584bbe24ee2d94834.zip |
introduce IssueType and RuleType enums
Diffstat (limited to 'server/sonar-web/src/main/js/apps/issues')
5 files changed, 11 insertions, 8 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx index 43c03a88fdb..64e770d506f 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx @@ -21,7 +21,7 @@ import * as React from 'react'; import { pickBy, sortBy } from 'lodash'; import { searchAssignees } from '../utils'; import { searchIssueTags, bulkChangeIssues } from '../../../api/issues'; -import { Component, CurrentUser, Issue, Paging, isLoggedIn } from '../../../app/types'; +import { Component, CurrentUser, Issue, Paging, isLoggedIn, IssueType } from '../../../app/types'; import throwGlobalError from '../../../app/utils/throwGlobalError'; import MarkdownTips from '../../../components/common/MarkdownTips'; import SearchSelect from '../../../components/controls/SearchSelect'; @@ -332,7 +332,7 @@ export default class BulkChangeModal extends React.PureComponent<Props, State> { return null; } - const types = ['BUG', 'VULNERABILITY', 'CODE_SMELL']; + const types = [IssueType.Bug, IssueType.Vulnerability, IssueType.CodeSmell]; const options = types.map(type => ({ label: translate('issue.type', type), value: type })); const optionRenderer = (option: { label: string; value: string }) => ( diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx index f0bcd9eaa55..d6fbe8a5d2d 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx @@ -21,7 +21,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import BulkChangeModal from '../BulkChangeModal'; import { waitAndUpdate } from '../../../../helpers/testUtils'; -import { Issue } from '../../../../app/types'; +import { Issue, IssueType } from '../../../../app/types'; jest.mock('../../../../api/issues', () => ({ searchIssueTags: () => Promise.resolve([undefined, []]) @@ -55,7 +55,7 @@ it('should display form when issues are present', async () => { secondaryLocations: [], severity: 'foo', status: 'foo', - type: 'foo' + type: IssueType.Bug } ]); await waitAndUpdate(wrapper); diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx index 2658e5ee0e0..7677f2c8b90 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ConciseIssue from '../ConciseIssue'; +import { IssueType } from '../../../../app/types'; const issue = { component: '', @@ -38,7 +39,7 @@ const issue = { ruleName: '', severity: '', status: '', - type: '', + type: IssueType.Bug, secondaryLocations: [], flows: [], fromHotspot: false diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssue-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssue-test.tsx.snap index 5a50fbad489..3041bcc6b35 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssue-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssue-test.tsx.snap @@ -27,7 +27,7 @@ exports[`should render 1`] = ` "secondaryLocations": Array [], "severity": "", "status": "", - "type": "", + "type": "BUG", } } onClick={[MockFunction]} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx index 6dced6ed39c..e246dc28202 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx @@ -28,6 +28,7 @@ import IssueTypeIcon from '../../../components/ui/IssueTypeIcon'; import { translate } from '../../../helpers/l10n'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import MultipleSelectionHint from '../../../components/facet/MultipleSelectionHint'; +import { IssueType } from '../../../app/types'; interface Props { fetching: boolean; @@ -38,7 +39,7 @@ interface Props { types: string[]; } -const TYPES = ['BUG', 'VULNERABILITY', 'CODE_SMELL', 'SECURITY_HOTSPOT']; +const TYPES = [IssueType.Bug, IssueType.Vulnerability, IssueType.CodeSmell, IssueType.Hotspot]; export default class TypeFacet extends React.PureComponent<Props> { property = 'types'; @@ -80,7 +81,8 @@ export default class TypeFacet extends React.PureComponent<Props> { // type is selected explicitly types.includes(type) || // bugs, vulnerabilities and code smells are selected implicitly by default - (types.length === 0 && ['BUG', 'VULNERABILITY', 'CODE_SMELL'].includes(type)) + (types.length === 0 && + [IssueType.Bug, IssueType.Vulnerability, IssueType.CodeSmell].includes(type as IssueType)) ); } |