aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps
diff options
context:
space:
mode:
authorJeremy Davis <jeremy.davis@sonarsource.com>2020-08-12 09:59:44 +0200
committersonartech <sonartech@sonarsource.com>2020-08-26 20:06:43 +0000
commitc39ab47130cf79261312b7b08afbcb2c79441f9c (patch)
tree5c72189db1b5e30a004184d9a7858238f606053c /server/sonar-web/src/main/js/apps
parentc1f7a7e59d34b1f5b961841ee1004739fcfa7a0f (diff)
downloadsonarqube-c39ab47130cf79261312b7b08afbcb2c79441f9c.tar.gz
sonarqube-c39ab47130cf79261312b7b08afbcb2c79441f9c.zip
SONAR-12749 DRYer SourceViewerHeader
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
-rw-r--r--server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelIssueMeasureRow.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/overview/branches/__tests__/MeasuresPanelIssueMeasureRow-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/IssueLabel.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/IssueRating.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/__tests__/IssueLabel-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/__tests__/IssueRating-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/utils.ts60
9 files changed, 22 insertions, 58 deletions
diff --git a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx
index 0dddf9776bb..977153b70ae 100644
--- a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx
@@ -27,9 +27,10 @@ import { findMeasure } from '../../../helpers/measures';
import { ApplicationPeriod } from '../../../types/application';
import { BranchLike } from '../../../types/branch-like';
import { ComponentQualifier } from '../../../types/component';
+import { IssueType } from '../../../types/issues';
import { MetricKey } from '../../../types/metrics';
import MeasurementLabel from '../components/MeasurementLabel';
-import { IssueType, MeasurementType } from '../utils';
+import { MeasurementType } from '../utils';
import { DrilldownMeasureValue } from './DrilldownMeasureValue';
import { LeakPeriodInfo } from './LeakPeriodInfo';
import MeasuresPanelIssueMeasureRow from './MeasuresPanelIssueMeasureRow';
diff --git a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelIssueMeasureRow.tsx b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelIssueMeasureRow.tsx
index dfe8795ce2c..a1c1d291cd1 100644
--- a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelIssueMeasureRow.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelIssueMeasureRow.tsx
@@ -20,9 +20,9 @@
import * as React from 'react';
import { BranchLike } from '../../../types/branch-like';
import { ComponentQualifier } from '../../../types/component';
+import { IssueType } from '../../../types/issues';
import IssueLabel from '../components/IssueLabel';
import IssueRating from '../components/IssueRating';
-import { IssueType } from '../utils';
import DebtValue from './DebtValue';
import SecurityHotspotsReviewed from './SecurityHotspotsReviewed';
diff --git a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/MeasuresPanelIssueMeasureRow-test.tsx b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/MeasuresPanelIssueMeasureRow-test.tsx
index 2503108b0a0..1efc4349978 100644
--- a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/MeasuresPanelIssueMeasureRow-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/MeasuresPanelIssueMeasureRow-test.tsx
@@ -22,8 +22,8 @@ import * as React from 'react';
import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
import { mockComponent, mockMeasureEnhanced, mockMetric } from '../../../../helpers/testMocks';
import { ComponentQualifier } from '../../../../types/component';
+import { IssueType } from '../../../../types/issues';
import { MetricKey } from '../../../../types/metrics';
-import { IssueType } from '../../utils';
import MeasuresPanelIssueMeasureRow, {
MeasuresPanelIssueMeasureRowProps
} from '../MeasuresPanelIssueMeasureRow';
diff --git a/server/sonar-web/src/main/js/apps/overview/components/IssueLabel.tsx b/server/sonar-web/src/main/js/apps/overview/components/IssueLabel.tsx
index 89c2405c569..f2c86205aa6 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/IssueLabel.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/IssueLabel.tsx
@@ -27,7 +27,8 @@ import { getBranchLikeQuery } from '../../../helpers/branch-like';
import { findMeasure } from '../../../helpers/measures';
import { getComponentIssuesUrl, getComponentSecurityHotspotsUrl } from '../../../helpers/urls';
import { BranchLike } from '../../../types/branch-like';
-import { getIssueIconClass, getIssueMetricKey, IssueType } from '../utils';
+import { IssueType } from '../../../types/issues';
+import { getIssueIconClass, getIssueMetricKey } from '../utils';
export interface IssueLabelProps {
branchLike?: BranchLike;
diff --git a/server/sonar-web/src/main/js/apps/overview/components/IssueRating.tsx b/server/sonar-web/src/main/js/apps/overview/components/IssueRating.tsx
index 05279460952..830c0a531e5 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/IssueRating.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/IssueRating.tsx
@@ -24,7 +24,8 @@ import { getLeakValue, getRatingTooltip } from '../../../components/measure/util
import DrilldownLink from '../../../components/shared/DrilldownLink';
import { findMeasure } from '../../../helpers/measures';
import { BranchLike } from '../../../types/branch-like';
-import { getIssueRatingMetricKey, getIssueRatingName, IssueType } from '../utils';
+import { IssueType } from '../../../types/issues';
+import { getIssueRatingMetricKey, getIssueRatingName } from '../utils';
export interface IssueRatingProps {
branchLike?: BranchLike;
diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/IssueLabel-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/IssueLabel-test.tsx
index 17b9f42fcb7..40f07a5621c 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/IssueLabel-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/IssueLabel-test.tsx
@@ -21,8 +21,8 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import { mockPullRequest } from '../../../../helpers/mocks/branch-like';
import { mockComponent, mockMeasureEnhanced, mockMetric } from '../../../../helpers/testMocks';
+import { IssueType } from '../../../../types/issues';
import { MetricKey } from '../../../../types/metrics';
-import { IssueType } from '../../utils';
import { IssueLabel, IssueLabelProps } from '../IssueLabel';
it('should render correctly for bugs', () => {
diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/IssueRating-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/IssueRating-test.tsx
index 1b660f3c124..d85efbd06c5 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/IssueRating-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/IssueRating-test.tsx
@@ -21,8 +21,8 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import { mockPullRequest } from '../../../../helpers/mocks/branch-like';
import { mockComponent, mockMeasureEnhanced, mockMetric } from '../../../../helpers/testMocks';
+import { IssueType } from '../../../../types/issues';
import { MetricKey } from '../../../../types/metrics';
-import { IssueType } from '../../utils';
import { IssueRating, IssueRatingProps } from '../IssueRating';
it('should render correctly for bugs', () => {
diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx
index 176ede6361f..df49eb32417 100644
--- a/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx
@@ -32,13 +32,14 @@ import { enhanceConditionWithMeasure, enhanceMeasuresWithMetrics } from '../../.
import { fetchBranchStatus } from '../../../store/rootActions';
import { getBranchStatusByBranchLike, Store } from '../../../store/rootReducer';
import { BranchLike, PullRequest } from '../../../types/branch-like';
+import { IssueType } from '../../../types/issues';
import { QualityGateStatusCondition } from '../../../types/quality-gates';
import IssueLabel from '../components/IssueLabel';
import IssueRating from '../components/IssueRating';
import MeasurementLabel from '../components/MeasurementLabel';
import QualityGateConditions from '../components/QualityGateConditions';
import '../styles.css';
-import { IssueType, MeasurementType, PR_METRICS } from '../utils';
+import { MeasurementType, PR_METRICS } from '../utils';
import AfterMergeEstimate from './AfterMergeEstimate';
import LargeQualityGateBadge from './LargeQualityGateBadge';
diff --git a/server/sonar-web/src/main/js/apps/overview/utils.ts b/server/sonar-web/src/main/js/apps/overview/utils.ts
index 39e122d0a0d..eadd034a437 100644
--- a/server/sonar-web/src/main/js/apps/overview/utils.ts
+++ b/server/sonar-web/src/main/js/apps/overview/utils.ts
@@ -17,13 +17,11 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import BugIcon from 'sonar-ui-common/components/icons/BugIcon';
-import CodeSmellIcon from 'sonar-ui-common/components/icons/CodeSmellIcon';
-import SecurityHotspotIcon from 'sonar-ui-common/components/icons/SecurityHotspotIcon';
-import VulnerabilityIcon from 'sonar-ui-common/components/icons/VulnerabilityIcon';
import DuplicationsRating from 'sonar-ui-common/components/ui/DuplicationsRating';
import { translate } from 'sonar-ui-common/helpers/l10n';
import CoverageRating from '../../components/ui/CoverageRating';
+import { ISSUETYPE_METRIC_KEYS_MAP } from '../../helpers/issues';
+import { IssueType } from '../../types/issues';
import { MetricKey } from '../../types/metrics';
export const METRICS: string[] = [
@@ -136,62 +134,24 @@ const MEASUREMENTS_MAP = {
}
};
-export enum IssueType {
- CodeSmell = 'CODE_SMELL',
- Vulnerability = 'VULNERABILITY',
- Bug = 'BUG',
- SecurityHotspot = 'SECURITY_HOTSPOT'
-}
-
-const ISSUETYPE_MAP = {
- [IssueType.CodeSmell]: {
- metric: MetricKey.code_smells,
- newMetric: MetricKey.new_code_smells,
- rating: MetricKey.sqale_rating,
- newRating: MetricKey.new_maintainability_rating,
- ratingName: 'Maintainability',
- iconClass: CodeSmellIcon
- },
- [IssueType.Vulnerability]: {
- metric: MetricKey.vulnerabilities,
- newMetric: MetricKey.new_vulnerabilities,
- rating: MetricKey.security_rating,
- newRating: MetricKey.new_security_rating,
- ratingName: 'Security',
- iconClass: VulnerabilityIcon
- },
- [IssueType.Bug]: {
- metric: MetricKey.bugs,
- newMetric: MetricKey.new_bugs,
- rating: MetricKey.reliability_rating,
- newRating: MetricKey.new_reliability_rating,
- ratingName: 'Reliability',
- iconClass: BugIcon
- },
- [IssueType.SecurityHotspot]: {
- metric: MetricKey.security_hotspots,
- newMetric: MetricKey.new_security_hotspots,
- rating: MetricKey.security_review_rating,
- newRating: MetricKey.new_security_review_rating,
- ratingName: 'SecurityReview',
- iconClass: SecurityHotspotIcon
- }
-};
-
export function getIssueRatingName(type: IssueType) {
- return translate('metric_domain', ISSUETYPE_MAP[type].ratingName);
+ return translate('metric_domain', ISSUETYPE_METRIC_KEYS_MAP[type].ratingName);
}
export function getIssueIconClass(type: IssueType) {
- return ISSUETYPE_MAP[type].iconClass;
+ return ISSUETYPE_METRIC_KEYS_MAP[type].iconClass;
}
export function getIssueMetricKey(type: IssueType, useDiffMetric: boolean) {
- return useDiffMetric ? ISSUETYPE_MAP[type].newMetric : ISSUETYPE_MAP[type].metric;
+ return useDiffMetric
+ ? ISSUETYPE_METRIC_KEYS_MAP[type].newMetric
+ : ISSUETYPE_METRIC_KEYS_MAP[type].metric;
}
export function getIssueRatingMetricKey(type: IssueType, useDiffMetric: boolean) {
- return useDiffMetric ? ISSUETYPE_MAP[type].newRating : ISSUETYPE_MAP[type].rating;
+ return useDiffMetric
+ ? ISSUETYPE_METRIC_KEYS_MAP[type].newRating
+ : ISSUETYPE_METRIC_KEYS_MAP[type].rating;
}
export function getMeasurementIconClass(type: MeasurementType) {