From 58cda9cc7fb79ca9df6746de7f9662bc08dc156a Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 13 Oct 2017 12:29:40 +0200 Subject: initial commit --- src/stores/UIStore.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/stores/UIStore.js (limited to 'src/stores/UIStore.js') diff --git a/src/stores/UIStore.js b/src/stores/UIStore.js new file mode 100644 index 000000000..cb45b88b5 --- /dev/null +++ b/src/stores/UIStore.js @@ -0,0 +1,34 @@ +import { action, observable } from 'mobx'; + +import Store from './lib/Store'; + +export default class UIStore extends Store { + @observable showServicesUpdatedInfoBar = false; + + constructor(...args) { + super(...args); + + // Register action handlers + this.actions.ui.openSettings.listen(this._openSettings.bind(this)); + this.actions.ui.closeSettings.listen(this._closeSettings.bind(this)); + this.actions.ui.toggleServiceUpdatedInfoBar.listen(this._toggleServiceUpdatedInfoBar.bind(this)); + } + + // Actions + @action _openSettings({ path = '/settings' }) { + const settingsPath = path !== '/settings' ? `/settings/${path}` : path; + this.stores.router.push(settingsPath); + } + + @action _closeSettings(): void { + this.stores.router.push('/'); + } + + @action _toggleServiceUpdatedInfoBar({ visible }) { + let visibility = visible; + if (visibility === null) { + visibility = !this.showServicesUpdatedInfoBar; + } + this.showServicesUpdatedInfoBar = visibility; + } +} -- cgit v1.2.3-70-g09d2