Comply w/ coding style
This commit is contained in:
parent
89862cbea9
commit
5a74080839
|
@ -1,7 +1,7 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
import { hideDialog } from '../actions';
|
import { hideDialog } from '../actions';
|
||||||
import { dialogPropTypes } from '../constants';
|
import { DIALOG_PROP_TYPES } from '../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract dialog to display dialogs.
|
* Abstract dialog to display dialogs.
|
||||||
|
@ -14,7 +14,7 @@ export default class AbstractDialog extends Component {
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
...dialogPropTypes,
|
...DIALOG_PROP_TYPES,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to show/hide the dialog on cancel.
|
* Used to show/hide the dialog on cancel.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import Prompt from 'react-native-prompt';
|
import Prompt from 'react-native-prompt';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import { translate } from '../../i18n';
|
import { translate } from '../../i18n';
|
||||||
|
|
||||||
|
|
|
@ -5,20 +5,19 @@ import React, { Component } from 'react';
|
||||||
|
|
||||||
import { translate } from '../../i18n';
|
import { translate } from '../../i18n';
|
||||||
|
|
||||||
import { dialogPropTypes } from '../constants';
|
import { DIALOG_PROP_TYPES } from '../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web dialog that uses atlaskit modal-dialog to display dialogs.
|
* Web dialog that uses atlaskit modal-dialog to display dialogs.
|
||||||
*/
|
*/
|
||||||
class StatelessDialog extends Component {
|
class StatelessDialog extends Component {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web dialog component's property types.
|
* {@code StatelessDialog} component's property types.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
...dialogPropTypes,
|
...DIALOG_PROP_TYPES,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the body of the dialog, the component children.
|
* This is the body of the dialog, the component children.
|
||||||
|
@ -45,16 +44,15 @@ class StatelessDialog extends Component {
|
||||||
/**
|
/**
|
||||||
* Width of the dialog, can be:
|
* Width of the dialog, can be:
|
||||||
* - 'small' (400px), 'medium' (600px), 'large' (800px),
|
* - 'small' (400px), 'medium' (600px), 'large' (800px),
|
||||||
* 'x-large' (968px)
|
* 'x-large' (968px)
|
||||||
* - integer value for pixel width
|
* - integer value for pixel width
|
||||||
* - string value for percentage
|
* - string value for percentage
|
||||||
*/
|
*/
|
||||||
width: React.PropTypes.string
|
width: React.PropTypes.string
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a new Dialog instance.
|
* Initializes a new {@code StatelessDialog} instance.
|
||||||
*
|
*
|
||||||
* @param {Object} props - The read-only properties with which the new
|
* @param {Object} props - The read-only properties with which the new
|
||||||
* instance is to be initialized.
|
* instance is to be initialized.
|
||||||
|
@ -62,6 +60,7 @@ class StatelessDialog extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
|
// Bind event handlers so they are only bound once for every instance.
|
||||||
this._onCancel = this._onCancel.bind(this);
|
this._onCancel = this._onCancel.bind(this);
|
||||||
this._onDialogDismissed = this._onDialogDismissed.bind(this);
|
this._onDialogDismissed = this._onDialogDismissed.bind(this);
|
||||||
this._onSubmit = this._onSubmit.bind(this);
|
this._onSubmit = this._onSubmit.bind(this);
|
||||||
|
@ -89,7 +88,19 @@ class StatelessDialog extends Component {
|
||||||
{ this.props.children }
|
{ this.props.children }
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</ModalDialog>);
|
</ModalDialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatches action to hide the dialog.
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
_onCancel() {
|
||||||
|
if (!this.props.isModal) {
|
||||||
|
this.props.onCancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,10 +115,21 @@ class StatelessDialog extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render cancel button.
|
* Dispatches the action when submitting the dialog.
|
||||||
*
|
*
|
||||||
* @returns {*} The cancel button if enabled and dialog is not modal.
|
|
||||||
* @private
|
* @private
|
||||||
|
* @param {string} value - The submitted value if any.
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
_onSubmit(value) {
|
||||||
|
this.props.onSubmit(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders Cancel button.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @returns {*} The Cancel button if enabled and dialog is not modal.
|
||||||
*/
|
*/
|
||||||
_renderCancelButton() {
|
_renderCancelButton() {
|
||||||
if (this.props.cancelDisabled || this.props.isModal) {
|
if (this.props.cancelDisabled || this.props.isModal) {
|
||||||
|
@ -125,10 +147,10 @@ class StatelessDialog extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render component in dialog footer.
|
* Renders component in dialog footer.
|
||||||
*
|
*
|
||||||
* @returns {ReactElement}
|
|
||||||
* @private
|
* @private
|
||||||
|
* @returns {ReactElement}
|
||||||
*/
|
*/
|
||||||
_renderFooter() {
|
_renderFooter() {
|
||||||
return (
|
return (
|
||||||
|
@ -142,10 +164,10 @@ class StatelessDialog extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render component in dialog header.
|
* Renders component in dialog header.
|
||||||
*
|
*
|
||||||
* @returns {ReactElement}
|
|
||||||
* @private
|
* @private
|
||||||
|
* @returns {ReactElement}
|
||||||
*/
|
*/
|
||||||
_renderHeader() {
|
_renderHeader() {
|
||||||
const { t } = this.props;
|
const { t } = this.props;
|
||||||
|
@ -160,10 +182,10 @@ class StatelessDialog extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render ok button.
|
* Renders OK button.
|
||||||
*
|
*
|
||||||
* @returns {*} The ok button if enabled.
|
|
||||||
* @private
|
* @private
|
||||||
|
* @returns {*} The OK button if enabled.
|
||||||
*/
|
*/
|
||||||
_renderOKButton() {
|
_renderOKButton() {
|
||||||
if (this.props.submitDisabled) {
|
if (this.props.submitDisabled) {
|
||||||
|
@ -181,30 +203,6 @@ class StatelessDialog extends Component {
|
||||||
</AKButton>
|
</AKButton>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Dispatches action to hide the dialog.
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
_onCancel() {
|
|
||||||
if (this.props.isModal) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.props.onCancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dispatches the action when submitting the dialog.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {string} value - The submitted value if any.
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
_onSubmit(value) {
|
|
||||||
this.props.onSubmit(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default translate(StatelessDialog);
|
export default translate(StatelessDialog);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
export const dialogPropTypes = {
|
export const DIALOG_PROP_TYPES = {
|
||||||
/**
|
/**
|
||||||
* Whether cancel button is disabled. Enabled by default.
|
* Whether cancel button is disabled. Enabled by default.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements a React Component to render a country flag icon.
|
* Implements a React {@link Component} to render a country flag icon.
|
||||||
*/
|
*/
|
||||||
class CountryIcon extends Component {
|
export default class CountryIcon extends Component {
|
||||||
/**
|
/**
|
||||||
* {@code CountryIcon}'s property types.
|
* {@code CountryIcon}'s property types.
|
||||||
*
|
*
|
||||||
|
@ -29,12 +29,9 @@ class CountryIcon extends Component {
|
||||||
*/
|
*/
|
||||||
render() {
|
render() {
|
||||||
const iconClassName
|
const iconClassName
|
||||||
= `flag-icon flag-icon-${this.props.countryCode}
|
= `flag-icon flag-icon-${this.props.countryCode
|
||||||
flag-icon-squared ${this.props.className}`;
|
} flag-icon-squared ${this.props.className}`;
|
||||||
|
|
||||||
return <span className = { iconClassName } />;
|
return <span className = { iconClassName } />;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CountryIcon;
|
|
||||||
|
|
|
@ -8,11 +8,10 @@ import { cancel, checkDialNumber, dial } from '../actions';
|
||||||
import DialOutNumbersForm from './DialOutNumbersForm';
|
import DialOutNumbersForm from './DialOutNumbersForm';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements a React Component which allows the user to dial out from the
|
* Implements a React {@link Component} which allows the user to dial out from
|
||||||
* conference.
|
* the conference.
|
||||||
*/
|
*/
|
||||||
class DialOutDialog extends Component {
|
class DialOutDialog extends Component {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code DialOutDialog} component's property types.
|
* {@code DialOutDialog} component's property types.
|
||||||
*
|
*
|
||||||
|
@ -91,7 +90,8 @@ class DialOutDialog extends Component {
|
||||||
titleKey = 'dialOut.dialOut'
|
titleKey = 'dialOut.dialOut'
|
||||||
width = 'small'>
|
width = 'small'>
|
||||||
{ this._renderContent() }
|
{ this._renderContent() }
|
||||||
</Dialog>);
|
</Dialog>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -221,6 +221,6 @@ function _mapStateToProps(state) {
|
||||||
export default translate(
|
export default translate(
|
||||||
connect(_mapStateToProps, {
|
connect(_mapStateToProps, {
|
||||||
cancel,
|
cancel,
|
||||||
dial,
|
checkDialNumber,
|
||||||
checkDialNumber
|
dial
|
||||||
})(DialOutDialog));
|
})(DialOutDialog));
|
||||||
|
|
|
@ -1,30 +1,35 @@
|
||||||
|
import { StatelessDropdownMenu } from '@atlaskit/dropdown-menu';
|
||||||
|
import ExpandIcon from '@atlaskit/icon/glyph/expand';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import ExpandIcon from '@atlaskit/icon/glyph/expand';
|
|
||||||
import { StatelessDropdownMenu } from '@atlaskit/dropdown-menu';
|
|
||||||
|
|
||||||
import { translate } from '../../base/i18n';
|
import { translate } from '../../base/i18n';
|
||||||
import CountryIcon from './CountryIcon';
|
|
||||||
import { updateDialOutCodes } from '../actions';
|
|
||||||
|
|
||||||
/**
|
import { updateDialOutCodes } from '../actions';
|
||||||
* The expand icon of the dropdown menu.
|
import CountryIcon from './CountryIcon';
|
||||||
*
|
|
||||||
* @type {XML}
|
|
||||||
*/
|
|
||||||
const EXPAND_ICON = <ExpandIcon label = 'expand' />;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default value of the country if the fetch service is unavailable.
|
* The default value of the country if the fetch service is unavailable.
|
||||||
*
|
*
|
||||||
* @type {{name: string, dialCode: string, code: string}}
|
* @type {{
|
||||||
|
* code: string,
|
||||||
|
* dialCode: string,
|
||||||
|
* name: string
|
||||||
|
* }}
|
||||||
*/
|
*/
|
||||||
const DEFAULT_COUNTRY = {
|
const DEFAULT_COUNTRY = {
|
||||||
name: 'United States',
|
code: 'US',
|
||||||
dialCode: '+1',
|
dialCode: '+1',
|
||||||
code: 'US'
|
name: 'United States'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The expand icon of the dropdown menu.
|
||||||
|
*
|
||||||
|
* @type {ReactElement}
|
||||||
|
*/
|
||||||
|
const EXPAND_ICON = <ExpandIcon label = 'expand' />;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* React {@code Component} responsible for fetching and displaying dial-out
|
* React {@code Component} responsible for fetching and displaying dial-out
|
||||||
* country codes, as well as dialing a phone number.
|
* country codes, as well as dialing a phone number.
|
||||||
|
@ -108,7 +113,7 @@ class DialOutNumbersForm extends Component {
|
||||||
* display in the dropdown trigger.
|
* display in the dropdown trigger.
|
||||||
*
|
*
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
* returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const dialOutCodes = this.props._dialOutCodes;
|
const dialOutCodes = this.props._dialOutCodes;
|
||||||
|
@ -125,7 +130,7 @@ class DialOutNumbersForm extends Component {
|
||||||
* the dropdown trigger if not already set.
|
* the dropdown trigger if not already set.
|
||||||
*
|
*
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
* returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
if (!this.state.selectedCountry && nextProps._dialOutCodes) {
|
if (!this.state.selectedCountry && nextProps._dialOutCodes) {
|
||||||
|
@ -141,7 +146,6 @@ class DialOutNumbersForm extends Component {
|
||||||
*/
|
*/
|
||||||
render() {
|
render() {
|
||||||
const { t, _dialOutCodes } = this.props;
|
const { t, _dialOutCodes } = this.props;
|
||||||
|
|
||||||
const items
|
const items
|
||||||
= _dialOutCodes ? this._formatCountryCodes(_dialOutCodes) : [];
|
= _dialOutCodes ? this._formatCountryCodes(_dialOutCodes) : [];
|
||||||
|
|
||||||
|
@ -219,18 +223,16 @@ class DialOutNumbersForm extends Component {
|
||||||
* @returns {Array<Object>}
|
* @returns {Array<Object>}
|
||||||
*/
|
*/
|
||||||
_formatCountryCodes(countryCodes) {
|
_formatCountryCodes(countryCodes) {
|
||||||
|
|
||||||
return countryCodes.map(country => {
|
return countryCodes.map(country => {
|
||||||
const countryIcon
|
const countryIcon
|
||||||
= <CountryIcon countryCode = { `${country.code}` } />;
|
= <CountryIcon countryCode = { `${country.code}` } />;
|
||||||
|
|
||||||
const countryElement
|
const countryElement
|
||||||
= <span>{countryIcon} { country.name }</span>;
|
= <span>{countryIcon} { country.name }</span>;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: `${country.dialCode}`,
|
content: `${country.dialCode}`,
|
||||||
elemBefore: countryElement,
|
country,
|
||||||
country
|
elemBefore: countryElement
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -342,5 +344,5 @@ function _mapStateToProps(state) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default translate(connect(_mapStateToProps,
|
export default translate(
|
||||||
{ updateDialOutCodes })(DialOutNumbersForm));
|
connect(_mapStateToProps, { updateDialOutCodes })(DialOutNumbersForm));
|
||||||
|
|
Loading…
Reference in New Issue