aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/projectActivity
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2017-08-14 15:15:26 +0200
committerGitHub <noreply@github.com>2017-08-14 15:15:26 +0200
commit90306cb436e4fadceda6c106adc407618674f0d0 (patch)
tree4884373f2827b3fb59adb4516aa63bc4c4b1ae47 /server/sonar-web/src/main/js/apps/projectActivity
parentffff02cbed3e5f94bbf0c1718425d66e19ac3901 (diff)
downloadsonarqube-90306cb436e4fadceda6c106adc407618674f0d0.tar.gz
sonarqube-90306cb436e4fadceda6c106adc407618674f0d0.zip
comment flow annotations (#2335)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/projectActivity')
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/actions.js18
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/Event.js16
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/EventInner.js4
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/Events.js6
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/GraphHistory.js20
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/GraphsHistory.js18
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendCustom.js6
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendItem.js6
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendStatic.js4
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltips.js8
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContent.js4
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentCoverage.js12
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentDuplication.js12
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentEvents.js6
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentIssues.js6
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/GraphsZoom.js6
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js28
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js8
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js6
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.js58
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityDateInput.js12
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityEventSelectOption.js12
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityEventSelectValue.js6
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.js40
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphsHeader.js8
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFooter.js8
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.js10
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddEventForm.js18
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddGraphMetric.js18
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.js18
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveAnalysisForm.js16
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.js14
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/types.js14
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/utils.js109
34 files changed, 329 insertions, 226 deletions
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/actions.js b/server/sonar-web/src/main/js/apps/projectActivity/actions.js
index db482073f4e..97229ce74c3 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/actions.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/actions.js
@@ -18,10 +18,12 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
// @flow
-import type { Event } from './types';
-import type { State } from './components/ProjectActivityAppContainer';
+/*:: import type { Event } from './types'; */
+/*:: import type { State } from './components/ProjectActivityAppContainer'; */
-export const addCustomEvent = (analysis: string, event: Event) => (state: State) => ({
+export const addCustomEvent = (analysis /*: string */, event /*: Event */) => (
+ state /*: State */
+) => ({
analyses: state.analyses.map(item => {
if (item.key !== analysis) {
return item;
@@ -30,7 +32,9 @@ export const addCustomEvent = (analysis: string, event: Event) => (state: State)
})
});
-export const deleteEvent = (analysis: string, event: string) => (state: State) => ({
+export const deleteEvent = (analysis /*: string */, event /*: string */) => (
+ state /*: State */
+) => ({
analyses: state.analyses.map(item => {
if (item.key !== analysis) {
return item;
@@ -42,7 +46,9 @@ export const deleteEvent = (analysis: string, event: string) => (state: State) =
})
});
-export const changeEvent = (analysis: string, event: Event) => (state: State) => ({
+export const changeEvent = (analysis /*: string */, event /*: Event */) => (
+ state /*: State */
+) => ({
analyses: state.analyses.map(item => {
if (item.key !== analysis) {
return item;
@@ -56,6 +62,6 @@ export const changeEvent = (analysis: string, event: Event) => (state: State) =>
})
});
-export const deleteAnalysis = (analysis: string) => (state: State) => ({
+export const deleteAnalysis = (analysis /*: string */) => (state /*: State */) => ({
analyses: state.analyses.filter(item => item.key !== analysis)
});
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js b/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js
index df9bb12f972..55251df9328 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js
@@ -24,8 +24,9 @@ import ChangeEventForm from './forms/ChangeEventForm';
import RemoveEventForm from './forms/RemoveEventForm';
import DeleteIcon from '../../../components/icons-components/DeleteIcon';
import ChangeIcon from '../../../components/icons-components/ChangeIcon';
-import type { Event as EventType } from '../types';
+/*:: import type { Event as EventType } from '../types'; */
+/*::
type Props = {
analysis: string,
canAdmin: boolean,
@@ -34,16 +35,19 @@ type Props = {
event: EventType,
isFirst: boolean
};
+*/
+/*::
type State = {
changing: boolean,
deleting: boolean
};
+*/
export default class Event extends React.PureComponent {
- mounted: boolean;
- props: Props;
- state: State = {
+ /*:: mounted: boolean; */
+ /*:: props: Props; */
+ state /*: State */ = {
changing: false,
deleting: false
};
@@ -56,7 +60,7 @@ export default class Event extends React.PureComponent {
this.mounted = false;
}
- startChanging = (e: MouseEvent) => {
+ startChanging = (e /*: MouseEvent */) => {
e.stopPropagation();
this.setState({ changing: true });
};
@@ -67,7 +71,7 @@ export default class Event extends React.PureComponent {
}
};
- startDeleting = (e: MouseEvent) => {
+ startDeleting = (e /*: MouseEvent */) => {
e.stopPropagation();
this.setState({ deleting: true });
};
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/EventInner.js b/server/sonar-web/src/main/js/apps/projectActivity/components/EventInner.js
index 15e53e3a994..bdd3dd81fd1 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/EventInner.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/EventInner.js
@@ -22,9 +22,9 @@ import React from 'react';
import ProjectEventIcon from '../../../components/icons-components/ProjectEventIcon';
import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin';
import { translate } from '../../../helpers/l10n';
-import type { Event as EventType } from '../types';
+/*:: import type { Event as EventType } from '../types'; */
-export default function EventInner(props: { event: EventType }) {
+export default function EventInner(props /*: { event: EventType } */) {
const { event } = props;
return (
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/Events.js b/server/sonar-web/src/main/js/apps/projectActivity/components/Events.js
index 5e8aa73566b..b68e776f112 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/Events.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/Events.js
@@ -21,8 +21,9 @@
import React from 'react';
import { sortBy } from 'lodash';
import Event from './Event';
-import type { Event as EventType } from '../types';
+/*:: import type { Event as EventType } from '../types'; */
+/*::
type Props = {
analysis?: string,
canAdmin?: boolean,
@@ -31,8 +32,9 @@ type Props = {
events: Array<EventType>,
isFirst?: boolean
};
+*/
-export default function Events(props: Props) {
+export default function Events(props /*: Props */) {
const sortedEvents = sortBy(
props.events,
// versions last
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphHistory.js b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphHistory.js
index 64cbfe5d0ab..b3cf468b3f7 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphHistory.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphHistory.js
@@ -24,9 +24,10 @@ import GraphsTooltips from './GraphsTooltips';
import GraphsLegendCustom from './GraphsLegendCustom';
import GraphsLegendStatic from './GraphsLegendStatic';
import { formatMeasure, getShortType } from '../../../helpers/measures';
-import type { Event, MeasureHistory } from '../types';
-import type { Serie } from '../../../components/charts/AdvancedTimeline';
+/*:: import type { Event, MeasureHistory } from '../types'; */
+/*:: import type { Serie } from '../../../components/charts/AdvancedTimeline'; */
+/*::
type Props = {
events: Array<Event>,
graph: string,
@@ -44,23 +45,30 @@ type Props = {
updateSelectedDate: (selectedDate: ?Date) => void,
updateTooltip: (selectedDate: ?Date) => void
};
+*/
+/*::
type State = {
tooltipIdx: ?number,
tooltipXPos: ?number
};
+*/
export default class GraphHistory extends React.PureComponent {
- props: Props;
- state: State = {
+ /*:: props: Props; */
+ state /*: State */ = {
tooltipIdx: null,
tooltipXPos: null
};
- formatValue = (tick: string | number) =>
+ formatValue = (tick /*: string | number */) =>
formatMeasure(tick, getShortType(this.props.metricsType));
- updateTooltip = (selectedDate: ?Date, tooltipXPos: ?number, tooltipIdx: ?number) => {
+ updateTooltip = (
+ selectedDate /*: ?Date */,
+ tooltipXPos /*: ?number */,
+ tooltipIdx /*: ?number */
+ ) => {
this.props.updateTooltip(selectedDate);
this.setState({ tooltipXPos, tooltipIdx });
};
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsHistory.js b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsHistory.js
index 3fae4284ddd..25247318719 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsHistory.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsHistory.js
@@ -23,9 +23,10 @@ import { isEqual, sortBy } from 'lodash';
import GraphHistory from './GraphHistory';
import { EVENT_TYPES, getSeriesMetricType, hasHistoryData, isCustomGraph } from '../utils';
import { translate } from '../../../helpers/l10n';
-import type { Analysis, MeasureHistory } from '../types';
-import type { Serie } from '../../../components/charts/AdvancedTimeline';
+/*:: import type { Analysis, MeasureHistory } from '../types'; */
+/*:: import type { Serie } from '../../../components/charts/AdvancedTimeline'; */
+/*::
type Props = {
analyses: Array<Analysis>,
eventFilter: string,
@@ -42,23 +43,26 @@ type Props = {
updateGraphZoom: (from: ?Date, to: ?Date) => void,
updateSelectedDate: (selectedDate: ?Date) => void
};
+*/
+/*::
type State = {
selectedDate?: ?Date
};
+*/
export default class GraphsHistory extends React.PureComponent {
- props: Props;
- state: State;
+ /*:: props: Props; */
+ /*:: state: State; */
- constructor(props: Props) {
+ constructor(props /*: Props */) {
super(props);
this.state = {
selectedDate: props.selectedDate
};
}
- componentWillReceiveProps(nextProps: Props) {
+ componentWillReceiveProps(nextProps /*: Props */) {
if (!isEqual(nextProps.selectedDate, this.props.selectedDate)) {
this.setState({ selectedDate: nextProps.selectedDate });
}
@@ -102,7 +106,7 @@ export default class GraphsHistory extends React.PureComponent {
return [];
};
- updateTooltip = (selectedDate: ?Date) => this.setState({ selectedDate });
+ updateTooltip = (selectedDate /*: ?Date */) => this.setState({ selectedDate });
render() {
const { graph, series } = this.props;
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendCustom.js b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendCustom.js
index 018565d2e9c..3130d415397 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendCustom.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendCustom.js
@@ -23,14 +23,16 @@ import GraphsLegendItem from './GraphsLegendItem';
import Tooltip from '../../../components/controls/Tooltip';
import { hasDataValues } from '../utils';
import { translate } from '../../../helpers/l10n';
-import type { Serie } from '../../../components/charts/AdvancedTimeline';
+/*:: import type { Serie } from '../../../components/charts/AdvancedTimeline'; */
+/*::
type Props = {
removeMetric: string => void,
series: Array<Serie & { translatedName: string }>
};
+*/
-export default function GraphsLegendCustom({ removeMetric, series }: Props) {
+export default function GraphsLegendCustom({ removeMetric, series } /*: Props */) {
return (
<div className="project-activity-graph-legends">
{series.map((serie, idx) => {
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendItem.js b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendItem.js
index a458455a85c..3d7e16fad8b 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendItem.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendItem.js
@@ -24,6 +24,7 @@ import AlertWarnIcon from '../../../components/icons-components/AlertWarnIcon';
import ChartLegendIcon from '../../../components/icons-components/ChartLegendIcon';
import CloseIcon from '../../../components/icons-components/CloseIcon';
+/*::
type Props = {
className?: string,
metric: string,
@@ -32,11 +33,12 @@ type Props = {
style: string,
removeMetric?: string => void
};
+*/
export default class GraphsLegendItem extends React.PureComponent {
- props: Props;
+ /*:: props: Props; */
- handleClick = (e: Event) => {
+ handleClick = (e /*: Event */) => {
e.preventDefault();
if (this.props.removeMetric) {
this.props.removeMetric(this.props.metric);
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendStatic.js b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendStatic.js
index c48119607cf..2b8c85ed7b9 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendStatic.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendStatic.js
@@ -21,11 +21,13 @@
import React from 'react';
import GraphsLegendItem from './GraphsLegendItem';
+/*::
type Props = {
series: Array<{ name: string, translatedName: string }>
};
+*/
-export default function GraphsLegendStatic({ series }: Props) {
+export default function GraphsLegendStatic({ series } /*: Props */) {
return (
<div className="project-activity-graph-legends">
{series.map((serie, idx) =>
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltips.js b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltips.js
index a64755f5b64..4eb0e719a28 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltips.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltips.js
@@ -27,9 +27,10 @@ import GraphsTooltipsContentCoverage from './GraphsTooltipsContentCoverage';
import GraphsTooltipsContentDuplication from './GraphsTooltipsContentDuplication';
import GraphsTooltipsContentIssues from './GraphsTooltipsContentIssues';
import { DEFAULT_GRAPH } from '../utils';
-import type { Event, MeasureHistory } from '../types';
-import type { Serie } from '../../../components/charts/AdvancedTimeline';
+/*:: import type { Event, MeasureHistory } from '../types'; */
+/*:: import type { Serie } from '../../../components/charts/AdvancedTimeline'; */
+/*::
type Props = {
events: Array<Event>,
formatValue: (number | string) => string,
@@ -41,11 +42,12 @@ type Props = {
tooltipIdx: number,
tooltipPos: number
};
+*/
const TOOLTIP_WIDTH = 250;
export default class GraphsTooltips extends React.PureComponent {
- props: Props;
+ /*:: props: Props; */
renderContent() {
const { tooltipIdx } = this.props;
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContent.js b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContent.js
index 288bc539b18..369482b4fbd 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContent.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContent.js
@@ -22,14 +22,16 @@ import React from 'react';
import classNames from 'classnames';
import ChartLegendIcon from '../../../components/icons-components/ChartLegendIcon';
+/*::
type Props = {
name: string,
style: string,
translatedName: string,
value: string
};
+*/
-export default function GraphsTooltipsContent({ name, style, translatedName, value }: Props) {
+export default function GraphsTooltipsContent({ name, style, translatedName, value } /*: Props */) {
return (
<tr key={name} className="project-activity-graph-tooltip-line">
<td className="thin">
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentCoverage.js b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentCoverage.js
index 7ada640c64f..77c630376f7 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentCoverage.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentCoverage.js
@@ -21,19 +21,19 @@
import React from 'react';
import { formatMeasure } from '../../../helpers/measures';
import { translate } from '../../../helpers/l10n';
-import type { MeasureHistory } from '../types';
+/*:: import type { MeasureHistory } from '../types'; */
+/*::
type Props = {
addSeparator: boolean,
measuresHistory: Array<MeasureHistory>,
tooltipIdx: number
};
+*/
-export default function GraphsTooltipsContentCoverage({
- addSeparator,
- measuresHistory,
- tooltipIdx
-}: Props) {
+export default function GraphsTooltipsContentCoverage(
+ { addSeparator, measuresHistory, tooltipIdx } /*: Props */
+) {
const uncovered = measuresHistory.find(measure => measure.metric === 'uncovered_lines');
const coverage = measuresHistory.find(measure => measure.metric === 'coverage');
if (!uncovered || !uncovered.history[tooltipIdx] || !coverage || !coverage.history[tooltipIdx]) {
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentDuplication.js b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentDuplication.js
index ed613969195..3fb31334c8b 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentDuplication.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentDuplication.js
@@ -21,19 +21,19 @@
import React from 'react';
import { formatMeasure } from '../../../helpers/measures';
import { translate } from '../../../helpers/l10n';
-import type { MeasureHistory } from '../types';
+/*:: import type { MeasureHistory } from '../types'; */
+/*::
type Props = {
addSeparator: boolean,
measuresHistory: Array<MeasureHistory>,
tooltipIdx: number
};
+*/
-export default function GraphsTooltipsContentDuplication({
- addSeparator,
- measuresHistory,
- tooltipIdx
-}: Props) {
+export default function GraphsTooltipsContentDuplication(
+ { addSeparator, measuresHistory, tooltipIdx } /*: Props */
+) {
const duplicationDensity = measuresHistory.find(
measure => measure.metric === 'duplicated_lines_density'
);
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentEvents.js b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentEvents.js
index d23ac08368f..675e6382be8 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentEvents.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentEvents.js
@@ -21,14 +21,16 @@
import React from 'react';
import ProjectEventIcon from '../../../components/icons-components/ProjectEventIcon';
import { translate } from '../../../helpers/l10n';
-import type { Event } from '../types';
+/*:: import type { Event } from '../types'; */
+/*::
type Props = {
addSeparator: boolean,
events: Array<Event>
};
+*/
-export default function GraphsTooltipsContentEvents({ addSeparator, events }: Props) {
+export default function GraphsTooltipsContentEvents({ addSeparator, events } /*: Props */) {
return (
<tbody>
{addSeparator &&
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentIssues.js b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentIssues.js
index cad11cf2085..bbe85d7a25f 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentIssues.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentIssues.js
@@ -22,8 +22,9 @@ import React from 'react';
import classNames from 'classnames';
import ChartLegendIcon from '../../../components/icons-components/ChartLegendIcon';
import Rating from '../../../components/ui/Rating';
-import type { MeasureHistory } from '../types';
+/*:: import type { MeasureHistory } from '../types'; */
+/*::
type Props = {
measuresHistory: Array<MeasureHistory>,
name: string,
@@ -32,6 +33,7 @@ type Props = {
translatedName: string,
value: string
};
+*/
const METRIC_RATING = {
bugs: 'reliability_rating',
@@ -39,7 +41,7 @@ const METRIC_RATING = {
code_smells: 'sqale_rating'
};
-export default function GraphsTooltipsContentIssues(props: Props) {
+export default function GraphsTooltipsContentIssues(props /*: Props */) {
const rating = props.measuresHistory.find(
measure => measure.metric === METRIC_RATING[props.name]
);
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsZoom.js b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsZoom.js
index 3acdafc99ad..810fcf755fd 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsZoom.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsZoom.js
@@ -22,8 +22,9 @@ import React from 'react';
import { AutoSizer } from 'react-virtualized';
import ZoomTimeLine from '../../../components/charts/ZoomTimeLine';
import { hasHistoryData } from '../utils';
-import type { Serie } from '../../../components/charts/AdvancedTimeline';
+/*:: import type { Serie } from '../../../components/charts/AdvancedTimeline'; */
+/*::
type Props = {
graphEndDate: ?Date,
graphStartDate: ?Date,
@@ -34,8 +35,9 @@ type Props = {
showAreas?: boolean,
updateGraphZoom: (from: ?Date, to: ?Date) => void
};
+*/
-export default function GraphsZoom(props: Props) {
+export default function GraphsZoom(props /*: Props */) {
const { loading } = props;
if (loading || !hasHistoryData(props.series)) {
return null;
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js
index a7e94e0ef84..ffb96775dc9 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js
@@ -30,9 +30,10 @@ import {
getAnalysesByVersionByDay,
selectedDateQueryChanged
} from '../utils';
-import type { RawQuery } from '../../../helpers/query';
-import type { Analysis, Query } from '../types';
+/*:: import type { RawQuery } from '../../../helpers/query'; */
+/*:: import type { Analysis, Query } from '../types'; */
+/*::
type Props = {
addCustomEvent: (analysis: string, name: string, category?: string) => Promise<*>,
addVersion: (analysis: string, version: string) => Promise<*>,
@@ -46,16 +47,17 @@ type Props = {
loading: boolean,
project: { qualifier: string },
query: Query,
- updateQuery: RawQuery => void
+ updateQuery: Object => void
};
+*/
export default class ProjectActivityAnalysesList extends React.PureComponent {
- analyses: HTMLCollection<HTMLElement>;
- badges: HTMLCollection<HTMLElement>;
- props: Props;
- scrollContainer: HTMLElement;
+ /*:: analyses: HTMLCollection<HTMLElement>; */
+ /*:: badges: HTMLCollection<HTMLElement>; */
+ /*:: props: Props; */
+ /*:: scrollContainer: HTMLElement; */
- constructor(props: Props) {
+ constructor(props /*: Props */) {
super(props);
this.handleScroll = throttle(this.handleScroll, 20);
}
@@ -65,7 +67,7 @@ export default class ProjectActivityAnalysesList extends React.PureComponent {
this.analyses = document.getElementsByClassName('project-activity-analysis');
}
- componentDidUpdate(prevProps: Props) {
+ componentDidUpdate(prevProps /*: Props */) {
if (!this.scrollContainer) {
return;
}
@@ -82,7 +84,7 @@ export default class ProjectActivityAnalysesList extends React.PureComponent {
handleScroll = () => this.updateStickyBadges(true);
- resetScrollTop = (newScrollTop: number, forceBadgeAlignement?: boolean) => {
+ resetScrollTop = (newScrollTop /*: number */, forceBadgeAlignement /*: ?boolean */) => {
this.scrollContainer.scrollTop = newScrollTop;
for (let i = 1; i < this.badges.length; i++) {
this.badges[i].removeAttribute('originOffsetTop');
@@ -91,7 +93,7 @@ export default class ProjectActivityAnalysesList extends React.PureComponent {
this.updateStickyBadges(forceBadgeAlignement);
};
- scrollToDate = (targetDate: ?Date) => {
+ scrollToDate = (targetDate /*: ?Date */) => {
if (!this.scrollContainer || !targetDate) {
return;
}
@@ -109,7 +111,7 @@ export default class ProjectActivityAnalysesList extends React.PureComponent {
}
};
- updateStickyBadges = (forceBadgeAlignement?: boolean) => {
+ updateStickyBadges = (forceBadgeAlignement /*: ?boolean */) => {
if (this.scrollContainer && this.badges) {
const scrollTop = this.scrollContainer.scrollTop;
if (scrollTop != null) {
@@ -138,7 +140,7 @@ export default class ProjectActivityAnalysesList extends React.PureComponent {
}
};
- updateSelectedDate = (date: Date) => this.props.updateQuery({ selectedDate: date });
+ updateSelectedDate = (date /*: Date */) => this.props.updateQuery({ selectedDate: date });
render() {
const byVersionByDay = getAnalysesByVersionByDay(this.props.analyses, this.props.query);
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js
index 72067b95261..f52a59b5943 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js
@@ -25,8 +25,9 @@ import AddEventForm from './forms/AddEventForm';
import RemoveAnalysisForm from './forms/RemoveAnalysisForm';
import FormattedDate from '../../../components/ui/FormattedDate';
import { translate } from '../../../helpers/l10n';
-import type { Analysis } from '../types';
+/*:: import type { Analysis } from '../types'; */
+/*::
type Props = {
addCustomEvent: (analysis: string, name: string, category?: string) => Promise<*>,
addVersion: (analysis: string, version: string) => Promise<*>,
@@ -40,13 +41,14 @@ type Props = {
selected: boolean,
updateSelectedDate: Date => void
};
+*/
export default class ProjectActivityAnalysis extends React.PureComponent {
- props: Props;
+ /*:: props: Props; */
handleClick = () => this.props.updateSelectedDate(this.props.analysis.date);
- stopPropagation = (e: Event) => e.stopPropagation();
+ stopPropagation = (e /*: Event */) => e.stopPropagation();
render() {
const { analysis, isFirst, canAdmin } = this.props;
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js
index fb825ed45ad..717678a0561 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js
@@ -26,8 +26,9 @@ import ProjectActivityAnalysesList from './ProjectActivityAnalysesList';
import ProjectActivityGraphs from './ProjectActivityGraphs';
import { translate } from '../../../helpers/l10n';
import './projectActivity.css';
-import type { Analysis, MeasureHistory, Metric, Query } from '../types';
+/*:: import type { Analysis, MeasureHistory, Metric, Query } from '../types'; */
+/*::
type Props = {
addCustomEvent: (analysis: string, name: string, category?: string) => Promise<*>,
addVersion: (analysis: string, version: string) => Promise<*>,
@@ -49,8 +50,9 @@ type Props = {
query: Query,
updateQuery: (newQuery: Query) => void
};
+*/
-export default function ProjectActivityApp(props: Props) {
+export default function ProjectActivityApp(props /*: Props */) {
const { analyses, measuresHistory, query } = props;
const { configuration } = props.project;
const canAdmin = configuration ? configuration.showHistory : false;
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.js
index 0ca8c21f1a6..8572a4be9b5 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.js
@@ -39,9 +39,10 @@ import {
serializeQuery,
serializeUrlQuery
} from '../utils';
-import type { RawQuery } from '../../../helpers/query';
-import type { Analysis, MeasureHistory, Metric, Paging, Query } from '../types';
+/*:: import type { RawQuery } from '../../../helpers/query'; */
+/*:: import type { Analysis, MeasureHistory, Metric, Paging, Query } from '../types'; */
+/*::
type Props = {
location: { pathname: string, query: RawQuery },
project: {
@@ -55,7 +56,9 @@ type Props = {
replace: ({ pathname: string, query?: RawQuery }) => void
}
};
+*/
+/*::
export type State = {
analyses: Array<Analysis>,
analysesLoading: boolean,
@@ -66,13 +69,14 @@ export type State = {
paging?: Paging,
query: Query
};
+*/
class ProjectActivityAppContainer extends React.PureComponent {
- mounted: boolean;
- props: Props;
- state: State;
+ /*:: mounted: boolean; */
+ /*:: props: Props; */
+ /*:: state: State; */
- constructor(props: Props) {
+ constructor(props /*: Props */) {
super(props);
this.state = {
analyses: [],
@@ -105,7 +109,7 @@ class ProjectActivityAppContainer extends React.PureComponent {
}
}
- componentWillReceiveProps(nextProps: Props) {
+ componentWillReceiveProps(nextProps /*: Props */) {
if (nextProps.location.query !== this.props.location.query) {
const query = parseQuery(nextProps.location.query);
if (query.graph !== this.state.query.graph || customMetricsChanged(this.state.query, query)) {
@@ -125,7 +129,7 @@ class ProjectActivityAppContainer extends React.PureComponent {
elem && elem.classList.remove('dashboard-page');
}
- addCustomEvent = (analysis: string, name: string, category?: string): Promise<*> =>
+ addCustomEvent = (analysis /*: string */, name /*: string */, category /*: ?string */) =>
api
.createEvent(analysis, name, category)
.then(
@@ -133,10 +137,10 @@ class ProjectActivityAppContainer extends React.PureComponent {
this.mounted && this.setState(actions.addCustomEvent(analysis, event))
);
- addVersion = (analysis: string, version: string): Promise<*> =>
+ addVersion = (analysis /*: string */, version /*: string */) =>
this.addCustomEvent(analysis, version, 'VERSION');
- changeEvent = (event: string, name: string): Promise<*> =>
+ changeEvent = (event /*: string */, name /*: string */) =>
api
.changeEvent(event, name)
.then(
@@ -144,7 +148,7 @@ class ProjectActivityAppContainer extends React.PureComponent {
this.mounted && this.setState(actions.changeEvent(analysis, event))
);
- deleteAnalysis = (analysis: string): Promise<*> =>
+ deleteAnalysis = (analysis /*: string */) =>
api.deleteAnalysis(analysis).then(() => {
if (this.mounted) {
this.updateGraphData(this.state.query.graph, this.state.query.customMetrics);
@@ -152,19 +156,19 @@ class ProjectActivityAppContainer extends React.PureComponent {
}
});
- deleteEvent = (analysis: string, event: string): Promise<*> =>
+ deleteEvent = (analysis /*: string */, event /*: string */) =>
api
.deleteEvent(event)
.then(() => this.mounted && this.setState(actions.deleteEvent(analysis, event)));
fetchActivity = (
- project: string,
- p: number,
- ps: number,
- additional?: {
+ project /*: string */,
+ p /*: number */,
+ ps /*: number */,
+ additional /*: ?{
[string]: string
- }
- ): Promise<{ analyses: Array<Analysis>, paging: Paging }> => {
+ } */
+ ) => {
const parameters = { project, p, ps };
return api
.getProjectActivity({ ...parameters, ...additional })
@@ -174,7 +178,7 @@ class ProjectActivityAppContainer extends React.PureComponent {
}));
};
- fetchMeasuresHistory = (metrics: Array<string>): Promise<Array<MeasureHistory>> => {
+ fetchMeasuresHistory = (metrics /*: Array<string> */) => {
if (metrics.length <= 0) {
return Promise.resolve([]);
}
@@ -191,12 +195,12 @@ class ProjectActivityAppContainer extends React.PureComponent {
);
};
- fetchMetrics = (): Promise<Array<Metric>> => getMetrics().catch(throwGlobalError);
+ fetchMetrics = () => getMetrics().catch(throwGlobalError);
loadAllActivities = (
- project: string,
- prevResult?: { analyses: Array<Analysis>, paging: Paging }
- ): Promise<{ analyses: Array<Analysis>, paging: Paging }> => {
+ project /*: string */,
+ prevResult /*: ?{ analyses: Array<Analysis>, paging: Paging } */
+ ) => {
if (
prevResult &&
prevResult.paging.pageIndex * prevResult.paging.pageSize >= prevResult.paging.total
@@ -215,7 +219,7 @@ class ProjectActivityAppContainer extends React.PureComponent {
});
};
- firstLoadData(query: Query) {
+ firstLoadData(query /*: Query */) {
const graphMetrics = getHistoryMetrics(query.graph, query.customMetrics);
Promise.all([
this.fetchActivity(query.project, 1, 100, serializeQuery(query)),
@@ -246,15 +250,15 @@ class ProjectActivityAppContainer extends React.PureComponent {
});
}
- updateGraphData = (graph: string, customMetrics: Array<string>) => {
+ updateGraphData = (graph /*: string */, customMetrics /*: Array<string> */) => {
const graphMetrics = getHistoryMetrics(graph, customMetrics);
this.setState({ graphLoading: true });
- this.fetchMeasuresHistory(graphMetrics).then((measuresHistory: Array<MeasureHistory>) =>
+ this.fetchMeasuresHistory(graphMetrics).then((measuresHistory /*: Array<MeasureHistory> */) =>
this.setState({ graphLoading: false, measuresHistory })
);
};
- updateQuery = (newQuery: Query) => {
+ updateQuery = (newQuery /*: Query */) => {
const query = serializeUrlQuery({
...this.state.query,
...newQuery
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityDateInput.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityDateInput.js
index 3a0212037ac..1ece1355970 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityDateInput.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityDateInput.js
@@ -23,24 +23,26 @@ import moment from 'moment';
import DateInput from '../../../components/controls/DateInput';
import { parseAsDate } from '../../../helpers/query';
import { translate } from '../../../helpers/l10n';
-import type { RawQuery } from '../../../helpers/query';
+/*:: import type { RawQuery } from '../../../helpers/query'; */
+/*::
type Props = {
from: ?Date,
to: ?Date,
onChange: RawQuery => void
};
+*/
export default class ProjectActivityDateInput extends React.PureComponent {
- props: Props;
+ /*:: props: Props; */
- handleFromDateChange = (from: string) => this.props.onChange({ from: parseAsDate(from) });
+ handleFromDateChange = (from /*: string */) => this.props.onChange({ from: parseAsDate(from) });
- handleToDateChange = (to: string) => this.props.onChange({ to: parseAsDate(to) });
+ handleToDateChange = (to /*: string */) => this.props.onChange({ to: parseAsDate(to) });
handleResetClick = () => this.props.onChange({ from: null, to: null });
- formatDate = (date: ?Date) => (date ? moment(date).format('YYYY-MM-DD') : null);
+ formatDate = (date /*: ?Date */) => (date ? moment(date).format('YYYY-MM-DD') : null);
render() {
return (
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityEventSelectOption.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityEventSelectOption.js
index a77c653b147..cac4aae8a01 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityEventSelectOption.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityEventSelectOption.js
@@ -21,8 +21,11 @@
import React from 'react';
import ProjectEventIcon from '../../../components/icons-components/ProjectEventIcon';
+/*::
export type Option = { label: string, value: string };
+*/
+/*::
type Props = {
option: Option,
children?: Element | Text,
@@ -31,21 +34,22 @@ type Props = {
onFocus: (Option, MouseEvent) => void,
onSelect: (Option, MouseEvent) => void
};
+*/
export default class ProjectActivityEventSelectOption extends React.PureComponent {
- props: Props;
+ /*:: props: Props; */
- handleMouseDown = (event: MouseEvent) => {
+ handleMouseDown = (event /*: MouseEvent */) => {
event.preventDefault();
event.stopPropagation();
this.props.onSelect(this.props.option, event);
};
- handleMouseEnter = (event: MouseEvent) => {
+ handleMouseEnter = (event /*: MouseEvent */) => {
this.props.onFocus(this.props.option, event);
};
- handleMouseMove = (event: MouseEvent) => {
+ handleMouseMove = (event /*: MouseEvent */) => {
if (this.props.isFocused) {
return;
}
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityEventSelectValue.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityEventSelectValue.js
index 08665bf06e4..e06d0827f8d 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityEventSelectValue.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityEventSelectValue.js
@@ -20,14 +20,16 @@
//@flow
import React from 'react';
import ProjectEventIcon from '../../../components/icons-components/ProjectEventIcon';
-import type { Option } from './ProjectActivityEventSelectOption';
+/*:: import type { Option } from './ProjectActivityEventSelectOption'; */
+/*::
type Props = {
value: Option,
children?: Element | Text
};
+*/
-export default function ProjectActivityEventSelectValue(props: Props) {
+export default function ProjectActivityEventSelectValue(props /*: Props */) {
const { value } = props;
return (
<div className="Select-value" title={value.label}>
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.js
index 08feb4a5953..e97d205640e 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.js
@@ -33,10 +33,11 @@ import {
isCustomGraph,
splitSeriesInGraphs
} from '../utils';
-import type { RawQuery } from '../../../helpers/query';
-import type { Analysis, MeasureHistory, Metric, Query } from '../types';
-import type { Serie } from '../../../components/charts/AdvancedTimeline';
+/*:: import type { RawQuery } from '../../../helpers/query'; */
+/*:: import type { Analysis, MeasureHistory, Metric, Query } from '../types'; */
+/*:: import type { Serie } from '../../../components/charts/AdvancedTimeline'; */
+/*::
type Props = {
analyses: Array<Analysis>,
leakPeriodDate: Date,
@@ -46,22 +47,25 @@ type Props = {
query: Query,
updateQuery: RawQuery => void
};
+*/
+/*::
type State = {
graphStartDate: ?Date,
graphEndDate: ?Date,
series: Array<Serie>,
graphs: Array<Array<Serie>>
};
+*/
const MAX_GRAPH_NB = 2;
const MAX_SERIES_PER_GRAPH = 3;
export default class ProjectActivityGraphs extends React.PureComponent {
- props: Props;
- state: State;
+ /*:: props: Props; */
+ /*:: state: State; */
- constructor(props: Props) {
+ constructor(props /*: Props */) {
super(props);
const series = generateSeries(
props.measuresHistory,
@@ -77,7 +81,7 @@ export default class ProjectActivityGraphs extends React.PureComponent {
this.updateQueryDateRange = debounce(this.updateQueryDateRange, 500);
}
- componentWillReceiveProps(nextProps: Props) {
+ componentWillReceiveProps(nextProps /*: Props */) {
let newSeries;
let newGraphs;
if (
@@ -109,10 +113,10 @@ export default class ProjectActivityGraphs extends React.PureComponent {
}
getStateZoomDates = (
- props: ?Props,
- nextProps: Props,
- newSeries: ?Array<Serie>
- ): ?{ graphEndDate: ?Date, graphStartDate: ?Date } => {
+ props /*: ?Props */,
+ nextProps /*: Props */,
+ newSeries /*: ?Array<Serie> */
+ ) => {
const newDates = { from: nextProps.query.from || null, to: nextProps.query.to || null };
if (!props || datesQueryChanged(props.query, nextProps.query)) {
return { graphEndDate: newDates.to, graphStartDate: newDates.from };
@@ -132,7 +136,7 @@ export default class ProjectActivityGraphs extends React.PureComponent {
}
};
- getMetricsTypeFilter = (): ?Array<string> => {
+ getMetricsTypeFilter = () => {
if (this.state.graphs.length < MAX_GRAPH_NB) {
return null;
}
@@ -141,19 +145,19 @@ export default class ProjectActivityGraphs extends React.PureComponent {
.map(graph => graph[0].type);
};
- addCustomMetric = (metric: string) => {
+ addCustomMetric = (metric /*: string */) => {
const customMetrics = [...this.props.query.customMetrics, metric];
saveCustomGraph(customMetrics);
this.props.updateQuery({ customMetrics });
};
- removeCustomMetric = (removedMetric: string) => {
+ removeCustomMetric = (removedMetric /*: string */) => {
const customMetrics = this.props.query.customMetrics.filter(metric => metric !== removedMetric);
saveCustomGraph(customMetrics);
this.props.updateQuery({ customMetrics });
};
- updateGraph = (graph: string) => {
+ updateGraph = (graph /*: string */) => {
saveGraph(graph);
if (isCustomGraph(graph) && this.props.query.customMetrics.length <= 0) {
this.props.updateQuery({ graph, customMetrics: getCustomGraph() });
@@ -162,7 +166,7 @@ export default class ProjectActivityGraphs extends React.PureComponent {
}
};
- updateGraphZoom = (graphStartDate: ?Date, graphEndDate: ?Date) => {
+ updateGraphZoom = (graphStartDate /*: ?Date */, graphEndDate /*: ?Date */) => {
if (graphEndDate != null && graphStartDate != null) {
const msDiff = Math.abs(graphEndDate.valueOf() - graphStartDate.valueOf());
// 12 hours minimum between the two dates
@@ -175,9 +179,9 @@ export default class ProjectActivityGraphs extends React.PureComponent {
this.updateQueryDateRange([graphStartDate, graphEndDate]);
};
- updateSelectedDate = (selectedDate: ?Date) => this.props.updateQuery({ selectedDate });
+ updateSelectedDate = (selectedDate /*: ?Date */) => this.props.updateQuery({ selectedDate });
- updateQueryDateRange = (dates: Array<?Date>) => {
+ updateQueryDateRange = (dates /*: Array<?Date> */) => {
if (dates[0] == null || dates[1] == null) {
this.props.updateQuery({ from: dates[0], to: dates[1] });
} else {
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphsHeader.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphsHeader.js
index 3b536c25956..f9f298e9ab3 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphsHeader.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphsHeader.js
@@ -23,8 +23,9 @@ import Select from 'react-select';
import AddGraphMetric from './forms/AddGraphMetric';
import { isCustomGraph, GRAPH_TYPES } from '../utils';
import { translate } from '../../../helpers/l10n';
-import type { Metric } from '../types';
+/*:: import type { Metric } from '../types'; */
+/*::
type Props = {
addCustomMetric: string => void,
graph: string,
@@ -33,11 +34,12 @@ type Props = {
selectedMetrics: Array<string>,
updateGraph: string => void
};
+*/
export default class ProjectActivityGraphsHeader extends React.PureComponent {
- props: Props;
+ /*:: props: Props; */
- handleGraphChange = (option: { value: string }) => {
+ handleGraphChange = (option /*: { value: string } */) => {
if (option.value !== this.props.graph) {
this.props.updateGraph(option.value);
}
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFooter.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFooter.js
index 77428e38105..3ba5fd319a2 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFooter.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFooter.js
@@ -20,15 +20,19 @@
// @flow
import React from 'react';
import ListFooter from '../../../components/controls/ListFooter';
-import type { Paging } from '../types';
+/*:: import type { Paging } from '../types'; */
+/*::
type Props = {
analyses: Array<*>,
fetchMoreActivity: () => void,
paging?: Paging
};
+*/
-export default function ProjectActivityPageFooter({ analyses, fetchMoreActivity, paging }: Props) {
+export default function ProjectActivityPageFooter(
+ { analyses, fetchMoreActivity, paging } /*: Props */
+) {
if (!paging || analyses.length === 0) {
return null;
}
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.js
index 969af31ee63..57183279074 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.js
@@ -25,8 +25,9 @@ import ProjectActivityEventSelectValue from './ProjectActivityEventSelectValue';
import ProjectActivityDateInput from './ProjectActivityDateInput';
import { EVENT_TYPES, APPLICATION_EVENT_TYPES } from '../utils';
import { translate } from '../../../helpers/l10n';
-import type { RawQuery } from '../../../helpers/query';
+/*:: import type { RawQuery } from '../../../helpers/query'; */
+/*::
type Props = {
category?: string,
from: ?Date,
@@ -34,12 +35,13 @@ type Props = {
to: ?Date,
updateQuery: RawQuery => void
};
+*/
export default class ProjectActivityPageHeader extends React.PureComponent {
- options: Array<{ label: string, value: string }>;
- props: Props;
+ /*:: options: Array<{ label: string, value: string }>; */
+ /*:: props: Props; */
- handleCategoryChange = (option: ?{ value: string }) =>
+ handleCategoryChange = (option /*: ?{ value: string } */) =>
this.props.updateQuery({ category: option ? option.value : '' });
render() {
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddEventForm.js b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddEventForm.js
index bcfc6672789..62195f9d69d 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddEventForm.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddEventForm.js
@@ -21,24 +21,28 @@
import React from 'react';
import Modal from 'react-modal';
import { translate } from '../../../../helpers/l10n';
-import type { Analysis } from '../../types';
+/*:: import type { Analysis } from '../../types'; */
+/*::
type Props = {
addEvent: (analysis: string, name: string, category?: string) => Promise<*>,
analysis: Analysis,
addEventButtonText: string
};
+*/
+/*::
type State = {
open: boolean,
processing: boolean,
name: string
};
+*/
export default class AddEventForm extends React.PureComponent {
- mounted: boolean;
- props: Props;
- state: State = {
+ /*:: mounted: boolean; */
+ /*:: props: Props; */
+ state /*: State */ = {
open: false,
processing: false,
name: ''
@@ -52,7 +56,7 @@ export default class AddEventForm extends React.PureComponent {
this.mounted = false;
}
- openForm = (e: Event) => {
+ openForm = (e /*: Event */) => {
e.preventDefault();
e.stopPropagation();
if (this.mounted) {
@@ -66,7 +70,7 @@ export default class AddEventForm extends React.PureComponent {
}
};
- changeInput = (e: Object) => {
+ changeInput = (e /*: Object */) => {
if (this.mounted) {
this.setState({ name: e.target.value });
}
@@ -84,7 +88,7 @@ export default class AddEventForm extends React.PureComponent {
}
};
- handleSubmit = (e: Object) => {
+ handleSubmit = (e /*: Object */) => {
e.preventDefault();
this.setState({ processing: true });
this.props
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddGraphMetric.js b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddGraphMetric.js
index 3ab48063f12..7dec82030c7 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddGraphMetric.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddGraphMetric.js
@@ -29,8 +29,9 @@ import {
translate,
translateWithParameters
} from '../../../../helpers/l10n';
-import type { Metric } from '../../types';
+/*:: import type { Metric } from '../../types'; */
+/*::
type Props = {
addMetric: (metric: string) => void,
className?: string,
@@ -38,19 +39,22 @@ type Props = {
metricsTypeFilter: ?Array<string>,
selectedMetrics: Array<string>
};
+*/
+/*::
type State = {
open: boolean,
selectedMetric?: string
};
+*/
export default class AddGraphMetric extends React.PureComponent {
- props: Props;
- state: State = {
+ /*:: props: Props; */
+ state /*: State */ = {
open: false
};
- getMetricsOptions = (metricsTypeFilter: ?Array<string>) => {
+ getMetricsOptions = (metricsTypeFilter /*: ?Array<string> */) => {
return this.props.metrics
.filter(metric => {
if (
@@ -65,7 +69,7 @@ export default class AddGraphMetric extends React.PureComponent {
}
return true;
})
- .map((metric: Metric) => ({
+ .map((metric /*: Metric */) => ({
value: metric.key,
label: getLocalizedMetricName(metric)
}));
@@ -84,10 +88,10 @@ export default class AddGraphMetric extends React.PureComponent {
});
};
- handleChange = (option: { value: string, label: string }) =>
+ handleChange = (option /*: { value: string, label: string } */) =>
this.setState({ selectedMetric: option.value });
- handleSubmit = (e: Object) => {
+ handleSubmit = (e /*: Object */) => {
e.preventDefault();
if (this.state.selectedMetric) {
this.props.addMetric(this.state.selectedMetric);
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.js b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.js
index 40c19cba887..ffd358c47d9 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.js
@@ -21,26 +21,30 @@
import React from 'react';
import Modal from 'react-modal';
import { translate } from '../../../../helpers/l10n';
-import type { Event } from '../../types';
+/*:: import type { Event } from '../../types'; */
+/*::
type Props = {
changeEvent: (event: string, name: string) => Promise<*>,
changeEventButtonText: string,
event: Event,
onClose: () => void
};
+*/
+/*::
type State = {
processing: boolean,
name: string
};
+*/
export default class ChangeEventForm extends React.PureComponent {
- mounted: boolean;
- props: Props;
- state: State;
+ /*:: mounted: boolean; */
+ /*:: props: Props; */
+ /*:: state: State; */
- constructor(props: Props) {
+ constructor(props /*: Props */) {
super(props);
this.state = {
processing: false,
@@ -63,7 +67,7 @@ export default class ChangeEventForm extends React.PureComponent {
this.props.onClose();
};
- changeInput = (e: Object) => {
+ changeInput = (e /*: Object */) => {
if (this.mounted) {
this.setState({ name: e.target.value });
}
@@ -82,7 +86,7 @@ export default class ChangeEventForm extends React.PureComponent {
this.props.onClose();
};
- handleSubmit = (e: Object) => {
+ handleSubmit = (e /*: Object */) => {
e.preventDefault();
this.setState({ processing: true });
this.props
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveAnalysisForm.js b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveAnalysisForm.js
index d8a12f791c5..481f7f2be61 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveAnalysisForm.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveAnalysisForm.js
@@ -21,22 +21,26 @@
import React from 'react';
import Modal from 'react-modal';
import { translate } from '../../../../helpers/l10n';
-import type { Analysis } from '../../types';
+/*:: import type { Analysis } from '../../types'; */
+/*::
type Props = {
analysis: Analysis,
deleteAnalysis: (analysis: string) => Promise<*>
};
+*/
+/*::
type State = {
open: boolean,
processing: boolean
};
+*/
export default class RemoveAnalysisForm extends React.PureComponent {
- mounted: boolean;
- props: Props;
- state: State = {
+ /*:: mounted: boolean; */
+ /*:: props: Props; */
+ state /*: State */ = {
open: false,
processing: false
};
@@ -49,7 +53,7 @@ export default class RemoveAnalysisForm extends React.PureComponent {
this.mounted = false;
}
- openForm = (e: Event) => {
+ openForm = (e /*: Event */) => {
e.preventDefault();
e.stopPropagation();
if (this.mounted) {
@@ -75,7 +79,7 @@ export default class RemoveAnalysisForm extends React.PureComponent {
}
};
- handleSubmit = (e: Event) => {
+ handleSubmit = (e /*: Event */) => {
e.preventDefault();
this.setState({ processing: true });
this.props
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.js b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.js
index ac50df35dc7..3ba867116a5 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.js
@@ -21,8 +21,9 @@
import React from 'react';
import Modal from 'react-modal';
import { translate } from '../../../../helpers/l10n';
-import type { Event } from '../../types';
+/*:: import type { Event } from '../../types'; */
+/*::
type Props = {
analysis: string,
deleteEvent: (analysis: string, event: string) => Promise<*>,
@@ -31,15 +32,18 @@ type Props = {
removeEventQuestion: string,
onClose: () => void
};
+*/
+/*::
type State = {
processing: boolean
};
+*/
export default class RemoveEventForm extends React.PureComponent {
- mounted: boolean;
- props: Props;
- state: State = {
+ /*:: mounted: boolean; */
+ /*:: props: Props; */
+ state /*: State */ = {
processing: false
};
@@ -68,7 +72,7 @@ export default class RemoveEventForm extends React.PureComponent {
this.props.onClose();
};
- handleSubmit = (e: Object) => {
+ handleSubmit = (e /*: Object */) => {
e.preventDefault();
this.setState({ processing: true });
this.props
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/types.js b/server/sonar-web/src/main/js/apps/projectActivity/types.js
index ab6c9fa78a3..750518982d1 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/types.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/types.js
@@ -19,23 +19,32 @@
*/
// @flow
+/*::
export type Event = {
key: string,
name: string,
category: string,
description?: string
};
+*/
+/*::
export type Analysis = {
key: string,
date: Date,
events: Array<Event>
};
+*/
+/*::
export type HistoryItem = { date: Date, value: string };
+*/
+/*::
export type MeasureHistory = { metric: string, history: Array<HistoryItem> };
+*/
+/*::
export type Metric = {
custom?: boolean,
hidden?: boolean,
@@ -43,13 +52,17 @@ export type Metric = {
name: string,
type: string
};
+*/
+/*::
export type Paging = {
pageIndex: number,
pageSize: number,
total: number
};
+*/
+/*::
export type Query = {
category: string,
customMetrics: Array<string>,
@@ -59,3 +72,4 @@ export type Query = {
to?: Date,
selectedDate?: Date
};
+*/
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/utils.js b/server/sonar-web/src/main/js/apps/projectActivity/utils.js
index 7a126be384a..4e85eb3ced6 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/utils.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/utils.js
@@ -30,9 +30,9 @@ import {
serializeString
} from '../../helpers/query';
import { getLocalizedMetricName, translate } from '../../helpers/l10n';
-import type { Analysis, MeasureHistory, Metric, Query } from './types';
-import type { RawQuery } from '../../helpers/query';
-import type { Serie } from '../../components/charts/AdvancedTimeline';
+/*:: import type { Analysis, MeasureHistory, Metric, Query } from './types'; */
+/*:: import type { RawQuery } from '../../helpers/query'; */
+/*:: import type { Serie } from '../../components/charts/AdvancedTimeline'; */
export const EVENT_TYPES = ['VERSION', 'QUALITY_GATE', 'QUALITY_PROFILE', 'OTHER'];
export const APPLICATION_EVENT_TYPES = ['QUALITY_GATE', 'OTHER'];
@@ -53,34 +53,36 @@ export const GRAPHS_METRICS = {
duplications: GRAPHS_METRICS_DISPLAYED['duplications'].concat(['duplicated_lines_density'])
};
-export const activityQueryChanged = (prevQuery: Query, nextQuery: Query): boolean =>
+export const activityQueryChanged = (prevQuery /*: Query */, nextQuery /*: Query */) =>
prevQuery.category !== nextQuery.category || datesQueryChanged(prevQuery, nextQuery);
-export const customMetricsChanged = (prevQuery: Query, nextQuery: Query): boolean =>
+export const customMetricsChanged = (prevQuery /*: Query */, nextQuery /*: Query */) =>
!isEqual(prevQuery.customMetrics, nextQuery.customMetrics);
-export const datesQueryChanged = (prevQuery: Query, nextQuery: Query): boolean =>
+export const datesQueryChanged = (prevQuery /*: Query */, nextQuery /*: Query */) =>
!isEqual(prevQuery.from, nextQuery.from) || !isEqual(prevQuery.to, nextQuery.to);
-export const hasDataValues = (serie: Serie) => serie.data.some(point => point.y || point.y === 0);
+export const hasDataValues = (serie /*: Serie */) =>
+ serie.data.some(point => point.y || point.y === 0);
-export const hasHistoryData = (series: Array<Serie>) =>
+export const hasHistoryData = (series /*: Array<Serie> */) =>
series.some(serie => serie.data && serie.data.length > 1);
-export const hasHistoryDataValue = (series: Array<Serie>) =>
+export const hasHistoryDataValue = (series /*: Array<Serie> */) =>
series.some(serie => serie.data && serie.data.length > 1 && hasDataValues(serie));
-export const historyQueryChanged = (prevQuery: Query, nextQuery: Query): boolean =>
- prevQuery.graph !== nextQuery.graph;
+export function historyQueryChanged(prevQuery /*: Query */, nextQuery /*: Query */) /*: boolean */ {
+ return prevQuery.graph !== nextQuery.graph;
+}
-export const isCustomGraph = (graph: string) => graph === 'custom';
+export const isCustomGraph = (graph /*: string */) => graph === 'custom';
-export const selectedDateQueryChanged = (prevQuery: Query, nextQuery: Query): boolean =>
+export const selectedDateQueryChanged = (prevQuery /*: Query */, nextQuery /*: Query */) =>
!isEqual(prevQuery.selectedDate, nextQuery.selectedDate);
export const generateCoveredLinesMetric = (
- uncoveredLines: MeasureHistory,
- measuresHistory: Array<MeasureHistory>
+ uncoveredLines /*: MeasureHistory */,
+ measuresHistory /*: Array<MeasureHistory> */
) => {
const linesToCover = measuresHistory.find(measure => measure.metric === 'lines_to_cover');
return {
@@ -96,12 +98,12 @@ export const generateCoveredLinesMetric = (
};
};
-export const generateSeries = (
- measuresHistory: Array<MeasureHistory>,
- graph: string,
- metrics: Array<Metric>,
- displayedMetrics: Array<string>
-): Array<Serie> => {
+export function generateSeries(
+ measuresHistory /*: Array<MeasureHistory> */,
+ graph /*: string */,
+ metrics /*: Array<Metric> */,
+ displayedMetrics /*: Array<string> */
+) /*: Array<Serie> */ {
if (displayedMetrics.length <= 0) {
return [];
}
@@ -125,27 +127,20 @@ export const generateSeries = (
}),
serie => displayedMetrics.indexOf(serie.name)
);
-};
+}
export const splitSeriesInGraphs = (
- series: Array<Serie>,
- maxGraph: number,
- maxSeries: number
-): Array<Array<Serie>> =>
+ series /*: Array<Serie> */,
+ maxGraph /*: number */,
+ maxSeries /*: number */
+) =>
flatMap(groupBy(series, serie => serie.type), type => chunk(type, maxSeries)).slice(0, maxGraph);
-export const getSeriesMetricType = (series: Array<Serie>): string =>
+export const getSeriesMetricType = (series /*: Array<Serie> */) =>
series.length > 0 ? series[0].type : 'INT';
-export const getAnalysesByVersionByDay = (
- analyses: Array<Analysis>,
- query: Query
-): Array<{
- version: ?string,
- key: ?string,
- byDay: { [string]: Array<Analysis> }
-}> =>
- analyses.reduce((acc, analysis) => {
+export function getAnalysesByVersionByDay(analyses /*: Array<Analysis> */, query /*: Query */) {
+ return analyses.reduce((acc, analysis) => {
let currentVersion = acc[acc.length - 1];
const versionEvent = analysis.events.find(event => event.category === 'VERSION');
if (versionEvent) {
@@ -181,41 +176,45 @@ export const getAnalysesByVersionByDay = (
}
return acc;
}, []);
+}
export const getDisplayedHistoryMetrics = (
- graph: string,
- customMetrics: Array<string>
-): Array<string> => (isCustomGraph(graph) ? customMetrics : GRAPHS_METRICS_DISPLAYED[graph]);
+ graph /*: string */,
+ customMetrics /*: Array<string> */
+) => (isCustomGraph(graph) ? customMetrics : GRAPHS_METRICS_DISPLAYED[graph]);
-export const getHistoryMetrics = (graph: string, customMetrics: Array<string>): Array<string> =>
+export const getHistoryMetrics = (graph /*: string */, customMetrics /*: Array<string> */) =>
isCustomGraph(graph) ? customMetrics : GRAPHS_METRICS[graph];
-const parseGraph = (value?: string): string => {
+const parseGraph = (value /*: ?string */) => {
const graph = parseAsString(value);
return GRAPH_TYPES.includes(graph) ? graph : DEFAULT_GRAPH;
};
-const serializeGraph = (value: string): ?string => (value === DEFAULT_GRAPH ? undefined : value);
+const serializeGraph = (value /*: string */) => (value === DEFAULT_GRAPH ? undefined : value);
-export const parseQuery = (urlQuery: RawQuery): Query => ({
- category: parseAsString(urlQuery['category']),
- customMetrics: parseAsArray(urlQuery['custom_metrics'], parseAsString),
- from: parseAsDate(urlQuery['from']),
- graph: parseGraph(urlQuery['graph']),
- project: parseAsString(urlQuery['id']),
- to: parseAsDate(urlQuery['to']),
- selectedDate: parseAsDate(urlQuery['selected_date'])
-});
+export function parseQuery(urlQuery /*: RawQuery */) /*: Query */ {
+ return {
+ category: parseAsString(urlQuery['category']),
+ customMetrics: parseAsArray(urlQuery['custom_metrics'], parseAsString),
+ from: parseAsDate(urlQuery['from']),
+ graph: parseGraph(urlQuery['graph']),
+ project: parseAsString(urlQuery['id']),
+ to: parseAsDate(urlQuery['to']),
+ selectedDate: parseAsDate(urlQuery['selected_date'])
+ };
+}
-export const serializeQuery = (query: Query): RawQuery =>
- cleanQuery({
+export function serializeQuery(query /*: Query */) /*: RawQuery */ {
+ return cleanQuery({
category: serializeString(query.category),
from: serializeDate(query.from),
project: serializeString(query.project),
to: serializeDate(query.to)
});
+}
-export const serializeUrlQuery = (query: Query): RawQuery => {
+export function serializeUrlQuery(query /*: Query */) /*: RawQuery */ {
return cleanQuery({
category: serializeString(query.category),
custom_metrics: serializeStringArray(query.customMetrics),
@@ -225,4 +224,4 @@ export const serializeUrlQuery = (query: Query): RawQuery => {
to: serializeDate(query.to),
selected_date: serializeDate(query.selectedDate)
});
-};
+}