diff --git a/src/app.jsx b/src/app.jsx
index e4011912..3ad138c8 100644
--- a/src/app.jsx
+++ b/src/app.jsx
@@ -66,6 +66,7 @@ export default class App extends React.Component {
render() {
return
0}
onStyleSave={this.onStyleSave.bind(this)}
onStyleUpload={this.onStyleUpload.bind(this)}
onStyleDownload={this.onStyleDownload.bind(this)}
diff --git a/src/stylestore.js b/src/stylestore.js
index 7da20b97..937d2c3e 100644
--- a/src/stylestore.js
+++ b/src/stylestore.js
@@ -11,7 +11,7 @@ const storage = {
const emptyStyle = {
version: 8,
sources: {},
- layers: []
+ layers: [],
}
// Return style ids and dates of all styles stored in local storage
diff --git a/src/toolbar.jsx b/src/toolbar.jsx
index f11b39f0..1e3ba41e 100644
--- a/src/toolbar.jsx
+++ b/src/toolbar.jsx
@@ -19,15 +19,11 @@ export class Toolbar extends React.Component {
onStyleSave: React.PropTypes.func,
onOpenSettings: React.PropTypes.func,
onOpenLayers: React.PropTypes.func,
+ // Whether a style is available for download or saving
+ // A style with no layers should not be available
+ styleAvailable: React.PropTypes.bool,
}
- constructor(props) {
- super(props);
- this.state = {
- styleUploaded: false
- }
- }
-
onUpload(_, files) {
const [e, file] = files[0];
const reader = new FileReader();
@@ -35,17 +31,26 @@ export class Toolbar extends React.Component {
reader.onload = e => {
const style = JSON.parse(e.target.result);
this.props.onStyleUpload(style);
- this.setState({
- styleUploaded: true
- })
}
reader.onerror = e => console.log(e.target);
}
- render() {
- let downloadButton = null
- if(this.props.styleUploaded) {
- downloadButton =
+ saveButton() {
+ if(this.props.styleAvailable) {
+ return
+
+
+ }
+ return null
+ }
+
+ downloadButton() {
+ if(this.props.styleAvailable) {
+ return
}
+ return null
+ }
+ render() {
return
-
- {downloadButton}
-
-
-
-
-
-
-
+ {this.downloadButton()}
+ {this.saveButton()}