Skip to content

Commit

Permalink
First pass at proptypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Carlino committed Sep 14, 2018
1 parent 75ce5c4 commit ef0eecd
Show file tree
Hide file tree
Showing 47 changed files with 237 additions and 192 deletions.
3 changes: 2 additions & 1 deletion client/src/components/Badge/Badge.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { PureComponent, PropTypes } from 'react';
import React, { PureComponent } from 'react';
import classnames from 'classnames';
import PropTypes from 'prop-types';

class Badge extends PureComponent {
render() {
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Breadcrumb/Breadcrumb.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';

class Breadcrumb extends Component {
getLastCrumb() {
Expand Down
27 changes: 14 additions & 13 deletions client/src/components/CheckboxSetField/CheckboxSetField.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import OptionField from 'components/OptionsetField/OptionField';
import fieldHolder from 'components/FieldHolder/FieldHolder';
import PropTypes from 'prop-types';

// a group of check boxes
class CheckboxSetField extends Component {
Expand Down Expand Up @@ -112,20 +113,20 @@ class CheckboxSetField extends Component {
}

CheckboxSetField.propTypes = {
className: React.PropTypes.string,
extraClass: React.PropTypes.string,
itemClass: React.PropTypes.string,
id: React.PropTypes.string,
name: React.PropTypes.string.isRequired,
source: React.PropTypes.arrayOf(React.PropTypes.shape({
value: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]),
title: React.PropTypes.any,
disabled: React.PropTypes.bool,
className: PropTypes.string,
extraClass: PropTypes.string,
itemClass: PropTypes.string,
id: PropTypes.string,
name: PropTypes.string.isRequired,
source: PropTypes.arrayOf(PropTypes.shape({
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
title: PropTypes.any,
disabled: PropTypes.bool,
})),
onChange: React.PropTypes.func,
value: React.PropTypes.any,
readOnly: React.PropTypes.bool,
disabled: React.PropTypes.bool,
onChange: PropTypes.func,
value: PropTypes.any,
readOnly: PropTypes.bool,
disabled: PropTypes.bool,
};

CheckboxSetField.defaultProps = {
Expand Down
13 changes: 7 additions & 6 deletions client/src/components/CompositeField/CompositeField.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from 'react';
import castStringToElement from 'lib/castStringToElement';
import PropTypes from 'prop-types';

class CompositeField extends Component {
/**
Expand Down Expand Up @@ -36,14 +37,14 @@ class CompositeField extends Component {
}

CompositeField.propTypes = {
data: React.PropTypes.oneOfType([
React.PropTypes.array,
React.PropTypes.shape({
tag: React.PropTypes.string,
legend: React.PropTypes.string,
data: PropTypes.oneOfType([
PropTypes.array,
PropTypes.shape({
tag: PropTypes.string,
legend: PropTypes.string,
}),
]),
extraClass: React.PropTypes.string,
extraClass: PropTypes.string,
};

CompositeField.defaultProps = {
Expand Down
11 changes: 6 additions & 5 deletions client/src/components/DateField/DateField.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Component as TextField } from '../TextField/TextField';
import moment from 'moment';
import modernizr from 'modernizr';
import i18n from 'i18n';
import PropTypes from 'prop-types';

const localFormat = 'L';

Expand Down Expand Up @@ -127,11 +128,11 @@ class DateField extends TextField {
}

DateField.propTypes = {
lang: React.PropTypes.string,
isoLang: React.PropTypes.string,
modernizr: React.PropTypes.object,
data: React.PropTypes.shape({
html5: React.PropTypes.bool,
lang: PropTypes.string,
isoLang: PropTypes.string,
modernizr: PropTypes.object,
data: PropTypes.shape({
html5: PropTypes.bool,
}),
};

Expand Down
9 changes: 5 additions & 4 deletions client/src/components/DatetimeField/DatetimeField.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Component as DateField } from '../DateField/DateField';
import moment from 'moment';
import modernizr from 'modernizr';
import i18n from 'i18n';
import PropTypes from 'prop-types';

const localFormat = 'L LT';

Expand Down Expand Up @@ -67,10 +68,10 @@ class DatetimeField extends DateField {
}

DatetimeField.propTypes = {
lang: React.PropTypes.string,
modernizr: React.PropTypes.object,
data: React.PropTypes.shape({
html5: React.PropTypes.boolean,
lang: PropTypes.string,
modernizr: PropTypes.object,
data: PropTypes.shape({
html5: PropTypes.boolean,
}),
};

Expand Down
3 changes: 2 additions & 1 deletion client/src/components/FieldHolder/FieldHolder.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import { FormGroup, InputGroup, InputGroupAddon, Label } from 'reactstrap';
import castStringToElement from 'lib/castStringToElement';
import classnames from 'classnames';
import PropTypes from 'prop-types';

function fieldHolder(Field) {
class FieldHolder extends Component {
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Focusedzone/Focusedzone.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global document */
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';

/**
* Wrapper component that fires a handler (`onClickOut`) when a user clicks
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Form/Form.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { PropTypes, Component } from 'react';
import React, { Component } from 'react';
import FormAlert from 'components/FormAlert/FormAlert';
import PropTypes from 'prop-types';

class Form extends Component {
componentDidMount() {
Expand Down
31 changes: 16 additions & 15 deletions client/src/components/FormAction/FormAction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import castStringToElement from 'lib/castStringToElement';
import classnames from 'classnames';
import PropTypes from 'prop-types';

class FormAction extends Component {
constructor(props) {
Expand Down Expand Up @@ -169,23 +170,23 @@ class FormAction extends Component {
}

FormAction.propTypes = {
id: React.PropTypes.string,
name: React.PropTypes.string,
onClick: React.PropTypes.func,
title: React.PropTypes.string,
type: React.PropTypes.string,
loading: React.PropTypes.bool,
icon: React.PropTypes.string,
disabled: React.PropTypes.bool,
readOnly: React.PropTypes.bool,
data: React.PropTypes.oneOfType([
React.PropTypes.array,
React.PropTypes.shape({
buttonStyle: React.PropTypes.string,
id: PropTypes.string,
name: PropTypes.string,
onClick: PropTypes.func,
title: PropTypes.string,
type: PropTypes.string,
loading: PropTypes.bool,
icon: PropTypes.string,
disabled: PropTypes.bool,
readOnly: PropTypes.bool,
data: PropTypes.oneOfType([
PropTypes.array,
PropTypes.shape({
buttonStyle: PropTypes.string,
}),
]),
extraClass: React.PropTypes.string,
attributes: React.PropTypes.object,
extraClass: PropTypes.string,
attributes: PropTypes.object,
};

FormAction.defaultProps = {
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/FormAlert/FormAlert.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import { Alert } from 'reactstrap';
import castStringToElement from 'lib/castStringToElement';
import classnames from 'classnames';
import PropTypes from 'prop-types';

/**
* A wrapper for Alert messages in reactstrap.
Expand Down
35 changes: 18 additions & 17 deletions client/src/components/FormBuilderModal/FormBuilderModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import i18n from 'i18n';
import { Modal, ModalHeader, ModalBody } from 'reactstrap';
import FormBuilderLoader from 'containers/FormBuilderLoader/FormBuilderLoader';
import castStringToElement from 'lib/castStringToElement';
import PropTypes from 'prop-types';

const noop = () => null;

Expand Down Expand Up @@ -186,24 +187,24 @@ class FormBuilderModal extends Component {
}

FormBuilderModal.propTypes = {
autoFocus: React.PropTypes.bool,
isOpen: React.PropTypes.bool,
title: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.bool]),
className: React.PropTypes.string,
bodyClassName: React.PropTypes.string,
modalClassName: React.PropTypes.string,
showCloseButton: React.PropTypes.bool,
size: React.PropTypes.string,
onClosed: React.PropTypes.func,
schemaUrl: React.PropTypes.string,
onSubmit: React.PropTypes.func,
onAction: React.PropTypes.func,
responseClassGood: React.PropTypes.string,
responseClassBad: React.PropTypes.string,
identifier: React.PropTypes.string,
autoFocus: PropTypes.bool,
isOpen: PropTypes.bool,
title: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
className: PropTypes.string,
bodyClassName: PropTypes.string,
modalClassName: PropTypes.string,
showCloseButton: PropTypes.bool,
size: PropTypes.string,
onClosed: PropTypes.func,
schemaUrl: PropTypes.string,
onSubmit: PropTypes.func,
onAction: PropTypes.func,
responseClassGood: PropTypes.string,
responseClassBad: PropTypes.string,
identifier: PropTypes.string,
// Ignored and assumed true if onLoadingError is unassigned
showErrorMessage: React.PropTypes.bool,
onLoadingError: React.PropTypes.func,
showErrorMessage: PropTypes.bool,
onLoadingError: PropTypes.func,
};

FormBuilderModal.defaultProps = {
Expand Down
13 changes: 7 additions & 6 deletions client/src/components/GridField/GridField.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import GridFieldAction from './GridFieldAction';
import FormConstants from 'components/Form/FormConstants';
import * as actions from 'state/records/RecordsActions';
import castStringToElement from 'lib/castStringToElement';
import PropTypes from 'prop-types';

const NotYetLoaded = [];

Expand Down Expand Up @@ -158,12 +159,12 @@ class GridField extends Component {
}

GridField.propTypes = {
data: React.PropTypes.shape({
recordType: React.PropTypes.string.isRequired,
headerColumns: React.PropTypes.array,
collectionReadEndpoint: React.PropTypes.object,
onDrillDown: React.PropTypes.func,
onEditRecord: React.PropTypes.func,
data: PropTypes.shape({
recordType: PropTypes.string.isRequired,
headerColumns: PropTypes.array,
collectionReadEndpoint: PropTypes.object,
onDrillDown: PropTypes.func,
onEditRecord: PropTypes.func,
}),
};

Expand Down
3 changes: 2 additions & 1 deletion client/src/components/GridField/GridFieldAction.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';

class GridFieldAction extends Component {
constructor(props) {
Expand All @@ -21,7 +22,7 @@ class GridFieldAction extends Component {
}

GridFieldAction.PropTypes = {
Click: React.PropTypes.func.isRequired,
Click: PropTypes.func.isRequired,
};

export default GridFieldAction;
5 changes: 3 additions & 2 deletions client/src/components/GridField/GridFieldCell.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from 'react';
import classnames from 'classnames';
import PropTypes from 'prop-types';

class GridFieldCell extends Component {
constructor(props) {
Expand Down Expand Up @@ -34,8 +35,8 @@ class GridFieldCell extends Component {
}

GridFieldCell.PropTypes = {
className: React.PropTypes.string,
onDrillDown: React.PropTypes.func,
className: PropTypes.string,
onDrillDown: PropTypes.func,
};

export default GridFieldCell;
5 changes: 3 additions & 2 deletions client/src/components/GridFieldActions/GridFieldActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Button, DropdownItem } from 'reactstrap';
import GridFieldDropdownAction from './GridFieldDropdownAction';
import ActionMenu from '../ActionMenu/ActionMenu';
import classnames from 'classnames';
import PropTypes from 'prop-types';

class GridFieldActions extends PureComponent {
constructor(props) {
Expand Down Expand Up @@ -92,9 +93,9 @@ class GridFieldActions extends PureComponent {
}

const actionShape = GridFieldDropdownAction.propTypes;
actionShape.group = React.PropTypes.string;
actionShape.group = PropTypes.string;

GridFieldActions.propTypes = React.PropTypes.arrayOf(
GridFieldActions.propTypes = PropTypes.arrayOf(
React.PropTypes.shape(actionShape)
).isRequired;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { PureComponent } from 'react';
import { DropdownItem } from 'reactstrap';
import classnames from 'classnames';
import PropTypes from 'prop-types';

class GridFieldDropdownAction extends PureComponent {
render() {
Expand Down Expand Up @@ -38,10 +39,10 @@ class GridFieldDropdownAction extends PureComponent {
}

GridFieldDropdownAction.propTypes = {
data: React.PropTypes.object,
title: React.PropTypes.string.isRequired,
type: React.PropTypes.oneOf(['submit', 'link']),
url: React.PropTypes.string,
data: PropTypes.object,
title: PropTypes.string.isRequired,
type: PropTypes.oneOf(['submit', 'link']),
url: PropTypes.string,
};

export default GridFieldDropdownAction;
15 changes: 8 additions & 7 deletions client/src/components/HeaderField/HeaderField.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';

class HeaderField extends Component {
/**
Expand All @@ -25,13 +26,13 @@ class HeaderField extends Component {
}

HeaderField.propTypes = {
extraClass: React.PropTypes.string,
id: React.PropTypes.string,
data: React.PropTypes.oneOfType([
React.PropTypes.array,
React.PropTypes.shape({
headingLevel: React.PropTypes.number,
title: React.PropTypes.string,
extraClass: PropTypes.string,
id: PropTypes.string,
data: PropTypes.oneOfType([
PropTypes.array,
PropTypes.shape({
headingLevel: PropTypes.number,
title: PropTypes.string,
}),
]).isRequired,
};
Expand Down
Loading

0 comments on commit ef0eecd

Please sign in to comment.