2016-09-09 17:09:13 +02:00
|
|
|
import React from 'react'
|
2016-09-10 14:10:25 +02:00
|
|
|
import { LayerList } from './layers/list.jsx'
|
2016-09-10 22:08:26 +02:00
|
|
|
import { SourceList } from './sources/list.jsx'
|
2016-09-09 18:53:57 +02:00
|
|
|
import { SettingsEditor } from './settings.jsx'
|
2016-09-19 20:49:16 +02:00
|
|
|
import { About } from './about.jsx'
|
2016-09-10 16:11:43 +02:00
|
|
|
import { colors, fullHeight } from './theme.js'
|
2016-09-09 17:09:13 +02:00
|
|
|
|
2016-09-09 23:25:06 +02:00
|
|
|
/** The workspace drawer contains the editor components depending on the edit
|
|
|
|
* context chosen in the toolbar. It holds the state of the layers.*/
|
2016-09-09 17:09:13 +02:00
|
|
|
export class WorkspaceDrawer extends React.Component {
|
|
|
|
static propTypes = {
|
2016-09-09 23:25:06 +02:00
|
|
|
mapStyle: React.PropTypes.object.isRequired,
|
|
|
|
onStyleChanged: React.PropTypes.func.isRequired,
|
2016-09-10 22:08:26 +02:00
|
|
|
workContext: React.PropTypes.oneOf(['layers', 'settings', 'sources']).isRequired,
|
2016-09-10 16:26:39 +02:00
|
|
|
accessToken: React.PropTypes.string,
|
|
|
|
onAccessTokenChanged: React.PropTypes.func,
|
2016-09-21 08:34:48 +02:00
|
|
|
onReset: React.PropTypes.func,
|
2016-09-10 15:15:17 +02:00
|
|
|
}
|
2016-09-09 17:09:13 +02:00
|
|
|
|
2016-09-10 13:42:23 +02:00
|
|
|
onLayersChanged(changedLayers) {
|
|
|
|
const changedStyle = this.props.mapStyle.set('layers', changedLayers)
|
2016-09-09 23:25:06 +02:00
|
|
|
this.props.onStyleChanged(changedStyle)
|
|
|
|
}
|
|
|
|
|
2016-09-21 22:47:17 +02:00
|
|
|
onSourcesChanged(changedSources) {
|
|
|
|
const changedStyle = this.props.mapStyle.set('sources', changedSources)
|
|
|
|
this.props.onStyleChanged(changedStyle)
|
|
|
|
}
|
|
|
|
|
2016-09-09 17:09:13 +02:00
|
|
|
render() {
|
|
|
|
let workspaceContent = null
|
|
|
|
|
2016-09-10 22:08:26 +02:00
|
|
|
if(this.props.workContext === "sources") {
|
|
|
|
workspaceContent = <SourceList
|
2016-09-21 22:47:17 +02:00
|
|
|
onSourcesChanged={this.onSourcesChanged.bind(this)}
|
2016-09-10 22:08:26 +02:00
|
|
|
sources={this.props.mapStyle.get('sources')}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
|
2016-09-09 23:25:06 +02:00
|
|
|
if(this.props.workContext === "layers") {
|
2016-09-10 14:10:25 +02:00
|
|
|
workspaceContent = <LayerList
|
2016-09-09 23:25:06 +02:00
|
|
|
onLayersChanged={this.onLayersChanged.bind(this)}
|
2016-09-10 13:42:23 +02:00
|
|
|
layers={this.props.mapStyle.get('layers')}
|
2016-09-09 23:25:06 +02:00
|
|
|
/>
|
2016-09-09 17:09:13 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 23:25:06 +02:00
|
|
|
if(this.props.workContext === "settings") {
|
|
|
|
workspaceContent = <SettingsEditor
|
2016-09-21 08:34:48 +02:00
|
|
|
onReset={this.props.onReset}
|
2016-09-09 23:25:06 +02:00
|
|
|
onStyleChanged={this.props.onStyleChanged}
|
|
|
|
mapStyle={this.props.mapStyle}
|
2016-09-10 16:26:39 +02:00
|
|
|
accessToken={this.props.accessToken}
|
|
|
|
onAccessTokenChanged={this.props.onAccessTokenChanged}
|
2016-09-09 23:25:06 +02:00
|
|
|
/>
|
2016-09-09 18:53:57 +02:00
|
|
|
}
|
|
|
|
|
2016-09-19 20:49:16 +02:00
|
|
|
if(this.props.workContext === "about") {
|
|
|
|
workspaceContent = <About />
|
|
|
|
}
|
|
|
|
|
2016-09-09 17:09:13 +02:00
|
|
|
return <div style={{
|
2016-09-10 16:11:43 +02:00
|
|
|
...fullHeight,
|
2016-09-09 17:09:13 +02:00
|
|
|
zIndex: 100,
|
|
|
|
left: 60,
|
|
|
|
width: 300,
|
|
|
|
overflow: "hidden",
|
2016-09-10 16:11:43 +02:00
|
|
|
backgroundColor: colors.gray}
|
2016-09-09 17:09:13 +02:00
|
|
|
}>
|
|
|
|
{workspaceContent}
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
}
|