Unify proptypes in util/proptypes.js (#3728)
* Unify proptypes in util/proptypes.js * Add missing use of nodeOrStringProptype
This commit is contained in:
parent
60680e1913
commit
e2bb8ef6d1
@ -21,6 +21,9 @@ const muiTheme = getMuiTheme(lightBaseTheme);
|
|||||||
|
|
||||||
import CircularProgress from 'material-ui/CircularProgress';
|
import CircularProgress from 'material-ui/CircularProgress';
|
||||||
import { Card, CardText } from 'material-ui/Card';
|
import { Card, CardText } from 'material-ui/Card';
|
||||||
|
|
||||||
|
import { nullableProptype } from '~/util/proptypes';
|
||||||
|
|
||||||
import styles from './application.css';
|
import styles from './application.css';
|
||||||
import Accounts from '../Accounts';
|
import Accounts from '../Accounts';
|
||||||
import Events from '../Events';
|
import Events from '../Events';
|
||||||
@ -28,8 +31,6 @@ import Lookup from '../Lookup';
|
|||||||
import Names from '../Names';
|
import Names from '../Names';
|
||||||
import Records from '../Records';
|
import Records from '../Records';
|
||||||
|
|
||||||
const nullable = (type) => React.PropTypes.oneOfType([ React.PropTypes.oneOf([ null ]), type ]);
|
|
||||||
|
|
||||||
export default class Application extends Component {
|
export default class Application extends Component {
|
||||||
static childContextTypes = {
|
static childContextTypes = {
|
||||||
muiTheme: PropTypes.object.isRequired,
|
muiTheme: PropTypes.object.isRequired,
|
||||||
@ -44,8 +45,8 @@ export default class Application extends Component {
|
|||||||
actions: PropTypes.object.isRequired,
|
actions: PropTypes.object.isRequired,
|
||||||
accounts: PropTypes.object.isRequired,
|
accounts: PropTypes.object.isRequired,
|
||||||
contacts: PropTypes.object.isRequired,
|
contacts: PropTypes.object.isRequired,
|
||||||
contract: nullable(PropTypes.object.isRequired),
|
contract: nullableProptype(PropTypes.object.isRequired),
|
||||||
fee: nullable(PropTypes.object.isRequired),
|
fee: nullableProptype(PropTypes.object.isRequired),
|
||||||
lookup: PropTypes.object.isRequired,
|
lookup: PropTypes.object.isRequired,
|
||||||
events: PropTypes.object.isRequired,
|
events: PropTypes.object.isRequired,
|
||||||
names: PropTypes.object.isRequired,
|
names: PropTypes.object.isRequired,
|
||||||
|
@ -18,19 +18,19 @@ import React, { Component, PropTypes } from 'react';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
|
|
||||||
|
import { nullableProptype } from '~/util/proptypes';
|
||||||
|
|
||||||
import Application from './Application';
|
import Application from './Application';
|
||||||
import * as actions from './actions';
|
import * as actions from './actions';
|
||||||
|
|
||||||
const nullable = (type) => React.PropTypes.oneOfType([ React.PropTypes.oneOf([ null ]), type ]);
|
|
||||||
|
|
||||||
class Container extends Component {
|
class Container extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
actions: PropTypes.object.isRequired,
|
actions: PropTypes.object.isRequired,
|
||||||
accounts: PropTypes.object.isRequired,
|
accounts: PropTypes.object.isRequired,
|
||||||
contacts: PropTypes.object.isRequired,
|
contacts: PropTypes.object.isRequired,
|
||||||
contract: nullable(PropTypes.object.isRequired),
|
contract: nullableProptype(PropTypes.object.isRequired),
|
||||||
owner: nullable(PropTypes.string.isRequired),
|
owner: nullableProptype(PropTypes.string.isRequired),
|
||||||
fee: nullable(PropTypes.object.isRequired),
|
fee: nullableProptype(PropTypes.object.isRequired),
|
||||||
lookup: PropTypes.object.isRequired,
|
lookup: PropTypes.object.isRequired,
|
||||||
events: PropTypes.object.isRequired
|
events: PropTypes.object.isRequired
|
||||||
};
|
};
|
||||||
|
@ -19,21 +19,22 @@ import { Card, CardHeader, CardText } from 'material-ui/Card';
|
|||||||
import TextField from 'material-ui/TextField';
|
import TextField from 'material-ui/TextField';
|
||||||
import RaisedButton from 'material-ui/RaisedButton';
|
import RaisedButton from 'material-ui/RaisedButton';
|
||||||
import SearchIcon from 'material-ui/svg-icons/action/search';
|
import SearchIcon from 'material-ui/svg-icons/action/search';
|
||||||
|
|
||||||
|
import { nullableProptype } from '~/util/proptypes';
|
||||||
|
|
||||||
import renderAddress from '../ui/address.js';
|
import renderAddress from '../ui/address.js';
|
||||||
import renderImage from '../ui/image.js';
|
import renderImage from '../ui/image.js';
|
||||||
|
|
||||||
import recordTypeSelect from '../ui/record-type-select.js';
|
import recordTypeSelect from '../ui/record-type-select.js';
|
||||||
import styles from './lookup.css';
|
import styles from './lookup.css';
|
||||||
|
|
||||||
const nullable = (type) => React.PropTypes.oneOfType([ React.PropTypes.oneOf([ null ]), type ]);
|
|
||||||
|
|
||||||
export default class Lookup extends Component {
|
export default class Lookup extends Component {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
actions: PropTypes.object.isRequired,
|
actions: PropTypes.object.isRequired,
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
type: PropTypes.string.isRequired,
|
type: PropTypes.string.isRequired,
|
||||||
result: nullable(PropTypes.string.isRequired),
|
result: nullableProptype(PropTypes.string.isRequired),
|
||||||
accounts: PropTypes.object.isRequired,
|
accounts: PropTypes.object.isRequired,
|
||||||
contacts: PropTypes.object.isRequired
|
contacts: PropTypes.object.isRequired
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
import nullable from '../../../util/nullable-proptype';
|
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import { Checkbox } from 'material-ui';
|
import { Checkbox } from 'material-ui';
|
||||||
import InfoIcon from 'material-ui/svg-icons/action/info-outline';
|
import InfoIcon from 'material-ui/svg-icons/action/info-outline';
|
||||||
@ -24,6 +23,7 @@ import ErrorIcon from 'material-ui/svg-icons/navigation/close';
|
|||||||
|
|
||||||
import { fromWei } from '~/api/util/wei';
|
import { fromWei } from '~/api/util/wei';
|
||||||
import { Form, Input } from '~/ui';
|
import { Form, Input } from '~/ui';
|
||||||
|
import { nullableProptype } from '~/util/proptypes';
|
||||||
|
|
||||||
import { termsOfService } from '../../../3rdparty/sms-verification';
|
import { termsOfService } from '../../../3rdparty/sms-verification';
|
||||||
import styles from './gatherData.css';
|
import styles from './gatherData.css';
|
||||||
@ -32,8 +32,8 @@ export default class GatherData extends Component {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
fee: React.PropTypes.instanceOf(BigNumber),
|
fee: React.PropTypes.instanceOf(BigNumber),
|
||||||
isNumberValid: PropTypes.bool.isRequired,
|
isNumberValid: PropTypes.bool.isRequired,
|
||||||
isVerified: nullable(PropTypes.bool.isRequired),
|
isVerified: nullableProptype(PropTypes.bool.isRequired),
|
||||||
hasRequested: nullable(PropTypes.bool.isRequired),
|
hasRequested: nullableProptype(PropTypes.bool.isRequired),
|
||||||
setNumber: PropTypes.func.isRequired,
|
setNumber: PropTypes.func.isRequired,
|
||||||
setConsentGiven: PropTypes.func.isRequired
|
setConsentGiven: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
import nullable from '../../../util/nullable-proptype';
|
|
||||||
|
|
||||||
|
import { nullableProptype } from '~/util/proptypes';
|
||||||
import TxHash from '~/ui/TxHash';
|
import TxHash from '~/ui/TxHash';
|
||||||
import {
|
import {
|
||||||
POSTING_CONFIRMATION, POSTED_CONFIRMATION
|
POSTING_CONFIRMATION, POSTED_CONFIRMATION
|
||||||
@ -27,7 +27,7 @@ import styles from './sendConfirmation.css';
|
|||||||
export default class SendConfirmation extends Component {
|
export default class SendConfirmation extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
step: PropTypes.any.isRequired,
|
step: PropTypes.any.isRequired,
|
||||||
tx: nullable(PropTypes.any.isRequired)
|
tx: nullableProptype(PropTypes.any.isRequired)
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
import nullable from '../../../util/nullable-proptype';
|
|
||||||
|
|
||||||
|
import { nullableProptype } from '~/util/proptypes';
|
||||||
import TxHash from '~/ui/TxHash';
|
import TxHash from '~/ui/TxHash';
|
||||||
import {
|
import {
|
||||||
POSTING_REQUEST, POSTED_REQUEST, REQUESTING_SMS
|
POSTING_REQUEST, POSTED_REQUEST, REQUESTING_SMS
|
||||||
@ -27,7 +27,7 @@ import styles from './sendRequest.css';
|
|||||||
export default class SendRequest extends Component {
|
export default class SendRequest extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
step: PropTypes.any.isRequired,
|
step: PropTypes.any.isRequired,
|
||||||
tx: nullable(PropTypes.any.isRequired)
|
tx: nullableProptype(PropTypes.any.isRequired)
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -17,11 +17,10 @@
|
|||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
import { Checkbox, MenuItem } from 'material-ui';
|
import { Checkbox, MenuItem } from 'material-ui';
|
||||||
|
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
|
|
||||||
import Form, { Input, InputAddressSelect, AddressSelect, Select } from '~/ui/Form';
|
import Form, { Input, InputAddressSelect, AddressSelect, Select } from '~/ui/Form';
|
||||||
import nullableProptype from '~/util/nullable-proptype';
|
import { nullableProptype } from '~/util/proptypes';
|
||||||
|
|
||||||
import imageUnknown from '../../../../assets/images/contracts/unknown-64x64.png';
|
import imageUnknown from '../../../../assets/images/contracts/unknown-64x64.png';
|
||||||
import styles from '../transfer.css';
|
import styles from '../transfer.css';
|
||||||
|
@ -26,7 +26,7 @@ import NavigationArrowForward from 'material-ui/svg-icons/navigation/arrow-forwa
|
|||||||
|
|
||||||
import { newError } from '~/ui/Errors/actions';
|
import { newError } from '~/ui/Errors/actions';
|
||||||
import { BusyStep, CompletedStep, Button, IdentityIcon, Modal, TxHash } from '~/ui';
|
import { BusyStep, CompletedStep, Button, IdentityIcon, Modal, TxHash } from '~/ui';
|
||||||
import nullableProptype from '~/util/nullable-proptype';
|
import { nullableProptype } from '~/util/proptypes';
|
||||||
|
|
||||||
import Details from './Details';
|
import Details from './Details';
|
||||||
import Extras from './Extras';
|
import Extras from './Extras';
|
||||||
|
@ -1,7 +1,25 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Parity is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
import ActionDone from 'material-ui/svg-icons/action/done';
|
import ActionDone from 'material-ui/svg-icons/action/done';
|
||||||
import ContentClear from 'material-ui/svg-icons/content/clear';
|
import ContentClear from 'material-ui/svg-icons/content/clear';
|
||||||
|
|
||||||
|
import { nodeOrStringProptype } from '~/util/proptypes';
|
||||||
|
|
||||||
import Button from '../Button';
|
import Button from '../Button';
|
||||||
import Modal from '../Modal';
|
import Modal from '../Modal';
|
||||||
|
|
||||||
@ -15,9 +33,7 @@ export default class ConfirmDialog extends Component {
|
|||||||
iconDeny: PropTypes.node,
|
iconDeny: PropTypes.node,
|
||||||
labelConfirm: PropTypes.string,
|
labelConfirm: PropTypes.string,
|
||||||
labelDeny: PropTypes.string,
|
labelDeny: PropTypes.string,
|
||||||
title: PropTypes.oneOfType([
|
title: nodeOrStringProptype.isRequired,
|
||||||
PropTypes.node, PropTypes.string
|
|
||||||
]).isRequired,
|
|
||||||
visible: PropTypes.bool.isRequired,
|
visible: PropTypes.bool.isRequired,
|
||||||
onConfirm: PropTypes.func.isRequired,
|
onConfirm: PropTypes.func.isRequired,
|
||||||
onDeny: PropTypes.func.isRequired
|
onDeny: PropTypes.func.isRequired
|
||||||
|
@ -16,17 +16,15 @@
|
|||||||
|
|
||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
|
|
||||||
|
import { nodeOrStringProptype } from '~/util/proptypes';
|
||||||
|
|
||||||
import styles from './title.css';
|
import styles from './title.css';
|
||||||
|
|
||||||
export default class Title extends Component {
|
export default class Title extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
title: PropTypes.oneOfType([
|
title: nodeOrStringProptype,
|
||||||
PropTypes.string, PropTypes.node
|
byline: nodeOrStringProptype
|
||||||
]),
|
|
||||||
byline: PropTypes.oneOfType([
|
|
||||||
PropTypes.string, PropTypes.node
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
import { Card } from 'material-ui/Card';
|
import { Card } from 'material-ui/Card';
|
||||||
|
|
||||||
|
import { nodeOrStringProptype } from '~/util/proptypes';
|
||||||
|
|
||||||
import Title from './Title';
|
import Title from './Title';
|
||||||
|
|
||||||
import styles from './container.css';
|
import styles from './container.css';
|
||||||
@ -28,9 +30,7 @@ export default class Container extends Component {
|
|||||||
compact: PropTypes.bool,
|
compact: PropTypes.bool,
|
||||||
light: PropTypes.bool,
|
light: PropTypes.bool,
|
||||||
style: PropTypes.object,
|
style: PropTypes.object,
|
||||||
title: PropTypes.oneOfType([
|
title: nodeOrStringProptype
|
||||||
PropTypes.string, PropTypes.node
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
|
|
||||||
|
import { nodeOrStringProptype } from '~/util/proptypes';
|
||||||
|
|
||||||
import Input from '../Input';
|
import Input from '../Input';
|
||||||
|
|
||||||
import styles from './inputInline.css';
|
import styles from './inputInline.css';
|
||||||
@ -33,9 +35,7 @@ export default class InputInline extends Component {
|
|||||||
value: PropTypes.oneOfType([
|
value: PropTypes.oneOfType([
|
||||||
PropTypes.number, PropTypes.string
|
PropTypes.number, PropTypes.string
|
||||||
]),
|
]),
|
||||||
static: PropTypes.oneOfType([
|
static: nodeOrStringProptype
|
||||||
PropTypes.node, PropTypes.string
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
@ -18,6 +18,8 @@ import React, { Component, PropTypes } from 'react';
|
|||||||
import { LinearProgress } from 'material-ui';
|
import { LinearProgress } from 'material-ui';
|
||||||
import { Step, Stepper, StepLabel } from 'material-ui/Stepper';
|
import { Step, Stepper, StepLabel } from 'material-ui/Stepper';
|
||||||
|
|
||||||
|
import { nodeOrStringProptype } from '~/util/proptypes';
|
||||||
|
|
||||||
import styles from '../modal.css';
|
import styles from '../modal.css';
|
||||||
|
|
||||||
export default class Title extends Component {
|
export default class Title extends Component {
|
||||||
@ -26,9 +28,7 @@ export default class Title extends Component {
|
|||||||
current: PropTypes.number,
|
current: PropTypes.number,
|
||||||
steps: PropTypes.array,
|
steps: PropTypes.array,
|
||||||
waiting: PropTypes.array,
|
waiting: PropTypes.array,
|
||||||
title: React.PropTypes.oneOfType([
|
title: nodeOrStringProptype
|
||||||
PropTypes.node, PropTypes.string
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -19,6 +19,8 @@ import { connect } from 'react-redux';
|
|||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import { Dialog } from 'material-ui';
|
import { Dialog } from 'material-ui';
|
||||||
|
|
||||||
|
import { nodeOrStringProptype } from '~/util/proptypes';
|
||||||
|
|
||||||
import Container from '../Container';
|
import Container from '../Container';
|
||||||
import Title from './Title';
|
import Title from './Title';
|
||||||
|
|
||||||
@ -42,9 +44,7 @@ class Modal extends Component {
|
|||||||
current: PropTypes.number,
|
current: PropTypes.number,
|
||||||
waiting: PropTypes.array,
|
waiting: PropTypes.array,
|
||||||
steps: PropTypes.array,
|
steps: PropTypes.array,
|
||||||
title: PropTypes.oneOfType([
|
title: nodeOrStringProptype,
|
||||||
PropTypes.node, PropTypes.string
|
|
||||||
]),
|
|
||||||
visible: PropTypes.bool.isRequired,
|
visible: PropTypes.bool.isRequired,
|
||||||
settings: PropTypes.object.isRequired
|
settings: PropTypes.object.isRequired
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,16 @@
|
|||||||
|
|
||||||
import { PropTypes } from 'react';
|
import { PropTypes } from 'react';
|
||||||
|
|
||||||
export default function nullableProptype (type) {
|
export function nullableProptype (type) {
|
||||||
return PropTypes.oneOfType([ PropTypes.oneOf([ null ]), type ]);
|
return PropTypes.oneOfType([
|
||||||
|
PropTypes.oneOf([ null ]),
|
||||||
|
type
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function nodeOrStringProptype () {
|
||||||
|
return PropTypes.oneOfType([
|
||||||
|
PropTypes.node,
|
||||||
|
PropTypes.string
|
||||||
|
]);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user