diff --git a/src/components/modals/LoadingModal.jsx b/src/components/modals/LoadingModal.jsx new file mode 100644 index 00000000..42b8ecaf --- /dev/null +++ b/src/components/modals/LoadingModal.jsx @@ -0,0 +1,49 @@ +import React from 'react' +import PropTypes from 'prop-types' + +import Button from '../Button' +import Modal from './Modal' + + +class LoadingModal extends React.Component { + static propTypes = { + isOpen: PropTypes.bool.isRequired, + onCancel: PropTypes.func.isRequired, + title: PropTypes.string.isRequired, + message: PropTypes.node.isRequired, + } + + constructor(props) { + super(props); + } + + underlayOnClick(e) { + // This stops click events falling through to underlying modals. + e.stopPropagation(); + } + + render() { + return underlayProps(e) + }} + closeable={false} + title={this.props.title} + onOpenToggle={() => this.props.onCancel()} + > +

+ {this.props.message} +

+

+ +

+
+ } +} + +export default LoadingModal diff --git a/src/components/modals/Modal.jsx b/src/components/modals/Modal.jsx index 2a4a97c9..58bbbdcd 100644 --- a/src/components/modals/Modal.jsx +++ b/src/components/modals/Modal.jsx @@ -11,6 +11,12 @@ class Modal extends React.Component { title: PropTypes.string.isRequired, onOpenToggle: PropTypes.func.isRequired, children: PropTypes.node, + underlayClickExits: PropTypes.bool, + underlayProps: PropTypes.object, + } + + static defaultProps = { + underlayClickExits: true } getApplicationNode() { @@ -21,6 +27,8 @@ class Modal extends React.Component { if(this.props.isOpen) { return { + } + + const activeRequest = request(reqOpts, (error, response, body) => { + this.setState({ + activeRequest: null, + activeRequestUrl: null + }); + if (!error && response.statusCode == 200) { const mapStyle = style.ensureStyleValidity(JSON.parse(body)) console.log('Loaded style ', mapStyle.id) @@ -76,6 +97,11 @@ class OpenModal extends React.Component { console.warn('Could not open the style URL', styleUrl) } }) + + this.setState({ + activeRequest: activeRequest, + activeRequestUrl: reqOpts.url + }) } onOpenUrl() { @@ -169,6 +195,13 @@ class OpenModal extends React.Component { {styleOptions} + + this.onCancelActiveRequest(e)} + message={"Loading: "+this.state.activeRequestUrl} + /> } } diff --git a/src/styles/_components.scss b/src/styles/_components.scss index 048307de..170d855d 100644 --- a/src/styles/_components.scss +++ b/src/styles/_components.scss @@ -135,3 +135,9 @@ color: $color-red; } } + +.maputnik-dialog { + &__buttons { + text-align: right; + } +}