Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
return {
namespaced: true,
getters: {
left: (state, getters) => getters.evaluate(state.left.items),
right: (state, getters) => getters.evaluate(state.right.items),
evaluate: (state, getters, rootState, rootGetters) => (items) => {
return items.filter((item) => {
return !Object.keys(item.guard || {}).map((guard) => {
return (rootGetters[guard] === item.guard[guard])
}).includes(false)
})
},
},
mutations: {
toggle: (state, menu) => state[menu].active = !state[menu].active,
close: (state, menu) => state[menu].active = false,
open: (state, menu) => state[menu].active = true,
},
state: {
left: {
active: false,
items: [
{
icon: 'fa-tachometer-alt',
label: 'Dashboard',
route: {
name: 'dashboard'
},
guard: {
'account/isLoggedIn': false,
}
},
]
},
right: {
active: false,
items: [
{
icon: 'fa-lock',
label: 'Login',
route: {
name: 'auth.login',
},
guard: {
'account/isLoggedIn': false,
},
},
]
},
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.