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; } }