diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/overview')
32 files changed, 101 insertions, 143 deletions
diff --git a/server/sonar-web/src/main/js/apps/overview/badges/BadgeParams.tsx b/server/sonar-web/src/main/js/apps/overview/badges/BadgeParams.tsx index 6c5a6613d61..ddb7de1f365 100644 --- a/server/sonar-web/src/main/js/apps/overview/badges/BadgeParams.tsx +++ b/server/sonar-web/src/main/js/apps/overview/badges/BadgeParams.tsx @@ -22,11 +22,10 @@ import { BadgeColors, BadgeType, BadgeOptions } from './utils'; import Select from '../../../components/controls/Select'; import { fetchWebApi } from '../../../api/web-api'; import { getLocalizedMetricName, translate } from '../../../helpers/l10n'; -import { Metric } from '../../../app/types'; interface Props { className?: string; - metrics: { [key: string]: Metric }; + metrics: { [key: string]: T.Metric }; options: BadgeOptions; type: BadgeType; updateOptions: (options: Partial<BadgeOptions>) => void; diff --git a/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx b/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx index 9898a4f2b01..1962e6f73f0 100644 --- a/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx +++ b/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import BadgeButton from './BadgeButton'; import BadgeParams from './BadgeParams'; import { BadgeType, BadgeOptions, getBadgeUrl } from './utils'; -import { Metric, BranchLike } from '../../../app/types'; import CodeSnippet from '../../../components/common/CodeSnippet'; import Modal from '../../../components/controls/Modal'; import { getBranchLikeQuery } from '../../../helpers/branches'; @@ -31,8 +30,8 @@ import { isSonarCloud } from '../../../helpers/system'; import './styles.css'; interface Props { - branchLike?: BranchLike; - metrics: { [key: string]: Metric }; + branchLike?: T.BranchLike; + metrics: { [key: string]: T.Metric }; project: string; qualifier: string; } diff --git a/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgeParams-test.tsx b/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgeParams-test.tsx index 5e8936739b3..7656a4ac629 100644 --- a/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgeParams-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgeParams-test.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import BadgeParams from '../BadgeParams'; import { BadgeType } from '../utils'; -import { Metric } from '../../../../app/types'; jest.mock('../../../../api/web-api', () => ({ fetchWebApi: () => @@ -39,8 +38,8 @@ jest.mock('../../../../api/web-api', () => ({ })); const METRICS = { - alert_status: { key: 'alert_status', name: 'Quality Gate' } as Metric, - coverage: { key: 'coverage', name: 'Coverage' } as Metric + alert_status: { key: 'alert_status', name: 'Quality Gate' } as T.Metric, + coverage: { key: 'coverage', name: 'Coverage' } as T.Metric }; it('should display marketing badge params', () => { diff --git a/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgesModal-test.tsx b/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgesModal-test.tsx index 23555a9a631..eedcb7913f0 100644 --- a/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgesModal-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgesModal-test.tsx @@ -21,17 +21,16 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import BadgesModal from '../BadgesModal'; import { click } from '../../../../helpers/testUtils'; -import { ShortLivingBranch, BranchType } from '../../../../app/types'; import { isSonarCloud } from '../../../../helpers/system'; jest.mock('../../../../helpers/urls', () => ({ getHostUrl: () => 'host' })); jest.mock('../../../../helpers/system', () => ({ isSonarCloud: jest.fn() })); -const shortBranch: ShortLivingBranch = { +const shortBranch: T.ShortLivingBranch = { isMain: false, mergeBranch: '', name: 'branch-6.6', - type: BranchType.SHORT + type: 'SHORT' }; it('should display the modal after click on sonar cloud', () => { diff --git a/server/sonar-web/src/main/js/apps/overview/components/App.tsx b/server/sonar-web/src/main/js/apps/overview/components/App.tsx index 68c8238c23c..74ec5533243 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/App.tsx @@ -24,7 +24,6 @@ import EmptyOverview from './EmptyOverview'; import OverviewApp from './OverviewApp'; import SonarCloudEmptyOverview from './SonarCloudEmptyOverview'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; -import { Component, BranchLike } from '../../../app/types'; import { isShortLivingBranch } from '../../../helpers/branches'; import { getShortLivingBranchUrl, @@ -36,12 +35,12 @@ import { import { isSonarCloud } from '../../../helpers/system'; interface Props { - branchLike?: BranchLike; - branchLikes: BranchLike[]; - component: Component; + branchLike?: T.BranchLike; + branchLikes: T.BranchLike[]; + component: T.Component; isInProgress?: boolean; isPending?: boolean; - onComponentChange: (changes: Partial<Component>) => void; + onComponentChange: (changes: Partial<T.Component>) => void; } export default class App extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx b/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx index 9fb9e9a51e2..2e9f7123d60 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx @@ -25,11 +25,10 @@ import DateTooltipFormatter from '../../../components/intl/DateTooltipFormatter' import { getApplicationLeak } from '../../../api/application'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import DateFromNow from '../../../components/intl/DateFromNow'; -import { LightComponent, LongLivingBranch } from '../../../app/types'; interface Props { - branch?: LongLivingBranch; - component: LightComponent; + branch?: T.LongLivingBranch; + component: T.LightComponent; } interface State { diff --git a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx index a5db1cb7e6a..c862b97b0e4 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx @@ -21,13 +21,12 @@ import * as React from 'react'; import { Link } from 'react-router'; import { FormattedMessage } from 'react-intl'; import { translate } from '../../../helpers/l10n'; -import { BranchLike } from '../../../app/types'; import { isBranch, isLongLivingBranch } from '../../../helpers/branches'; import { Alert } from '../../../components/ui/Alert'; interface Props { - branchLike?: BranchLike; - branchLikes: BranchLike[]; + branchLike?: T.BranchLike; + branchLikes: T.BranchLike[]; component: string; showWarning?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx b/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx index 7e1c17777dd..fd3615653aa 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx @@ -26,10 +26,9 @@ import Tooltip from '../../../components/controls/Tooltip'; import { getPeriodDate, getPeriodLabel } from '../../../helpers/periods'; import { translateWithParameters } from '../../../helpers/l10n'; import { differenceInDays } from '../../../helpers/dates'; -import { Period, PeriodMode } from '../../../app/types'; interface Props { - period: Period; + period: T.Period; } export default class LeakPeriodLegend extends React.PureComponent<Props> { @@ -48,7 +47,7 @@ export default class LeakPeriodLegend extends React.PureComponent<Props> { return null; } - if (period.mode === PeriodMode.Days) { + if (period.mode === 'days') { return ( <div className="overview-legend overview-legend-spaced-line"> {translateWithParameters('overview.new_code_period_x', leakPeriodLabel)} @@ -64,7 +63,7 @@ export default class LeakPeriodLegend extends React.PureComponent<Props> { const formattedDateFunction = (formattedLeakPeriodDate: string) => ( <span> {translateWithParameters( - period.mode === PeriodMode.PreviousAnalysis + period.mode === 'previous_analysis' ? 'overview.previous_analysis_on_x' : 'overview.started_on_x', formattedLeakPeriodDate @@ -90,7 +89,7 @@ export default class LeakPeriodLegend extends React.PureComponent<Props> { {fromNow => ( <span className="note"> {translateWithParameters( - period.mode === PeriodMode.PreviousAnalysis + period.mode === 'previous_analysis' ? 'overview.previous_analysis_x' : 'overview.started_x', fromNow diff --git a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx index aa82ff5837f..611b3f5087f 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx @@ -48,18 +48,17 @@ import { } from '../../../helpers/branches'; import { fetchMetrics } from '../../../store/rootActions'; import { getMetrics, Store } from '../../../store/rootReducer'; -import { BranchLike, Component, Metric, MeasureEnhanced, Period } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; import '../styles.css'; interface OwnProps { - branchLike?: BranchLike; - component: Component; + branchLike?: T.BranchLike; + component: T.Component; onComponentChange: (changes: {}) => void; } interface StateToProps { - metrics: { [key: string]: Metric }; + metrics: { [key: string]: T.Metric }; } interface DispatchToProps { @@ -74,8 +73,8 @@ interface State { }; historyStartDate?: Date; loading: boolean; - measures: MeasureEnhanced[]; - periods?: Period[]; + measures: T.MeasureEnhanced[]; + periods?: T.Period[]; } export class OverviewApp extends React.PureComponent<Props, State> { @@ -162,7 +161,7 @@ export class OverviewApp extends React.PureComponent<Props, State> { getApplicationLeakPeriod = () => this.state.measures.find(measure => measure.metric.key === 'new_bugs') - ? ({ index: 1 } as Period) + ? ({ index: 1 } as T.Period) : undefined; isEmpty = () => diff --git a/server/sonar-web/src/main/js/apps/overview/components/SonarCloudEmptyOverview.tsx b/server/sonar-web/src/main/js/apps/overview/components/SonarCloudEmptyOverview.tsx index 46ebf59c072..d1be8f47023 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/SonarCloudEmptyOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/SonarCloudEmptyOverview.tsx @@ -22,7 +22,6 @@ import { connect } from 'react-redux'; import { FormattedMessage } from 'react-intl'; import AnalyzeTutorial from '../../tutorials/analyzeProject/AnalyzeTutorial'; import MetaContainer from '../meta/MetaContainer'; -import { BranchLike, Component, CurrentUser } from '../../../app/types'; import { isLongLivingBranch, isBranch, isMainBranch } from '../../../helpers/branches'; import { translate } from '../../../helpers/l10n'; import { isLoggedIn } from '../../../helpers/users'; @@ -31,15 +30,15 @@ import '../../../app/styles/sonarcloud.css'; import { Alert } from '../../../components/ui/Alert'; interface OwnProps { - branchLike?: BranchLike; - branchLikes: BranchLike[]; - component: Component; + branchLike?: T.BranchLike; + branchLikes: T.BranchLike[]; + component: T.Component; hasAnalyses?: boolean; onComponentChange: (changes: {}) => void; } interface StateProps { - currentUser: CurrentUser; + currentUser: T.CurrentUser; } type Props = OwnProps & StateProps; @@ -99,7 +98,7 @@ export function WarningMessage({ branchLike, message }: { - branchLike?: BranchLike; + branchLike?: T.BranchLike; message: string; }) { if (!isBranch(branchLike)) { diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx index 73eb99d9350..afac1a5750e 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { mount, shallow } from 'enzyme'; import App from '../App'; -import { BranchType, LongLivingBranch } from '../../../../app/types'; import { isSonarCloud } from '../../../../helpers/system'; jest.mock('../../../../helpers/system', () => ({ isSonarCloud: jest.fn() })); @@ -66,7 +65,7 @@ it('should render SonarCloudEmptyOverview', () => { }); it('redirects on Code page for files', () => { - const branch: LongLivingBranch = { isMain: false, name: 'b', type: BranchType.LONG }; + const branch: T.LongLivingBranch = { isMain: false, name: 'b', type: 'LONG' }; const newComponent = { ...component, breadcrumbs: [ diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx index 6fd204472ab..593c512198b 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx @@ -20,9 +20,8 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import EmptyOverview from '../EmptyOverview'; -import { BranchType } from '../../../../app/types'; -const branch = { isMain: true, name: 'b', type: BranchType.LONG }; +const branch = { isMain: true, name: 'b', type: 'LONG' }; it('renders', () => { expect( diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx index 77a2ddc8cca..f4a39fd5f13 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import LeakPeriodLegend from '../LeakPeriodLegend'; import { differenceInDays } from '../../../../helpers/dates'; -import { Period, PeriodMode } from '../../../../app/types'; jest.mock('../../../../helpers/dates', () => { const dates = require.requireActual('../../../../helpers/dates'); @@ -34,7 +33,7 @@ it('10 days', () => { getWrapper({ date: '2013-09-22T00:00:00+0200', index: 0, - mode: PeriodMode.Days, + mode: 'days', parameter: '10' }) ).toMatchSnapshot(); @@ -45,7 +44,7 @@ it('date', () => { getWrapper({ date: '2013-09-22T00:00:00+0200', index: 0, - mode: PeriodMode.Date, + mode: 'date', parameter: '2013-01-01' }) ).toMatchSnapshot(); @@ -56,7 +55,7 @@ it('version', () => { getWrapper({ date: '2013-09-22T00:00:00+0200', index: 0, - mode: PeriodMode.Version, + mode: 'version', parameter: '0.1' }).find('.overview-legend') ).toMatchSnapshot(); @@ -67,7 +66,7 @@ it('previous_version', () => { getWrapper({ date: '2013-09-22T00:00:00+0200', index: 0, - mode: PeriodMode.PreviousVersion + mode: 'previous_version' }).find('.overview-legend') ).toMatchSnapshot(); }); @@ -77,7 +76,7 @@ it('previous_analysis', () => { getWrapper({ date: '2013-09-22T00:00:00+0200', index: 0, - mode: PeriodMode.PreviousAnalysis + mode: 'previous_analysis' }).find('.overview-legend') ).toMatchSnapshot(); }); @@ -88,12 +87,12 @@ it('should render a more precise date', () => { getWrapper({ date: '2018-08-17T00:00:00+0200', index: 0, - mode: PeriodMode.PreviousVersion + mode: 'previous_version' }) ).toMatchSnapshot(); }); -function getWrapper(period: Period) { +function getWrapper(period: T.Period) { return shallow(<LeakPeriodLegend period={period} />, { context: { intl: { formatDate: (date: string) => 'formatted.' + date } diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/SonarCloudEmptyOverview-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/SonarCloudEmptyOverview-test.tsx index 278fca079d1..f971b2dbe9f 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/SonarCloudEmptyOverview-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/SonarCloudEmptyOverview-test.tsx @@ -20,9 +20,8 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { SonarCloudEmptyOverview, WarningMessage } from '../SonarCloudEmptyOverview'; -import { BranchType } from '../../../../app/types'; -const branch = { isMain: true, name: 'b', type: BranchType.LONG }; +const branch = { isMain: true, name: 'b', type: 'LONG' }; const component = { key: 'foo', diff --git a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx index 1de1bc02ba4..849706cdc88 100644 --- a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx +++ b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx @@ -23,22 +23,21 @@ import Analysis from './Analysis'; import { getProjectActivity } from '../../../api/projectActivity'; import PreviewGraph from '../../../components/preview-graph/PreviewGraph'; import { translate } from '../../../helpers/l10n'; -import { Metric, Component, BranchLike, Analysis as AnalysisType } from '../../../app/types'; import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branches'; import { getActivityUrl } from '../../../helpers/urls'; interface Props { - branchLike?: BranchLike; - component: Component; + branchLike?: T.BranchLike; + component: T.Component; history?: { [metric: string]: Array<{ date: Date; value?: string }>; }; - metrics: { [key: string]: Metric }; + metrics: { [key: string]: T.Metric }; qualifier: string; } interface State { - analyses: AnalysisType[]; + analyses: T.Analysis[]; loading: boolean; } @@ -99,7 +98,7 @@ export default class AnalysesList extends React.PureComponent<Props, State> { ); }; - renderList(analyses: AnalysisType[]) { + renderList(analyses: T.Analysis[]) { if (!analyses.length) { return <p className="spacer-top note">{translate('no_results')}</p>; } diff --git a/server/sonar-web/src/main/js/apps/overview/events/Analysis.tsx b/server/sonar-web/src/main/js/apps/overview/events/Analysis.tsx index aa00c270b34..615bccad2de 100644 --- a/server/sonar-web/src/main/js/apps/overview/events/Analysis.tsx +++ b/server/sonar-web/src/main/js/apps/overview/events/Analysis.tsx @@ -21,11 +21,10 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import Event from './Event'; import DateTooltipFormatter from '../../../components/intl/DateTooltipFormatter'; -import { Analysis as AnalysisType } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - analysis: AnalysisType; + analysis: T.Analysis; qualifier: string; } diff --git a/server/sonar-web/src/main/js/apps/overview/events/Event.tsx b/server/sonar-web/src/main/js/apps/overview/events/Event.tsx index b7fc148533a..262ff7c78a9 100644 --- a/server/sonar-web/src/main/js/apps/overview/events/Event.tsx +++ b/server/sonar-web/src/main/js/apps/overview/events/Event.tsx @@ -19,14 +19,13 @@ */ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; -import { AnalysisEvent } from '../../../app/types'; import { isRichQualityGateEvent } from '../../projectActivity/components/RichQualityGateEventInner'; import Level from '../../../components/ui/Level'; import { translate } from '../../../helpers/l10n'; import { isDefinitionChangeEvent } from '../../projectActivity/components/DefinitionChangeEventInner'; interface Props { - event: AnalysisEvent; + event: T.AnalysisEvent; } export default function Event({ event }: Props) { diff --git a/server/sonar-web/src/main/js/apps/overview/main/BugsAndVulnerabilities.tsx b/server/sonar-web/src/main/js/apps/overview/main/BugsAndVulnerabilities.tsx index 146158a5b61..3c7de94b878 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/BugsAndVulnerabilities.tsx +++ b/server/sonar-web/src/main/js/apps/overview/main/BugsAndVulnerabilities.tsx @@ -29,7 +29,6 @@ import { getMetricName } from '../utils'; import { getComponentDrilldownUrl } from '../../../helpers/urls'; import { translate } from '../../../helpers/l10n'; import { isLongLivingBranch } from '../../../helpers/branches'; -import { IssueType } from '../../../app/types'; export class BugsAndVulnerabilities extends React.PureComponent<ComposedProps> { renderHeader() { @@ -82,9 +81,7 @@ export class BugsAndVulnerabilities extends React.PureComponent<ComposedProps> { <div className="overview-domain-measures"> <div className="overview-domain-measure"> <div className="overview-domain-measure-value"> - <span style={{ marginLeft: 30 }}> - {this.props.renderIssues('new_bugs', IssueType.Bug)} - </span> + <span style={{ marginLeft: 30 }}>{this.props.renderIssues('new_bugs', 'BUG')}</span> {this.props.renderRating('new_reliability_rating')} </div> <div className="overview-domain-measure-label"> @@ -95,7 +92,7 @@ export class BugsAndVulnerabilities extends React.PureComponent<ComposedProps> { <div className="overview-domain-measure"> <div className="overview-domain-measure-value"> <span style={{ marginLeft: 30 }}> - {this.props.renderIssues('new_vulnerabilities', IssueType.Vulnerability)} + {this.props.renderIssues('new_vulnerabilities', 'VULNERABILITY')} </span> {this.props.renderRating('new_security_rating')} </div> @@ -115,7 +112,7 @@ export class BugsAndVulnerabilities extends React.PureComponent<ComposedProps> { <div className="overview-domain-measures"> <div className="overview-domain-measure"> <div className="overview-domain-measure-value"> - {this.props.renderIssues('bugs', IssueType.Bug)} + {this.props.renderIssues('bugs', 'BUG')} {this.props.renderRating('reliability_rating')} </div> <div className="overview-domain-measure-label"> @@ -126,7 +123,7 @@ export class BugsAndVulnerabilities extends React.PureComponent<ComposedProps> { </div> <div className="overview-domain-measure"> <div className="overview-domain-measure-value"> - {this.props.renderIssues('vulnerabilities', IssueType.Vulnerability)} + {this.props.renderIssues('vulnerabilities', 'VULNERABILITY')} {this.props.renderRating('security_rating')} </div> <div className="overview-domain-measure-label"> diff --git a/server/sonar-web/src/main/js/apps/overview/main/CodeSmells.tsx b/server/sonar-web/src/main/js/apps/overview/main/CodeSmells.tsx index c49704368f0..f5adea6c517 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/CodeSmells.tsx +++ b/server/sonar-web/src/main/js/apps/overview/main/CodeSmells.tsx @@ -25,7 +25,6 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; import CodeSmellIcon from '../../../components/icons-components/CodeSmellIcon'; import DrilldownLink from '../../../components/shared/DrilldownLink'; -import { IssueType } from '../../../app/types'; export class CodeSmells extends React.PureComponent<ComposedProps> { renderHeader() { @@ -85,7 +84,7 @@ export class CodeSmells extends React.PureComponent<ComposedProps> { </div> <div className="overview-domain-measure"> <div className="overview-domain-measure-value"> - {this.props.renderIssues('new_code_smells', IssueType.CodeSmell)} + {this.props.renderIssues('new_code_smells', 'CODE_SMELL')} </div> <div className="overview-domain-measure-label"> <CodeSmellIcon className="little-spacer-right" /> @@ -115,7 +114,7 @@ export class CodeSmells extends React.PureComponent<ComposedProps> { </div> <div className="overview-domain-measure"> <div className="overview-domain-measure-value"> - {this.props.renderIssues('code_smells', IssueType.CodeSmell)} + {this.props.renderIssues('code_smells', 'CODE_SMELL')} </div> <div className="overview-domain-measure-label offset-left"> <CodeSmellIcon className="little-spacer-right " /> diff --git a/server/sonar-web/src/main/js/apps/overview/main/enhance.tsx b/server/sonar-web/src/main/js/apps/overview/main/enhance.tsx index d583ae979d8..3bad649a3ea 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/enhance.tsx +++ b/server/sonar-web/src/main/js/apps/overview/main/enhance.tsx @@ -39,14 +39,13 @@ import { getComponentIssuesUrl, getMeasureHistoryUrl } from '../../../helpers/urls'; -import { Component, BranchLike, MeasureEnhanced, Period } from '../../../app/types'; import { getBranchLikeQuery } from '../../../helpers/branches'; export interface EnhanceProps { - branchLike?: BranchLike; - component: Component; - measures: MeasureEnhanced[]; - leakPeriod?: Period; + branchLike?: T.BranchLike; + component: T.Component; + measures: T.MeasureEnhanced[]; + leakPeriod?: T.Period; history?: { [metric: string]: Array<{ date: Date; value?: string }>; }; @@ -54,11 +53,11 @@ export interface EnhanceProps { } export interface ComposedProps extends EnhanceProps { - getValue: (measure: MeasureEnhanced) => string | undefined; + getValue: (measure: T.MeasureEnhanced) => string | undefined; renderHeader: (domain: string, label: string) => React.ReactNode; renderMeasure: (metricKey: string) => React.ReactNode; renderRating: (metricKey: string) => React.ReactNode; - renderIssues: (metric: string, type: string) => React.ReactNode; + renderIssues: (metric: string, type: T.IssueType) => React.ReactNode; renderHistoryLink: (metricKey: string) => React.ReactNode; renderTimeline: (metricKey: string, range: string, children?: React.ReactNode) => React.ReactNode; } @@ -67,7 +66,7 @@ export default function enhance(ComposedComponent: React.ComponentType<ComposedP return class extends React.PureComponent<EnhanceProps> { static displayName = `enhance(${ComposedComponent.displayName})}`; - getValue = (measure: MeasureEnhanced) => { + getValue = (measure: T.MeasureEnhanced) => { const { leakPeriod } = this.props; if (!measure) { return '0'; diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx index 80fe882f3d9..f4a9b938b37 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx @@ -29,15 +29,6 @@ import MetaSize from './MetaSize'; import MetaTags from './MetaTags'; import BadgesModal from '../badges/BadgesModal'; import AnalysesList from '../events/AnalysesList'; -import { - Visibility, - Component, - Metric, - BranchLike, - CurrentUser, - Organization, - MeasureEnhanced -} from '../../../app/types'; import { translate } from '../../../helpers/l10n'; import { hasPrivateAccess } from '../../../helpers/organizations'; import { @@ -49,19 +40,19 @@ import { import PrivacyBadgeContainer from '../../../components/common/PrivacyBadgeContainer'; interface StateToProps { - currentUser: CurrentUser; - organization?: Organization; - userOrganizations: Organization[]; + currentUser: T.CurrentUser; + organization?: T.Organization; + userOrganizations: T.Organization[]; } interface OwnProps { - branchLike?: BranchLike; - component: Component; + branchLike?: T.BranchLike; + component: T.Component; history?: { [metric: string]: Array<{ date: Date; value?: string }>; }; - measures?: MeasureEnhanced[]; - metrics?: { [key: string]: Metric }; + measures?: T.MeasureEnhanced[]; + metrics?: { [key: string]: T.Metric }; onComponentChange: (changes: {}) => void; } @@ -113,7 +104,7 @@ export class Meta extends React.PureComponent<Props> { const isProject = qualifier === 'TRK'; const isApp = qualifier === 'APP'; - const isPrivate = visibility === Visibility.Private; + const isPrivate = visibility === 'private'; return ( <div className="overview-meta"> <div className="overview-meta-card"> diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaLink.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaLink.tsx index 85eeaf8ca81..a1e1e6bad13 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaLink.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaLink.tsx @@ -19,11 +19,10 @@ */ import * as React from 'react'; import { getLinkName } from '../../projectLinks/utils'; -import { ProjectLink } from '../../../app/types'; import ProjectLinkIcon from '../../../components/icons-components/ProjectLinkIcon'; interface Props { - link: ProjectLink; + link: T.ProjectLink; } export default function MetaLink({ link }: Props) { diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaLinks.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaLinks.tsx index 78d87b6f88b..0a8251dfb27 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaLinks.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaLinks.tsx @@ -21,15 +21,14 @@ import * as React from 'react'; import MetaLink from './MetaLink'; import { orderLinks } from '../../projectLinks/utils'; import { getProjectLinks } from '../../../api/projectLinks'; -import { LightComponent, ProjectLink } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - component: LightComponent; + component: T.LightComponent; } interface State { - links?: ProjectLink[]; + links?: T.ProjectLink[]; } export default class MetaLinks extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx index 06452143c33..406ffcee656 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx @@ -26,16 +26,15 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getQualityProfileUrl } from '../../../helpers/urls'; import { searchRules } from '../../../api/rules'; import { getLanguages, Store } from '../../../store/rootReducer'; -import { ComponentQualityProfile, Languages } from '../../../app/types'; interface StateProps { - languages: Languages; + languages: T.Languages; } interface OwnProps { headerClassName?: string; organization?: string; - profiles: ComponentQualityProfile[]; + profiles: T.ComponentQualityProfile[]; } interface State { @@ -90,7 +89,7 @@ class MetaQualityProfiles extends React.PureComponent<StateProps & OwnProps, Sta return count || 0; } - renderProfile(profile: ComponentQualityProfile) { + renderProfile(profile: T.ComponentQualityProfile) { const languageFromStore = this.props.languages[profile.language]; const languageName = languageFromStore ? languageFromStore.name : profile.language; diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaSize.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaSize.tsx index ab902845eb1..2c97f7246ca 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaSize.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaSize.tsx @@ -25,16 +25,15 @@ import SizeRating from '../../../components/ui/SizeRating'; import { formatMeasure } from '../../../helpers/measures'; import { getMetricName } from '../utils'; import { translate } from '../../../helpers/l10n'; -import { LightComponent, BranchLike, MeasureEnhanced } from '../../../app/types'; interface Props { - branchLike?: BranchLike; - component: LightComponent; - measures: MeasureEnhanced[]; + branchLike?: T.BranchLike; + component: T.LightComponent; + measures: T.MeasureEnhanced[]; } export default class MetaSize extends React.PureComponent<Props> { - renderLoC = (ncloc?: MeasureEnhanced) => ( + renderLoC = (ncloc?: T.MeasureEnhanced) => ( <div className={classNames('overview-meta-size-ncloc', { 'is-half-width': this.props.component.qualifier === 'APP' diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaTags.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaTags.tsx index 855b3201c0c..475e82fb3cd 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaTags.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaTags.tsx @@ -22,13 +22,12 @@ import MetaTagsSelector from './MetaTagsSelector'; import { setProjectTags } from '../../../api/components'; import { translate } from '../../../helpers/l10n'; import TagsList from '../../../components/tags/TagsList'; -import { Component } from '../../../app/types'; import { Button } from '../../../components/ui/buttons'; import Dropdown from '../../../components/controls/Dropdown'; import { PopupPlacement } from '../../../components/ui/popups'; interface Props { - component: Component; + component: T.Component; onComponentChange: (changes: {}) => void; } diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx index 91cba327f51..7cf6741b1b9 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx @@ -23,17 +23,16 @@ import ApplicationQualityGateProject from './ApplicationQualityGateProject'; import Level from '../../../components/ui/Level'; import { getApplicationQualityGate, ApplicationProject } from '../../../api/quality-gates'; import { translate } from '../../../helpers/l10n'; -import { LightComponent, Metric, LongLivingBranch } from '../../../app/types'; import DocTooltip from '../../../components/docs/DocTooltip'; interface Props { - branch?: LongLivingBranch; - component: LightComponent; + branch?: T.LongLivingBranch; + component: T.LightComponent; } type State = { loading: boolean; - metrics?: { [key: string]: Metric }; + metrics?: { [key: string]: T.Metric }; projects?: ApplicationProject[]; status?: string; }; diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGateProject.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGateProject.tsx index 620a839fed0..fe5df8f34e6 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGateProject.tsx +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGateProject.tsx @@ -24,11 +24,10 @@ import { getLocalizedMetricName, translate } from '../../../helpers/l10n'; import { formatMeasure, isDiffMetric } from '../../../helpers/measures'; import { getProjectUrl } from '../../../helpers/urls'; import './ApplicationQualityGateProject.css'; -import { Metric } from '../../../app/types'; import { ApplicationProject, ConditionAnalysis } from '../../../api/quality-gates'; interface Props { - metrics: { [key: string]: Metric }; + metrics: { [key: string]: T.Metric }; project: ApplicationProject; } diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.tsx index b49ea0000a2..47370714c3e 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.tsx +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.tsx @@ -24,13 +24,12 @@ import { translate } from '../../../helpers/l10n'; import Level from '../../../components/ui/Level'; import HelpTooltip from '../../../components/controls/HelpTooltip'; import DocTooltip from '../../../components/docs/DocTooltip'; -import { Component, BranchLike, MeasureEnhanced } from '../../../app/types'; import { Alert } from '../../../components/ui/Alert'; interface Props { - branchLike?: BranchLike; - component: Pick<Component, 'key' | 'qualifier'>; - measures: MeasureEnhanced[]; + branchLike?: T.BranchLike; + component: Pick<T.Component, 'key' | 'qualifier'>; + measures: T.MeasureEnhanced[]; } export default function QualityGate({ branchLike, component, measures }: Props) { @@ -89,6 +88,6 @@ function parseQualityGateDetails(rawDetails: string) { return JSON.parse(rawDetails); } -function isProject(component: Pick<Component, 'qualifier'>) { +function isProject(component: Pick<T.Component, 'qualifier'>) { return component.qualifier === 'TRK'; } diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx index af96ccf0a1d..627bf89d57d 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx @@ -28,11 +28,10 @@ import { getPeriodValue, isDiffMetric, formatMeasure } from '../../../helpers/me import { translate } from '../../../helpers/l10n'; import { getComponentIssuesUrl } from '../../../helpers/urls'; import { getBranchLikeQuery } from '../../../helpers/branches'; -import { IssueType, BranchLike, Component } from '../../../app/types'; interface Props { - branchLike?: BranchLike; - component: Pick<Component, 'key'>; + branchLike?: T.BranchLike; + component: Pick<T.Component, 'key'>; condition: QualityGateStatusConditionEnhanced; } @@ -60,7 +59,7 @@ export default class QualityGateCondition extends React.PureComponent<Props> { }; getUrlForCodeSmells(sinceLeakPeriod: boolean) { - return this.getIssuesUrl(sinceLeakPeriod, { types: IssueType.CodeSmell }); + return this.getIssuesUrl(sinceLeakPeriod, { types: 'CODE_SMELL' }); } getUrlForBugsOrVulnerabilities(type: string, sinceLeakPeriod: boolean) { @@ -81,7 +80,7 @@ export default class QualityGateCondition extends React.PureComponent<Props> { } getUrlForType(type: string, sinceLeakPeriod: boolean) { - return type === IssueType.CodeSmell + return type === 'CODE_SMELL' ? this.getUrlForCodeSmells(sinceLeakPeriod) : this.getUrlForBugsOrVulnerabilities(type, sinceLeakPeriod); } @@ -98,12 +97,12 @@ export default class QualityGateCondition extends React.PureComponent<Props> { const metricKey = condition.measure.metric.key; const RATING_METRICS_MAPPING: { [metric: string]: [string, boolean] } = { - reliability_rating: [IssueType.Bug, false], - new_reliability_rating: [IssueType.Bug, true], - security_rating: [IssueType.Vulnerability, false], - new_security_rating: [IssueType.Vulnerability, true], - sqale_rating: [IssueType.CodeSmell, false], - new_maintainability_rating: [IssueType.CodeSmell, true] + reliability_rating: ['BUG', false], + new_reliability_rating: ['BUG', true], + security_rating: ['VULNERABILITY', false], + new_security_rating: ['VULNERABILITY', true], + sqale_rating: ['CODE_SMELL', false], + new_maintainability_rating: ['CODE_SMELL', true] }; return RATING_METRICS_MAPPING[metricKey] ? ( diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.tsx index 32762196d54..5f4118e85bd 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.tsx +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.tsx @@ -24,13 +24,12 @@ import { QualityGateStatusCondition, QualityGateStatusConditionEnhanced } from ' import { getMeasuresAndMeta } from '../../../api/measures'; import { enhanceMeasuresWithMetrics } from '../../../helpers/measures'; import { isSameBranchLike, getBranchLikeQuery } from '../../../helpers/branches'; -import { BranchLike, Component, MeasureEnhanced } from '../../../app/types'; const LEVEL_ORDER = ['ERROR', 'WARN']; interface Props { - branchLike?: BranchLike; - component: Pick<Component, 'key'>; + branchLike?: T.BranchLike; + component: Pick<T.Component, 'key'>; conditions: QualityGateStatusCondition[]; } @@ -126,7 +125,7 @@ export default class QualityGateConditions extends React.PureComponent<Props, St function enhanceConditions( conditions: QualityGateStatusCondition[], - measures: MeasureEnhanced[] + measures: T.MeasureEnhanced[] ): QualityGateStatusConditionEnhanced[] { return conditions.map(condition => { const measure = measures.find(measure => measure.metric.key === condition.metric)!; 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 cb0923876ef..7e1b8f2eb74 100644 --- a/server/sonar-web/src/main/js/apps/overview/utils.ts +++ b/server/sonar-web/src/main/js/apps/overview/utils.ts @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { MeasureEnhanced } from '../../app/types'; import { translate } from '../../helpers/l10n'; export interface QualityGateStatusCondition { @@ -32,7 +31,7 @@ export interface QualityGateStatusCondition { // long name to not mix with Condition from /app/types.ts export interface QualityGateStatusConditionEnhanced extends QualityGateStatusCondition { - measure: MeasureEnhanced; + measure: T.MeasureEnhanced; } export const METRICS = [ |