Skip to content

Commit

Permalink
Merge branch 'release/v5.3.1' into version/5.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
demtario committed Nov 3, 2023
2 parents c2c6630 + 83b493b commit ee371a3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "store-admin",
"version": "5.3.0",
"version": "5.3.1",
"private": true,
"description": "Admin panel for Heseya Store API",
"author": "Heseya",
Expand Down
1 change: 1 addition & 0 deletions src/components/root/DesktopNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<router-link
v-if="item.type === MenuItemType.Link"
:key="i"
v-can="item.can"
class="nav__link"
:to="item.to"
:exact="item.exact"
Expand Down
2 changes: 1 addition & 1 deletion src/consts/menuItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const MENU_ITEMS: MenuItem[] = [
svgIconPath: 'icons/orders-icon.svg',
label: 'models.orders',
disabled: true,
can: PERMISSIONS_TREE.Orders.ShowSummary,
can: PERMISSIONS_TREE.Orders.Show,
},
{ id: nextId(), type: MenuItemType.Spacer, disabled: true },
{
Expand Down
12 changes: 11 additions & 1 deletion src/store/menuItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { actionTree, getterTree, mutationTree } from 'typed-vuex'
import { App } from '@heseya/store-core'

import { DEFAULT_MENU_ITEMS, MenuItemType, MenuItem, MenuLink } from '@/consts/menuItems'
import { hasAccess } from '@/utils/hasAccess'
import { accessor } from '.'
import { PERMISSIONS_TREE } from '@/consts/permissions'

const state = () => ({
activeItems: DEFAULT_MENU_ITEMS,
Expand All @@ -13,6 +16,12 @@ const getters = getterTree(state, {
(item: MenuItem) => item.type === MenuItemType.Link,
) as MenuLink[]
},

items(state): MenuItem[] {
return state.activeItems.filter((item) =>
`can` in item ? hasAccess(item.can || [])(accessor.auth.user?.permissions || []) : true,
)
},
})

const mutations = mutationTree(state, {
Expand Down Expand Up @@ -45,7 +54,8 @@ const actions = actionTree(

async initMicrofrontendMenuItems({ dispatch, rootGetters }) {
if (rootGetters['auth/isLogged']) {
await dispatch('apps/fetch', { limit: 500 }, { root: true })
if (hasAccess(PERMISSIONS_TREE.Apps.Show)(accessor.auth.user?.permissions || []))
await dispatch('apps/fetch', { limit: 500 }, { root: true })
dispatch('removeNotExistingApps')
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/settings/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
v-for="item in group"
v-show="!isLinkHidden(item)"
:key="item.id"
:v-can="item.can"
v-can="item.can"
:name="$t(item.label).toString()"
:url="item.to"
:icon-class="item.iconClass"
Expand Down

0 comments on commit ee371a3

Please sign in to comment.