mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Move main drop-down state to component state
This commit is contained in:
parent
6ec387b675
commit
51a5e66cbb
@ -2,10 +2,6 @@ var actions = {
|
|||||||
GO_HOME: 'GO_HOME',
|
GO_HOME: 'GO_HOME',
|
||||||
goHome: goHome,
|
goHome: goHome,
|
||||||
// menu state
|
// menu state
|
||||||
TOGGLE_MENU: 'TOGGLE_MENU',
|
|
||||||
toggleMenu: toggleMenu,
|
|
||||||
SET_MENU_STATE: 'SET_MENU_STATE',
|
|
||||||
closeMenu: closeMenu,
|
|
||||||
getNetworkStatus: 'getNetworkStatus',
|
getNetworkStatus: 'getNetworkStatus',
|
||||||
|
|
||||||
// remote state
|
// remote state
|
||||||
@ -125,21 +121,6 @@ function goHome () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// menu state
|
|
||||||
|
|
||||||
function toggleMenu () {
|
|
||||||
return {
|
|
||||||
type: actions.TOGGLE_MENU,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeMenu () {
|
|
||||||
return {
|
|
||||||
type: actions.SET_MENU_STATE,
|
|
||||||
value: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// async actions
|
// async actions
|
||||||
|
|
||||||
function tryUnlockMetamask (password) {
|
function tryUnlockMetamask (password) {
|
||||||
|
@ -178,7 +178,7 @@ App.prototype.renderAppBar = function () {
|
|||||||
onClick: (event) => {
|
onClick: (event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
this.props.dispatch(actions.toggleMenu())
|
this.setState({ isMainMenuOpen: true })
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
@ -241,10 +241,13 @@ App.prototype.renderNetworkDropdown = function () {
|
|||||||
|
|
||||||
App.prototype.renderDropdown = function () {
|
App.prototype.renderDropdown = function () {
|
||||||
const props = this.props
|
const props = this.props
|
||||||
|
const state = this.state || {}
|
||||||
|
const isOpen = state.isMainMenuOpen
|
||||||
|
|
||||||
return h(MenuDroppo, {
|
return h(MenuDroppo, {
|
||||||
isOpen: props.menuOpen,
|
isOpen: isOpen,
|
||||||
onClickOutside: (event) => {
|
onClickOutside: (event) => {
|
||||||
this.props.dispatch(actions.closeMenu())
|
this.setState({ isMainMenuOpen: !isOpen })
|
||||||
},
|
},
|
||||||
style: {
|
style: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
@ -263,21 +266,21 @@ App.prototype.renderDropdown = function () {
|
|||||||
|
|
||||||
h(DropMenuItem, {
|
h(DropMenuItem, {
|
||||||
label: 'Settings',
|
label: 'Settings',
|
||||||
closeMenu: () => this.props.dispatch(actions.closeMenu()),
|
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
||||||
action: () => this.props.dispatch(actions.showConfigPage()),
|
action: () => this.props.dispatch(actions.showConfigPage()),
|
||||||
icon: h('i.fa.fa-gear.fa-lg', { ariaHidden: true }),
|
icon: h('i.fa.fa-gear.fa-lg', { ariaHidden: true }),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
h(DropMenuItem, {
|
h(DropMenuItem, {
|
||||||
label: 'Lock',
|
label: 'Lock',
|
||||||
closeMenu: () => this.props.dispatch(actions.closeMenu()),
|
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
||||||
action: () => this.props.dispatch(actions.lockMetamask()),
|
action: () => this.props.dispatch(actions.lockMetamask()),
|
||||||
icon: h('i.fa.fa-lock.fa-lg', { ariaHidden: true }),
|
icon: h('i.fa.fa-lock.fa-lg', { ariaHidden: true }),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
h(DropMenuItem, {
|
h(DropMenuItem, {
|
||||||
label: 'Help',
|
label: 'Help',
|
||||||
closeMenu: () => this.props.dispatch(actions.closeMenu()),
|
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
|
||||||
action: () => this.props.dispatch(actions.showInfoPage()),
|
action: () => this.props.dispatch(actions.showInfoPage()),
|
||||||
icon: h('i.fa.fa-question.fa-lg', { ariaHidden: true }),
|
icon: h('i.fa.fa-question.fa-lg', { ariaHidden: true }),
|
||||||
}),
|
}),
|
||||||
|
@ -43,16 +43,6 @@ function reduceApp (state, action) {
|
|||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
|
||||||
case actions.TOGGLE_MENU:
|
|
||||||
return extend(appState, {
|
|
||||||
menuOpen: !appState.menuOpen,
|
|
||||||
})
|
|
||||||
|
|
||||||
case actions.SET_MENU_STATE:
|
|
||||||
return extend(appState, {
|
|
||||||
menuOpen: action.value,
|
|
||||||
})
|
|
||||||
|
|
||||||
// intialize
|
// intialize
|
||||||
|
|
||||||
case actions.SHOW_CREATE_VAULT:
|
case actions.SHOW_CREATE_VAULT:
|
||||||
|
Loading…
Reference in New Issue
Block a user