mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 17:11:17 +01:00
Prevented overlapping modals in react tree and fixed request canceling.
This commit is contained in:
parent
805133d10c
commit
e6da977c48
2 changed files with 48 additions and 41 deletions
|
@ -40,7 +40,7 @@
|
||||||
"prop-types": "^15.6.0",
|
"prop-types": "^15.6.0",
|
||||||
"react": "^16.3.2",
|
"react": "^16.3.2",
|
||||||
"react-aria-menubutton": "^5.1.1",
|
"react-aria-menubutton": "^5.1.1",
|
||||||
"react-aria-modal": "^2.12.1",
|
"react-aria-modal": "^3.0.0",
|
||||||
"react-autobind": "^1.0.6",
|
"react-autobind": "^1.0.6",
|
||||||
"react-autocomplete": "^1.7.2",
|
"react-autocomplete": "^1.7.2",
|
||||||
"react-codemirror2": "^4.2.1",
|
"react-codemirror2": "^4.2.1",
|
||||||
|
|
|
@ -76,7 +76,10 @@ class OpenModal extends React.Component {
|
||||||
onStyleSelect = (styleUrl) => {
|
onStyleSelect = (styleUrl) => {
|
||||||
this.clearError();
|
this.clearError();
|
||||||
|
|
||||||
|
const requestController = new AbortController();
|
||||||
|
|
||||||
const activeRequest = fetch(styleUrl, {
|
const activeRequest = fetch(styleUrl, {
|
||||||
|
signal: requestController.signal,
|
||||||
mode: 'cors',
|
mode: 'cors',
|
||||||
credentials: "same-origin"
|
credentials: "same-origin"
|
||||||
})
|
})
|
||||||
|
@ -165,49 +168,53 @@ class OpenModal extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Modal
|
return (
|
||||||
data-wd-key="open-modal"
|
<div>
|
||||||
isOpen={this.props.isOpen}
|
<Modal
|
||||||
onOpenToggle={() => this.onOpenToggle()}
|
data-wd-key="open-modal"
|
||||||
title={'Open Style'}
|
isOpen={this.props.isOpen}
|
||||||
>
|
onOpenToggle={() => this.onOpenToggle()}
|
||||||
{errorElement}
|
title={'Open Style'}
|
||||||
<section className="maputnik-modal-section">
|
>
|
||||||
<h2>Upload Style</h2>
|
{errorElement}
|
||||||
<p>Upload a JSON style from your computer.</p>
|
<section className="maputnik-modal-section">
|
||||||
<FileReaderInput onChange={this.onUpload} tabIndex="-1">
|
<h2>Upload Style</h2>
|
||||||
<Button className="maputnik-upload-button"><FileUploadIcon /> Upload</Button>
|
<p>Upload a JSON style from your computer.</p>
|
||||||
</FileReaderInput>
|
<FileReaderInput onChange={this.onUpload} tabIndex="-1">
|
||||||
</section>
|
<Button className="maputnik-upload-button"><FileUploadIcon /> Upload</Button>
|
||||||
|
</FileReaderInput>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section className="maputnik-modal-section">
|
<section className="maputnik-modal-section">
|
||||||
<h2>Load from URL</h2>
|
<h2>Load from URL</h2>
|
||||||
<p>
|
<p>
|
||||||
Load from a URL. Note that the URL must have <a href="https://enable-cors.org" target="_blank" rel="noopener noreferrer">CORS enabled</a>.
|
Load from a URL. Note that the URL must have <a href="https://enable-cors.org" target="_blank" rel="noopener noreferrer">CORS enabled</a>.
|
||||||
</p>
|
</p>
|
||||||
<input data-wd-key="open-modal.url.input" type="text" ref={(input) => this.styleUrlElement = input} className="maputnik-input" placeholder="Enter URL..."/>
|
<input data-wd-key="open-modal.url.input" type="text" ref={(input) => this.styleUrlElement = input} className="maputnik-input" placeholder="Enter URL..."/>
|
||||||
<div>
|
<div>
|
||||||
<Button data-wd-key="open-modal.url.button" className="maputnik-big-button" onClick={this.onOpenUrl}>Open URL</Button>
|
<Button data-wd-key="open-modal.url.button" className="maputnik-big-button" onClick={this.onOpenUrl}>Open URL</Button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className="maputnik-modal-section maputnik-modal-section--shrink">
|
<section className="maputnik-modal-section maputnik-modal-section--shrink">
|
||||||
<h2>Gallery Styles</h2>
|
<h2>Gallery Styles</h2>
|
||||||
<p>
|
<p>
|
||||||
Open one of the publicly available styles to start from.
|
Open one of the publicly available styles to start from.
|
||||||
</p>
|
</p>
|
||||||
<div className="maputnik-style-gallery-container">
|
<div className="maputnik-style-gallery-container">
|
||||||
{styleOptions}
|
{styleOptions}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
<LoadingModal
|
<LoadingModal
|
||||||
isOpen={!!this.state.activeRequest}
|
isOpen={!!this.state.activeRequest}
|
||||||
title={'Loading style'}
|
title={'Loading style'}
|
||||||
onCancel={(e) => this.onCancelActiveRequest(e)}
|
onCancel={(e) => this.onCancelActiveRequest(e)}
|
||||||
message={"Loading: "+this.state.activeRequestUrl}
|
message={"Loading: "+this.state.activeRequestUrl}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue