diff options
Diffstat (limited to 'server/sonar-web/src/main/js/components')
31 files changed, 225 insertions, 181 deletions
diff --git a/server/sonar-web/src/main/js/components/charts/LanguageDistribution.js b/server/sonar-web/src/main/js/components/charts/LanguageDistribution.js index d6fb2024693..696ad6c6e24 100644 --- a/server/sonar-web/src/main/js/components/charts/LanguageDistribution.js +++ b/server/sonar-web/src/main/js/components/charts/LanguageDistribution.js @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { find, sortBy } from 'lodash'; +import PropTypes from 'prop-types'; import React from 'react'; import { Histogram } from './histogram'; import { formatMeasure } from '../../helpers/measures'; @@ -26,7 +27,7 @@ import { translate } from '../../helpers/l10n'; export default class LanguageDistribution extends React.PureComponent { static propTypes = { - distribution: React.PropTypes.string.isRequired + distribution: PropTypes.string.isRequired }; state = {}; diff --git a/server/sonar-web/src/main/js/components/charts/Timeline.js b/server/sonar-web/src/main/js/components/charts/Timeline.js index f8c5568df02..0896127d099 100644 --- a/server/sonar-web/src/main/js/components/charts/Timeline.js +++ b/server/sonar-web/src/main/js/components/charts/Timeline.js @@ -19,19 +19,23 @@ */ import $ from 'jquery'; import moment from 'moment'; +import PropTypes from 'prop-types'; import React from 'react'; +import createReactClass from 'create-react-class'; import { extent, max } from 'd3-array'; import { scaleLinear, scalePoint, scaleTime } from 'd3-scale'; import { line as d3Line, curveBasis } from 'd3-shape'; import { ResizeMixin } from '../mixins/resize-mixin'; import { TooltipsMixin } from '../mixins/tooltips-mixin'; -const Timeline = React.createClass({ +const Timeline = createReactClass({ + displayName: 'Timeline', + propTypes: { - data: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, - padding: React.PropTypes.arrayOf(React.PropTypes.number), - height: React.PropTypes.number, - basisCurve: React.PropTypes.bool + data: PropTypes.arrayOf(PropTypes.object).isRequired, + padding: PropTypes.arrayOf(PropTypes.number), + height: PropTypes.number, + basisCurve: PropTypes.bool }, mixins: [ResizeMixin, TooltipsMixin], @@ -205,6 +209,7 @@ const Timeline = React.createClass({ </g> ); }, + render() { if (!this.state.width || !this.state.height) { return <div />; diff --git a/server/sonar-web/src/main/js/components/charts/bar-chart.js b/server/sonar-web/src/main/js/components/charts/bar-chart.js index 1d89adb5475..37e847d580d 100644 --- a/server/sonar-web/src/main/js/components/charts/bar-chart.js +++ b/server/sonar-web/src/main/js/components/charts/bar-chart.js @@ -18,20 +18,24 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import createReactClass from 'create-react-class'; +import PropTypes from 'prop-types'; import { max } from 'd3-array'; import { scaleLinear, scaleBand } from 'd3-scale'; import { ResizeMixin } from './../mixins/resize-mixin'; import { TooltipsContainer } from './../mixins/tooltips-mixin'; -export const BarChart = React.createClass({ +export const BarChart = createReactClass({ + displayName: 'BarChart', + propTypes: { - data: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, - xTicks: React.PropTypes.arrayOf(React.PropTypes.any), - xValues: React.PropTypes.arrayOf(React.PropTypes.any), - height: React.PropTypes.number, - padding: React.PropTypes.arrayOf(React.PropTypes.number), - barsWidth: React.PropTypes.number.isRequired, - onBarClick: React.PropTypes.func + data: PropTypes.arrayOf(PropTypes.object).isRequired, + xTicks: PropTypes.arrayOf(PropTypes.any), + xValues: PropTypes.arrayOf(PropTypes.any), + height: PropTypes.number, + padding: PropTypes.arrayOf(PropTypes.number), + barsWidth: PropTypes.number.isRequired, + onBarClick: PropTypes.func }, mixins: [ResizeMixin], diff --git a/server/sonar-web/src/main/js/components/charts/donut-chart.js b/server/sonar-web/src/main/js/components/charts/donut-chart.js index a55a243a72f..9acec66a199 100644 --- a/server/sonar-web/src/main/js/components/charts/donut-chart.js +++ b/server/sonar-web/src/main/js/components/charts/donut-chart.js @@ -18,22 +18,22 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import createReactClass from 'create-react-class'; +import PropTypes from 'prop-types'; import { arc as d3Arc, pie as d3Pie } from 'd3-shape'; import { ResizeMixin } from './../mixins/resize-mixin'; import { TooltipsMixin } from './../mixins/tooltips-mixin'; -const Sector = React.createClass({ - render() { - const arc = d3Arc() - .outerRadius(this.props.radius) - .innerRadius(this.props.radius - this.props.thickness); - return <path d={arc(this.props.data)} style={{ fill: this.props.fill }} />; - } -}); +function Sector(props) { + const arc = d3Arc().outerRadius(props.radius).innerRadius(props.radius - props.thickness); + return <path d={arc(props.data)} style={{ fill: props.fill }} />; +} + +export const DonutChart = createReactClass({ + displayName: 'DonutChart', -export const DonutChart = React.createClass({ propTypes: { - data: React.PropTypes.arrayOf(React.PropTypes.object).isRequired + data: PropTypes.arrayOf(PropTypes.object).isRequired }, mixins: [ResizeMixin, TooltipsMixin], diff --git a/server/sonar-web/src/main/js/components/charts/histogram.js b/server/sonar-web/src/main/js/components/charts/histogram.js index c7542b3a0de..b6fdeb7b6c5 100644 --- a/server/sonar-web/src/main/js/components/charts/histogram.js +++ b/server/sonar-web/src/main/js/components/charts/histogram.js @@ -18,21 +18,25 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import createReactClass from 'create-react-class'; +import PropTypes from 'prop-types'; import { max } from 'd3-array'; import { scaleLinear, scaleBand } from 'd3-scale'; import { ResizeMixin } from './../mixins/resize-mixin'; import { TooltipsMixin } from './../mixins/tooltips-mixin'; -export const Histogram = React.createClass({ +export const Histogram = createReactClass({ + displayName: 'Histogram', + propTypes: { - data: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, - yTicks: React.PropTypes.arrayOf(React.PropTypes.any), - yValues: React.PropTypes.arrayOf(React.PropTypes.any), - width: React.PropTypes.number, - height: React.PropTypes.number, - padding: React.PropTypes.arrayOf(React.PropTypes.number), - barsHeight: React.PropTypes.number, - onBarClick: React.PropTypes.func + data: PropTypes.arrayOf(PropTypes.object).isRequired, + yTicks: PropTypes.arrayOf(PropTypes.any), + yValues: PropTypes.arrayOf(PropTypes.any), + width: PropTypes.number, + height: PropTypes.number, + padding: PropTypes.arrayOf(PropTypes.number), + barsHeight: PropTypes.number, + onBarClick: PropTypes.func }, mixins: [ResizeMixin, TooltipsMixin], diff --git a/server/sonar-web/src/main/js/components/charts/line-chart.js b/server/sonar-web/src/main/js/components/charts/line-chart.js index 1b574db1216..ea56aa7e6ca 100644 --- a/server/sonar-web/src/main/js/components/charts/line-chart.js +++ b/server/sonar-web/src/main/js/components/charts/line-chart.js @@ -18,23 +18,27 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import createReactClass from 'create-react-class'; +import PropTypes from 'prop-types'; import { extent, max } from 'd3-array'; import { scaleLinear } from 'd3-scale'; import { area as d3Area, line as d3Line, curveBasis } from 'd3-shape'; import { ResizeMixin } from './../mixins/resize-mixin'; import { TooltipsMixin } from './../mixins/tooltips-mixin'; -export const LineChart = React.createClass({ +export const LineChart = createReactClass({ + displayName: 'LineChart', + propTypes: { - data: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, - xTicks: React.PropTypes.arrayOf(React.PropTypes.any), - xValues: React.PropTypes.arrayOf(React.PropTypes.any), - padding: React.PropTypes.arrayOf(React.PropTypes.number), - backdropConstraints: React.PropTypes.arrayOf(React.PropTypes.number), - displayBackdrop: React.PropTypes.bool, - displayPoints: React.PropTypes.bool, - displayVerticalGrid: React.PropTypes.bool, - height: React.PropTypes.number + data: PropTypes.arrayOf(PropTypes.object).isRequired, + xTicks: PropTypes.arrayOf(PropTypes.any), + xValues: PropTypes.arrayOf(PropTypes.any), + padding: PropTypes.arrayOf(PropTypes.number), + backdropConstraints: PropTypes.arrayOf(PropTypes.number), + displayBackdrop: PropTypes.bool, + displayPoints: PropTypes.bool, + displayVerticalGrid: PropTypes.bool, + height: PropTypes.number }, mixins: [ResizeMixin, TooltipsMixin], diff --git a/server/sonar-web/src/main/js/components/charts/treemap-breadcrumbs.js b/server/sonar-web/src/main/js/components/charts/treemap-breadcrumbs.js index 3e23cb080ac..8ed3536a9d6 100644 --- a/server/sonar-web/src/main/js/components/charts/treemap-breadcrumbs.js +++ b/server/sonar-web/src/main/js/components/charts/treemap-breadcrumbs.js @@ -18,15 +18,16 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import QualifierIcon from '../shared/QualifierIcon'; export class TreemapBreadcrumbs extends React.PureComponent { static propTypes = { - breadcrumbs: React.PropTypes.arrayOf( - React.PropTypes.shape({ - key: React.PropTypes.string.isRequired, - name: React.PropTypes.string.isRequired, - qualifier: React.PropTypes.string.isRequired + breadcrumbs: PropTypes.arrayOf( + PropTypes.shape({ + key: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + qualifier: PropTypes.string.isRequired }).isRequired ).isRequired }; diff --git a/server/sonar-web/src/main/js/components/charts/treemap.js b/server/sonar-web/src/main/js/components/charts/treemap.js index 77316c7c78f..7b6c73af59e 100644 --- a/server/sonar-web/src/main/js/components/charts/treemap.js +++ b/server/sonar-web/src/main/js/components/charts/treemap.js @@ -18,6 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import createReactClass from 'create-react-class'; +import PropTypes from 'prop-types'; import { scaleLinear } from 'd3-scale'; import { treemap as d3Treemap, hierarchy as d3Hierarchy } from 'd3-hierarchy'; import { TreemapBreadcrumbs } from './treemap-breadcrumbs'; @@ -42,18 +44,18 @@ function mostCommitPrefix(strings) { return prefix.substr(0, prefix.length - lastPrefixPart.length); } -export const TreemapRect = React.createClass({ - propTypes: { - x: React.PropTypes.number.isRequired, - y: React.PropTypes.number.isRequired, - width: React.PropTypes.number.isRequired, - height: React.PropTypes.number.isRequired, - fill: React.PropTypes.string.isRequired, - label: React.PropTypes.string.isRequired, - onClick: React.PropTypes.func - }, - - renderLink() { +export class TreemapRect extends React.PureComponent { + static propTypes = { + x: PropTypes.number.isRequired, + y: PropTypes.number.isRequired, + width: PropTypes.number.isRequired, + height: PropTypes.number.isRequired, + fill: PropTypes.string.isRequired, + label: PropTypes.string.isRequired, + onClick: PropTypes.func + }; + + renderLink = () => { if (!this.props.link) { return null; } @@ -71,7 +73,7 @@ export const TreemapRect = React.createClass({ <span className="icon-link" /> </a> ); - }, + }; render() { let tooltipAttrs = {}; @@ -108,13 +110,15 @@ export const TreemapRect = React.createClass({ </div> ); } -}); +} + +export const Treemap = createReactClass({ + displayName: 'Treemap', -export const Treemap = React.createClass({ propTypes: { - items: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, - height: React.PropTypes.number, - onRectangleClick: React.PropTypes.func + items: PropTypes.arrayOf(PropTypes.object).isRequired, + height: PropTypes.number, + onRectangleClick: PropTypes.func }, mixins: [ResizeMixin, TooltipsMixin], diff --git a/server/sonar-web/src/main/js/components/charts/word-cloud.js b/server/sonar-web/src/main/js/components/charts/word-cloud.js index 021b5bcba59..c7547ebdf87 100644 --- a/server/sonar-web/src/main/js/components/charts/word-cloud.js +++ b/server/sonar-web/src/main/js/components/charts/word-cloud.js @@ -18,39 +18,41 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import createReactClass from 'create-react-class'; +import PropTypes from 'prop-types'; import { max } from 'd3-array'; import { scaleLinear } from 'd3-scale'; import { sortBy } from 'lodash'; import { TooltipsMixin } from './../mixins/tooltips-mixin'; -export const Word = React.createClass({ - propTypes: { - size: React.PropTypes.number.isRequired, - text: React.PropTypes.string.isRequired, - tooltip: React.PropTypes.string, - link: React.PropTypes.string.isRequired - }, - - render() { - let tooltipAttrs = {}; - if (this.props.tooltip) { - tooltipAttrs = { - 'data-toggle': 'tooltip', - title: this.props.tooltip - }; - } - return ( - <a {...tooltipAttrs} style={{ fontSize: this.props.size }} href={this.props.link}> - {this.props.text} - </a> - ); +export function Word(props) { + let tooltipAttrs = {}; + if (props.tooltip) { + tooltipAttrs = { + 'data-toggle': 'tooltip', + title: props.tooltip + }; } -}); + return ( + <a {...tooltipAttrs} style={{ fontSize: props.size }} href={props.link}> + {props.text} + </a> + ); +} + +Word.propTypes = { + size: PropTypes.number.isRequired, + text: PropTypes.string.isRequired, + tooltip: PropTypes.string, + link: PropTypes.string.isRequired +}; + +export const WordCloud = createReactClass({ + displayName: 'WordCloud', -export const WordCloud = React.createClass({ propTypes: { - items: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, - sizeRange: React.PropTypes.arrayOf(React.PropTypes.number) + items: PropTypes.arrayOf(PropTypes.object).isRequired, + sizeRange: PropTypes.arrayOf(PropTypes.number) }, mixins: [TooltipsMixin], diff --git a/server/sonar-web/src/main/js/components/common/BubblePopup.js b/server/sonar-web/src/main/js/components/common/BubblePopup.js index b29ee147dab..c77167ee53b 100644 --- a/server/sonar-web/src/main/js/components/common/BubblePopup.js +++ b/server/sonar-web/src/main/js/components/common/BubblePopup.js @@ -18,13 +18,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import classNames from 'classnames'; export default class BubblePopup extends React.PureComponent { static propsType = { - children: React.PropTypes.object.isRequired, - position: React.PropTypes.object.isRequired, - customClass: React.PropTypes.string + children: PropTypes.object.isRequired, + position: PropTypes.object.isRequired, + customClass: PropTypes.string }; static defaultProps = { diff --git a/server/sonar-web/src/main/js/components/controls/Checkbox.js b/server/sonar-web/src/main/js/components/controls/Checkbox.js index 57a5d6969a5..b1acc9f577e 100644 --- a/server/sonar-web/src/main/js/components/controls/Checkbox.js +++ b/server/sonar-web/src/main/js/components/controls/Checkbox.js @@ -18,15 +18,16 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import classNames from 'classnames'; export default class Checkbox extends React.PureComponent { static propTypes = { - id: React.PropTypes.string, - onCheck: React.PropTypes.func.isRequired, - checked: React.PropTypes.bool.isRequired, - thirdState: React.PropTypes.bool, - className: React.PropTypes.any + id: PropTypes.string, + onCheck: PropTypes.func.isRequired, + checked: PropTypes.bool.isRequired, + thirdState: PropTypes.bool, + className: PropTypes.any }; static defaultProps = { diff --git a/server/sonar-web/src/main/js/components/controls/DateInput.js b/server/sonar-web/src/main/js/components/controls/DateInput.js index 16bab132de3..9da950af99a 100644 --- a/server/sonar-web/src/main/js/components/controls/DateInput.js +++ b/server/sonar-web/src/main/js/components/controls/DateInput.js @@ -19,18 +19,19 @@ */ import $ from 'jquery'; import React from 'react'; +import PropTypes from 'prop-types'; import classNames from 'classnames'; import { pick } from 'lodash'; import './styles.css'; export default class DateInput extends React.PureComponent { static propTypes = { - className: React.PropTypes.string, - value: React.PropTypes.string, - format: React.PropTypes.string, - name: React.PropTypes.string, - placeholder: React.PropTypes.string, - onChange: React.PropTypes.func.isRequired + className: PropTypes.string, + value: PropTypes.string, + format: PropTypes.string, + name: PropTypes.string, + placeholder: PropTypes.string, + onChange: PropTypes.func.isRequired }; static defaultProps = { diff --git a/server/sonar-web/src/main/js/components/controls/Favorite.js b/server/sonar-web/src/main/js/components/controls/Favorite.js index f783d24b666..4faf4e186e6 100644 --- a/server/sonar-web/src/main/js/components/controls/Favorite.js +++ b/server/sonar-web/src/main/js/components/controls/Favorite.js @@ -18,14 +18,15 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import FavoriteBase from './FavoriteBase'; import { addFavorite, removeFavorite } from '../../api/favorites'; export default class Favorite extends React.PureComponent { static propTypes = { - favorite: React.PropTypes.bool.isRequired, - component: React.PropTypes.string.isRequired, - className: React.PropTypes.string + favorite: PropTypes.bool.isRequired, + component: PropTypes.string.isRequired, + className: PropTypes.string }; render() { diff --git a/server/sonar-web/src/main/js/components/controls/FavoriteBase.js b/server/sonar-web/src/main/js/components/controls/FavoriteBase.js index 13ec0372fe1..ac1d58186b3 100644 --- a/server/sonar-web/src/main/js/components/controls/FavoriteBase.js +++ b/server/sonar-web/src/main/js/components/controls/FavoriteBase.js @@ -18,15 +18,16 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import classNames from 'classnames'; import FavoriteIcon from '../common/FavoriteIcon'; export default class FavoriteBase extends React.PureComponent { static propTypes = { - favorite: React.PropTypes.bool.isRequired, - addFavorite: React.PropTypes.func.isRequired, - removeFavorite: React.PropTypes.func.isRequired, - className: React.PropTypes.string + favorite: PropTypes.bool.isRequired, + addFavorite: PropTypes.func.isRequired, + removeFavorite: PropTypes.func.isRequired, + className: PropTypes.string }; constructor(props) { diff --git a/server/sonar-web/src/main/js/components/controls/FavoriteBaseStateless.js b/server/sonar-web/src/main/js/components/controls/FavoriteBaseStateless.js index 1e4f325fa1f..35260d19d85 100644 --- a/server/sonar-web/src/main/js/components/controls/FavoriteBaseStateless.js +++ b/server/sonar-web/src/main/js/components/controls/FavoriteBaseStateless.js @@ -18,15 +18,16 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import classNames from 'classnames'; import FavoriteIcon from '../common/FavoriteIcon'; export default class FavoriteBaseStateless extends React.PureComponent { static propTypes = { - favorite: React.PropTypes.bool.isRequired, - addFavorite: React.PropTypes.func.isRequired, - removeFavorite: React.PropTypes.func.isRequired, - className: React.PropTypes.string + favorite: PropTypes.bool.isRequired, + addFavorite: PropTypes.func.isRequired, + removeFavorite: PropTypes.func.isRequired, + className: PropTypes.string }; toggleFavorite = e => { diff --git a/server/sonar-web/src/main/js/components/controls/FavoriteIssueFilter.js b/server/sonar-web/src/main/js/components/controls/FavoriteIssueFilter.js index 2cfaf29aa8a..c00c2993d04 100644 --- a/server/sonar-web/src/main/js/components/controls/FavoriteIssueFilter.js +++ b/server/sonar-web/src/main/js/components/controls/FavoriteIssueFilter.js @@ -18,14 +18,15 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import FavoriteBase from './FavoriteBase'; import { toggleIssueFilter } from '../../api/issue-filters'; export default class FavoriteIssueFilter extends React.PureComponent { static propTypes = { - favorite: React.PropTypes.bool.isRequired, - filter: React.PropTypes.shape({ - id: React.PropTypes.string.isRequired + favorite: PropTypes.bool.isRequired, + filter: PropTypes.shape({ + id: PropTypes.string.isRequired }).isRequired }; diff --git a/server/sonar-web/src/main/js/components/controls/GlobalMessages.js b/server/sonar-web/src/main/js/components/controls/GlobalMessages.js index 10f41ddad15..ac3c07535bf 100644 --- a/server/sonar-web/src/main/js/components/controls/GlobalMessages.js +++ b/server/sonar-web/src/main/js/components/controls/GlobalMessages.js @@ -18,19 +18,20 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import classNames from 'classnames'; import { ERROR, SUCCESS } from '../../store/globalMessages/duck'; export default class GlobalMessages extends React.PureComponent { static propTypes = { - messages: React.PropTypes.arrayOf( - React.PropTypes.shape({ - id: React.PropTypes.string.isRequired, - message: React.PropTypes.string.isRequired, - level: React.PropTypes.oneOf([ERROR, SUCCESS]) + messages: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string.isRequired, + message: PropTypes.string.isRequired, + level: PropTypes.oneOf([ERROR, SUCCESS]) }) ), - closeGlobalMessage: React.PropTypes.func.isRequired + closeGlobalMessage: PropTypes.func.isRequired }; renderMessage = message => { diff --git a/server/sonar-web/src/main/js/components/controls/ListFooter.js b/server/sonar-web/src/main/js/components/controls/ListFooter.js index ba8ea10eadd..2cb3d59e903 100644 --- a/server/sonar-web/src/main/js/components/controls/ListFooter.js +++ b/server/sonar-web/src/main/js/components/controls/ListFooter.js @@ -19,15 +19,16 @@ */ import classNames from 'classnames'; import React from 'react'; +import PropTypes from 'prop-types'; import { translate, translateWithParameters } from '../../helpers/l10n'; import { formatMeasure } from '../../helpers/measures'; export default class ListFooter extends React.PureComponent { static propTypes = { - count: React.PropTypes.number.isRequired, - total: React.PropTypes.number.isRequired, - loadMore: React.PropTypes.func, - ready: React.PropTypes.bool + count: PropTypes.number.isRequired, + total: PropTypes.number.isRequired, + loadMore: PropTypes.func, + ready: PropTypes.bool }; static defaultProps = { diff --git a/server/sonar-web/src/main/js/components/controls/RadioToggle.js b/server/sonar-web/src/main/js/components/controls/RadioToggle.js index 83f36d2d846..2041eba1422 100644 --- a/server/sonar-web/src/main/js/components/controls/RadioToggle.js +++ b/server/sonar-web/src/main/js/components/controls/RadioToggle.js @@ -18,18 +18,19 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; export default class RadioToggle extends React.PureComponent { static propTypes = { - value: React.PropTypes.string, - options: React.PropTypes.arrayOf( - React.PropTypes.shape({ - value: React.PropTypes.string.isRequired, - label: React.PropTypes.string.isRequired + value: PropTypes.string, + options: PropTypes.arrayOf( + PropTypes.shape({ + value: PropTypes.string.isRequired, + label: PropTypes.string.isRequired }) ).isRequired, - name: React.PropTypes.string.isRequired, - onCheck: React.PropTypes.func.isRequired + name: PropTypes.string.isRequired, + onCheck: PropTypes.func.isRequired }; static defaultProps = { diff --git a/server/sonar-web/src/main/js/components/controls/Toggle.js b/server/sonar-web/src/main/js/components/controls/Toggle.js index 870ed5220ec..165c74777eb 100644 --- a/server/sonar-web/src/main/js/components/controls/Toggle.js +++ b/server/sonar-web/src/main/js/components/controls/Toggle.js @@ -18,14 +18,15 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import classNames from 'classnames'; import './styles.css'; export default class Toggle extends React.PureComponent { static propTypes = { - value: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.bool]).isRequired, - name: React.PropTypes.string, - onChange: React.PropTypes.func + value: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]).isRequired, + name: PropTypes.string, + onChange: PropTypes.func }; handleClick(e, value) { diff --git a/server/sonar-web/src/main/js/components/issue/Issue.js b/server/sonar-web/src/main/js/components/issue/Issue.js index eaa0214f92a..f21644f1e59 100644 --- a/server/sonar-web/src/main/js/components/issue/Issue.js +++ b/server/sonar-web/src/main/js/components/issue/Issue.js @@ -19,6 +19,7 @@ */ // @flow import React from 'react'; +import PropTypes from 'prop-types'; import key from 'keymaster'; import IssueView from './IssueView'; import { updateIssue } from './actions'; @@ -46,7 +47,7 @@ export default class BaseIssue extends React.PureComponent { state: State; static contextTypes = { - store: React.PropTypes.object + store: PropTypes.object }; static defaultProps = { diff --git a/server/sonar-web/src/main/js/components/select-list/footer.js b/server/sonar-web/src/main/js/components/select-list/footer.js index 3088c2f2337..d85be905a9d 100644 --- a/server/sonar-web/src/main/js/components/select-list/footer.js +++ b/server/sonar-web/src/main/js/components/select-list/footer.js @@ -18,12 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; export default class Footer extends React.PureComponent { static propTypes = { - count: React.PropTypes.number.isRequired, - total: React.PropTypes.number.isRequired, - loadMore: React.PropTypes.func.isRequired + count: PropTypes.number.isRequired, + total: PropTypes.number.isRequired, + loadMore: PropTypes.func.isRequired }; loadMore = e => { diff --git a/server/sonar-web/src/main/js/components/select-list/item.js b/server/sonar-web/src/main/js/components/select-list/item.js index ecd5442c927..c03ef453c04 100644 --- a/server/sonar-web/src/main/js/components/select-list/item.js +++ b/server/sonar-web/src/main/js/components/select-list/item.js @@ -18,14 +18,15 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import Checkbox from '../controls/Checkbox'; export default class Item extends React.PureComponent { static propTypes = { - item: React.PropTypes.any.isRequired, - renderItem: React.PropTypes.func.isRequired, - selectItem: React.PropTypes.func.isRequired, - deselectItem: React.PropTypes.func.isRequired + item: PropTypes.any.isRequired, + renderItem: PropTypes.func.isRequired, + selectItem: PropTypes.func.isRequired, + deselectItem: PropTypes.func.isRequired }; onCheck = checked => { diff --git a/server/sonar-web/src/main/js/components/select-list/list.js b/server/sonar-web/src/main/js/components/select-list/list.js index 6a701f51eb4..c752367bb8e 100644 --- a/server/sonar-web/src/main/js/components/select-list/list.js +++ b/server/sonar-web/src/main/js/components/select-list/list.js @@ -18,15 +18,16 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import Item from './item'; export default class List extends React.PureComponent { static propTypes = { - items: React.PropTypes.array.isRequired, - renderItem: React.PropTypes.func.isRequired, - getItemKey: React.PropTypes.func.isRequired, - selectItem: React.PropTypes.func.isRequired, - deselectItem: React.PropTypes.func.isRequired + items: PropTypes.array.isRequired, + renderItem: PropTypes.func.isRequired, + getItemKey: PropTypes.func.isRequired, + selectItem: PropTypes.func.isRequired, + deselectItem: PropTypes.func.isRequired }; render() { diff --git a/server/sonar-web/src/main/js/components/select-list/main.js b/server/sonar-web/src/main/js/components/select-list/main.js index 64902383add..3ebfeafaa9b 100644 --- a/server/sonar-web/src/main/js/components/select-list/main.js +++ b/server/sonar-web/src/main/js/components/select-list/main.js @@ -18,17 +18,18 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import Controls from './controls'; import List from './list'; import Footer from './footer'; export default class Main extends React.PureComponent { static propTypes = { - loadItems: React.PropTypes.func.isRequired, - renderItem: React.PropTypes.func.isRequired, - getItemKey: React.PropTypes.func.isRequired, - selectItem: React.PropTypes.func.isRequired, - deselectItem: React.PropTypes.func.isRequired + loadItems: PropTypes.func.isRequired, + renderItem: PropTypes.func.isRequired, + getItemKey: PropTypes.func.isRequired, + selectItem: PropTypes.func.isRequired, + deselectItem: PropTypes.func.isRequired }; state = { diff --git a/server/sonar-web/src/main/js/components/shared/WithStore.js b/server/sonar-web/src/main/js/components/shared/WithStore.js index 5d8a41939cf..c406d118aff 100644 --- a/server/sonar-web/src/main/js/components/shared/WithStore.js +++ b/server/sonar-web/src/main/js/components/shared/WithStore.js @@ -19,6 +19,7 @@ */ // @flow import React from 'react'; +import PropTypes from 'prop-types'; import getStore from '../../app/utils/getStore'; type Props = { @@ -30,7 +31,7 @@ export default class WithStore extends React.PureComponent { store: {}; static childContextTypes = { - store: React.PropTypes.object + store: PropTypes.object }; constructor(props: Props) { diff --git a/server/sonar-web/src/main/js/components/shared/complexity-distribution.js b/server/sonar-web/src/main/js/components/shared/complexity-distribution.js index 6c7b49221a5..7853ee91800 100644 --- a/server/sonar-web/src/main/js/components/shared/complexity-distribution.js +++ b/server/sonar-web/src/main/js/components/shared/complexity-distribution.js @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import { BarChart } from '../charts/bar-chart'; import { formatMeasure } from '../../helpers/measures'; import { translateWithParameters } from '../../helpers/l10n'; @@ -26,8 +27,8 @@ const HEIGHT = 80; export class ComplexityDistribution extends React.PureComponent { static propTypes = { - distribution: React.PropTypes.string.isRequired, - of: React.PropTypes.string.isRequired + distribution: PropTypes.string.isRequired, + of: PropTypes.string.isRequired }; renderBarChart = () => { diff --git a/server/sonar-web/src/main/js/components/shared/drilldown-link.js b/server/sonar-web/src/main/js/components/shared/drilldown-link.js index 55b64727a8a..13b0afeb0c3 100644 --- a/server/sonar-web/src/main/js/components/shared/drilldown-link.js +++ b/server/sonar-web/src/main/js/components/shared/drilldown-link.js @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import { Link } from 'react-router'; import { getComponentDrilldownUrl, getComponentIssuesUrl } from '../../helpers/urls'; @@ -48,14 +49,11 @@ const ISSUE_MEASURES = [ export class DrilldownLink extends React.PureComponent { static propTypes = { - children: React.PropTypes.oneOfType([ - React.PropTypes.node, - React.PropTypes.arrayOf(React.PropTypes.node) - ]), - className: React.PropTypes.string, - component: React.PropTypes.string.isRequired, - metric: React.PropTypes.string.isRequired, - sinceLeakPeriod: React.PropTypes.bool + children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]), + className: PropTypes.string, + component: PropTypes.string.isRequired, + metric: PropTypes.string.isRequired, + sinceLeakPeriod: PropTypes.bool }; isIssueMeasure = () => { return ISSUE_MEASURES.indexOf(this.props.metric) !== -1; diff --git a/server/sonar-web/src/main/js/components/ui/Avatar.js b/server/sonar-web/src/main/js/components/ui/Avatar.js index fcd34da318f..a2a53f474aa 100644 --- a/server/sonar-web/src/main/js/components/ui/Avatar.js +++ b/server/sonar-web/src/main/js/components/ui/Avatar.js @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import md5 from 'blueimp-md5'; import classNames from 'classnames'; @@ -47,13 +48,13 @@ function getTextColor(background) { class Avatar extends React.PureComponent { static propTypes = { - enableGravatar: React.PropTypes.bool.isRequired, - gravatarServerUrl: React.PropTypes.string.isRequired, - email: React.PropTypes.string, - hash: React.PropTypes.string, - name: React.PropTypes.string.isRequired, - size: React.PropTypes.number.isRequired, - className: React.PropTypes.string + enableGravatar: PropTypes.bool.isRequired, + gravatarServerUrl: PropTypes.string.isRequired, + email: PropTypes.string, + hash: PropTypes.string, + name: PropTypes.string.isRequired, + size: PropTypes.number.isRequired, + className: PropTypes.string }; renderFallback() { diff --git a/server/sonar-web/src/main/js/components/ui/Level.js b/server/sonar-web/src/main/js/components/ui/Level.js index 66a2bbe5025..013618021ef 100644 --- a/server/sonar-web/src/main/js/components/ui/Level.js +++ b/server/sonar-web/src/main/js/components/ui/Level.js @@ -18,15 +18,16 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import classNames from 'classnames'; import { formatMeasure } from '../../helpers/measures'; import './Level.css'; export default class Level extends React.PureComponent { static propTypes = { - level: React.PropTypes.oneOf(['ERROR', 'WARN', 'OK']).isRequired, - small: React.PropTypes.bool, - muted: React.PropTypes.bool + level: PropTypes.oneOf(['ERROR', 'WARN', 'OK']).isRequired, + small: PropTypes.bool, + muted: PropTypes.bool }; static defaultProps = { diff --git a/server/sonar-web/src/main/js/components/ui/Rating.js b/server/sonar-web/src/main/js/components/ui/Rating.js index 65a56c46999..1f30a388d04 100644 --- a/server/sonar-web/src/main/js/components/ui/Rating.js +++ b/server/sonar-web/src/main/js/components/ui/Rating.js @@ -18,13 +18,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import PropTypes from 'prop-types'; import classNames from 'classnames'; import { formatMeasure } from '../../helpers/measures'; import './Rating.css'; export default class Rating extends React.PureComponent { static propTypes = { - className: React.PropTypes.string, + className: PropTypes.string, value: (props, propName, componentName) => { // allow both numbers and strings const numberValue = Number(props[propName]); @@ -32,8 +33,8 @@ export default class Rating extends React.PureComponent { throw new Error(`Invalid prop "${propName}" passed to "${componentName}".`); } }, - small: React.PropTypes.bool, - muted: React.PropTypes.bool + small: PropTypes.bool, + muted: PropTypes.bool }; static defaultProps = { |