aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/overview/components
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/overview/components
parenta9c22c1185c5fd8c8dc4c9388f4a3b967e3f463d (diff)
downloadsonarqube-41c98779d38bda9fdfdca182a5f20c73fcff9a84.tar.gz
sonarqube-41c98779d38bda9fdfdca182a5f20c73fcff9a84.zip
create global type definitions (#1017)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/overview/components')
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/App.tsx9
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx9
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx13
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/SonarCloudEmptyOverview.tsx11
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx15
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/__tests__/SonarCloudEmptyOverview-test.tsx3
10 files changed, 33 insertions, 43 deletions
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',