first implementation

This commit is contained in:
Tobias Miesel
2018-10-17 15:21:32 +02:00
committed by Manuel Bouza
parent aff72595c7
commit ade0055441
20 changed files with 65105 additions and 52 deletions

View File

@@ -0,0 +1,57 @@
import React, { Component } from 'react'
import { observable } from 'mobx'
import { observer } from 'mobx-react'
@observer
class Setup extends Component {
@observable loading = true
@observable subdomain = ""
@observable apiKey = ""
componentDidMount() {
chrome.storage.sync.get(null, (store) => {
this.loading = false
this.subdomain = store.subdomain || ""
this.apiKey = store.api_key || ""
})
}
// EVENTS
onChange = (e) => {
this[e.target.name] = e.target.value
}
onSubmit = (_e) => {
chrome.storage.sync.set({
subdomain: this.subdomain.trim(),
api_key: this.apiKey.trim(),
}, () => window.close())
}
// RENDER -------------------------------------------------------------------
render() {
if (this.loading) return null
return (
<form onSubmit={this.onSubmit}>
<input
type="text"
name="subdomain"
value={this.subdomain}
onChange={this.onChange}
/>
<input
type="text"
name="apiKey"
value={this.apiKey}
onChange={this.onChange}
/>
<button>Save</button>
</form>
)
}
}
export default Setup