From aab0fda9acf58c638a03a43de4260c079adf258f Mon Sep 17 00:00:00 2001 From: sdtsui Date: Tue, 8 Aug 2017 13:37:16 -0700 Subject: [PATCH] Add actions and reducers for global modal --- ui/app/actions.js | 17 +++++++++++++++++ ui/app/reducers/app.js | 12 ++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ui/app/actions.js b/ui/app/actions.js index 13a767343..69fc46ca4 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -5,6 +5,11 @@ var actions = { GO_HOME: 'GO_HOME', goHome: goHome, + // modal state + MODAL_OPEN: 'UI_MODAL_OPEN', + MODAL_CLOSE: 'UI_MODAL_CLOSE', + showModal: showModal, + hideModal: hideModal, // sidebar state SIDEBAR_OPEN: 'UI_SIDEBAR_OPEN', SIDEBAR_CLOSE: 'UI_SIDEBAR_CLOSE', @@ -768,6 +773,18 @@ function useEtherscanProvider () { } } +function showModal () { + return { + type: actions.MODAL_OPEN, + } +} + +function hideModal () { + return { + type: actions.MODAL_CLOSE, + } +} + function showSidebar () { return { type: actions.SIDEBAR_OPEN, diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index bf1de4577..ac8cbf158 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -36,6 +36,7 @@ function reduceApp (state, action) { var appState = extend({ shouldClose: false, menuOpen: false, + modalOpen: false, sidebarOpen: false, currentView: seedWords ? seedConfView : defaultView, accountDetail: { @@ -58,6 +59,17 @@ function reduceApp (state, action) { sidebarOpen: false, }) + // modal methods: + case actions.MODAL_OPEN: + return extend(appState, { + modalOpen: true, + }) + + case actions.MODAL_CLOSE: + return extend(appState, { + modalOpen: false, + }) + // transition methods case actions.TRANSITION_FORWARD: