Notify on saved options

This commit is contained in:
hensm
2018-12-12 13:13:18 +00:00
parent 82e224fd80
commit 4e682e4e1f
3 changed files with 30 additions and 3 deletions

View File

@@ -119,7 +119,10 @@
, "optionsReset": { , "optionsReset": {
"message": "Restore Defaults" "message": "Restore Defaults"
} }
, "optionsSubmit": { , "optionsSave": {
"message": "Submit" "message": "Save"
}
, "optionsSaved": {
"message": "Saved!"
} }
} }

View File

@@ -46,6 +46,7 @@ class App extends Component {
, bridgeInfo: null , bridgeInfo: null
, bridgeLoading: true , bridgeLoading: true
, isFormValid: true , isFormValid: true
, hasSaved: false
}; };
this.handleReset = this.handleReset.bind(this); this.handleReset = this.handleReset.bind(this);
@@ -104,6 +105,16 @@ class App extends Component {
} }
} }
this.setState({
hasSaved: true
}, () => {
window.setTimeout(() => {
this.setState({
hasSaved: false
});
}, 1000)
});
// Send update message / event // Send update message / event
browser.runtime.sendMessage({ browser.runtime.sendMessage({
subject: "optionsUpdated" subject: "optionsUpdated"
@@ -270,13 +281,20 @@ class App extends Component {
</fieldset> </fieldset>
<div id="buttons"> <div id="buttons">
<div id="status-line">
{ do {
if (this.state.hasSaved) {
_("optionsSaved")
}
}}
</div>
<button onClick={ this.handleReset }> <button onClick={ this.handleReset }>
{ _("optionsReset") } { _("optionsReset") }
</button> </button>
<button type="submit" <button type="submit"
default default
disabled={ !this.state.isFormValid }> disabled={ !this.state.isFormValid }>
{ _("optionsSubmit") } { _("optionsSave") }
</button> </button>
</div> </div>
</form> </form>

View File

@@ -12,6 +12,8 @@
} }
#buttons { #buttons {
display: flex;
align-items: center;
align-self: flex-end; align-self: flex-end;
margin-block-start: 5px; margin-block-start: 5px;
} }
@@ -20,6 +22,10 @@
margin-inline-end: 5px; margin-inline-end: 5px;
} }
#status-line {
color: graytext;
}
.bridge { .bridge {
margin-top: 20px; margin-top: 20px;