mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-30 23:05:28 +01:00
Code review fixes
- Added docs to export modal - Fixed 'source type' doc in data sources modal
This commit is contained in:
parent
9b4d924dff
commit
223721a65d
5 changed files with 62 additions and 7 deletions
|
@ -11,6 +11,7 @@ import Button from '../Button'
|
||||||
import Modal from './Modal'
|
import Modal from './Modal'
|
||||||
import {MdFileDownload} from 'react-icons/md'
|
import {MdFileDownload} from 'react-icons/md'
|
||||||
import style from '../../libs/style'
|
import style from '../../libs/style'
|
||||||
|
import fieldSpecAdditional from '../../libs/field-spec-additional'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,6 +71,7 @@ class ExportModal extends React.Component {
|
||||||
isOpen={this.props.isOpen}
|
isOpen={this.props.isOpen}
|
||||||
onOpenToggle={this.props.onOpenToggle}
|
onOpenToggle={this.props.onOpenToggle}
|
||||||
title={'Export Style'}
|
title={'Export Style'}
|
||||||
|
className="maputnik-export-modal"
|
||||||
>
|
>
|
||||||
|
|
||||||
<div className="maputnik-modal-section">
|
<div className="maputnik-modal-section">
|
||||||
|
@ -79,19 +81,28 @@ class ExportModal extends React.Component {
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<InputBlock label={"MapTiler Access Token: "}>
|
<InputBlock
|
||||||
|
label={fieldSpecAdditional.maputnik.mapbox_access_token.label}
|
||||||
|
fieldSpec={fieldSpecAdditional.maputnik.mapbox_access_token}
|
||||||
|
>
|
||||||
<StringInput
|
<StringInput
|
||||||
value={(this.props.mapStyle.metadata || {})['maputnik:openmaptiles_access_token']}
|
value={(this.props.mapStyle.metadata || {})['maputnik:openmaptiles_access_token']}
|
||||||
onChange={this.changeMetadataProperty.bind(this, "maputnik:openmaptiles_access_token")}
|
onChange={this.changeMetadataProperty.bind(this, "maputnik:openmaptiles_access_token")}
|
||||||
/>
|
/>
|
||||||
</InputBlock>
|
</InputBlock>
|
||||||
<InputBlock label={"Mapbox Access Token: "}>
|
<InputBlock
|
||||||
|
label={fieldSpecAdditional.maputnik.maptiler_access_token.label}
|
||||||
|
fieldSpec={fieldSpecAdditional.maputnik.maptiler_access_token}
|
||||||
|
>
|
||||||
<StringInput
|
<StringInput
|
||||||
value={(this.props.mapStyle.metadata || {})['maputnik:mapbox_access_token']}
|
value={(this.props.mapStyle.metadata || {})['maputnik:mapbox_access_token']}
|
||||||
onChange={this.changeMetadataProperty.bind(this, "maputnik:mapbox_access_token")}
|
onChange={this.changeMetadataProperty.bind(this, "maputnik:mapbox_access_token")}
|
||||||
/>
|
/>
|
||||||
</InputBlock>
|
</InputBlock>
|
||||||
<InputBlock label={"Thunderforest Access Token: "}>
|
<InputBlock
|
||||||
|
label={fieldSpecAdditional.maputnik.thunderforest_access_token.label}
|
||||||
|
fieldSpec={fieldSpecAdditional.maputnik.thunderforest_access_token}
|
||||||
|
>
|
||||||
<StringInput
|
<StringInput
|
||||||
value={(this.props.mapStyle.metadata || {})['maputnik:thunderforest_access_token']}
|
value={(this.props.mapStyle.metadata || {})['maputnik:thunderforest_access_token']}
|
||||||
onChange={this.changeMetadataProperty.bind(this, "maputnik:thunderforest_access_token")}
|
onChange={this.changeMetadataProperty.bind(this, "maputnik:thunderforest_access_token")}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import SelectInput from '../inputs/SelectInput'
|
||||||
import EnumInput from '../inputs/EnumInput'
|
import EnumInput from '../inputs/EnumInput'
|
||||||
import ColorField from '../fields/ColorField'
|
import ColorField from '../fields/ColorField'
|
||||||
import Modal from './Modal'
|
import Modal from './Modal'
|
||||||
|
import fieldSpecAdditional from '../../libs/field-spec-additional'
|
||||||
|
|
||||||
class SettingsModal extends React.Component {
|
class SettingsModal extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -116,7 +117,10 @@ class SettingsModal extends React.Component {
|
||||||
/>
|
/>
|
||||||
</InputBlock>
|
</InputBlock>
|
||||||
|
|
||||||
<InputBlock label={"Mapbox Access Token"} fieldSpec={{doc: "Public access token for Mapbox services."}}>
|
<InputBlock
|
||||||
|
label={fieldSpecAdditional.maputnik.mapbox_access_token.label}
|
||||||
|
fieldSpec={fieldSpecAdditional.maputnik.mapbox_access_token}
|
||||||
|
>
|
||||||
<StringInput {...inputProps}
|
<StringInput {...inputProps}
|
||||||
data-wd-key="modal-settings.maputnik:mapbox_access_token"
|
data-wd-key="modal-settings.maputnik:mapbox_access_token"
|
||||||
value={metadata['maputnik:mapbox_access_token']}
|
value={metadata['maputnik:mapbox_access_token']}
|
||||||
|
@ -124,7 +128,10 @@ class SettingsModal extends React.Component {
|
||||||
/>
|
/>
|
||||||
</InputBlock>
|
</InputBlock>
|
||||||
|
|
||||||
<InputBlock label={"MapTiler Access Token"} fieldSpec={{doc: "Public access token for MapTiler Cloud."}}>
|
<InputBlock
|
||||||
|
label={fieldSpecAdditional.maputnik.maptiler_access_token.label}
|
||||||
|
fieldSpec={fieldSpecAdditional.maputnik.maptiler_access_token}
|
||||||
|
>
|
||||||
<StringInput {...inputProps}
|
<StringInput {...inputProps}
|
||||||
data-wd-key="modal-settings.maputnik:openmaptiles_access_token"
|
data-wd-key="modal-settings.maputnik:openmaptiles_access_token"
|
||||||
value={metadata['maputnik:openmaptiles_access_token']}
|
value={metadata['maputnik:openmaptiles_access_token']}
|
||||||
|
@ -132,7 +139,10 @@ class SettingsModal extends React.Component {
|
||||||
/>
|
/>
|
||||||
</InputBlock>
|
</InputBlock>
|
||||||
|
|
||||||
<InputBlock label={"Thunderforest Access Token"} fieldSpec={{doc: "Public access token for Thunderforest services."}}>
|
<InputBlock
|
||||||
|
label={fieldSpecAdditional.maputnik.thunderforest_access_token.label}
|
||||||
|
fieldSpec={fieldSpecAdditional.maputnik.thunderforest_access_token}
|
||||||
|
>
|
||||||
<StringInput {...inputProps}
|
<StringInput {...inputProps}
|
||||||
data-wd-key="modal-settings.maputnik:thunderforest_access_token"
|
data-wd-key="modal-settings.maputnik:thunderforest_access_token"
|
||||||
value={metadata['maputnik:thunderforest_access_token']}
|
value={metadata['maputnik:thunderforest_access_token']}
|
||||||
|
|
|
@ -167,6 +167,17 @@ class AddSource extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
// Kind of a hack because the type changes, however maputnik has 1..n
|
||||||
|
// options per type, for example
|
||||||
|
//
|
||||||
|
// - 'geojson' - 'GeoJSON (URL)' and 'GeoJSON (JSON)'
|
||||||
|
// - 'raster' - 'Raster (TileJSON URL)' and 'Raster (XYZ URL)'
|
||||||
|
//
|
||||||
|
// So we just ignore the values entirely as they are self explanatory
|
||||||
|
const sourceTypeFieldSpec = {
|
||||||
|
doc: latest.source_vector.type.doc
|
||||||
|
};
|
||||||
|
|
||||||
return <div className="maputnik-add-source">
|
return <div className="maputnik-add-source">
|
||||||
<InputBlock label={"Source ID"} fieldSpec={{doc: "Unique ID that identifies the source and is used in the layer to reference the source."}}>
|
<InputBlock label={"Source ID"} fieldSpec={{doc: "Unique ID that identifies the source and is used in the layer to reference the source."}}>
|
||||||
<StringInput
|
<StringInput
|
||||||
|
@ -174,7 +185,7 @@ class AddSource extends React.Component {
|
||||||
onChange={v => this.setState({ sourceId: v})}
|
onChange={v => this.setState({ sourceId: v})}
|
||||||
/>
|
/>
|
||||||
</InputBlock>
|
</InputBlock>
|
||||||
<InputBlock label={"Source Type"} fieldSpec={latest.source_vector.type}>
|
<InputBlock label={"Source Type"} fieldSpec={sourceTypeFieldSpec}>
|
||||||
<SelectInput
|
<SelectInput
|
||||||
options={[
|
options={[
|
||||||
['geojson_json', 'GeoJSON (JSON)'],
|
['geojson_json', 'GeoJSON (JSON)'],
|
||||||
|
|
18
src/libs/field-spec-additional.js
Normal file
18
src/libs/field-spec-additional.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
const spec = {
|
||||||
|
maputnik: {
|
||||||
|
mapbox_access_token: {
|
||||||
|
label: "Mapbox Access Token",
|
||||||
|
doc: "Public access token for Mapbox services."
|
||||||
|
},
|
||||||
|
maptiler_access_token: {
|
||||||
|
label: "MapTiler Access Token",
|
||||||
|
doc: "Public access token for MapTiler Cloud."
|
||||||
|
},
|
||||||
|
thunderforest_access_token: {
|
||||||
|
label: "Thunderforest Access Token",
|
||||||
|
doc: "Public access token for Thunderforest services."
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default spec;
|
|
@ -113,6 +113,11 @@
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.maputnik-export-modal {
|
||||||
|
width: 400px;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.maputnik-add-layer {
|
.maputnik-add-layer {
|
||||||
@extend .clearfix;
|
@extend .clearfix;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue