refactor: replace role-based access checks with canAccess utility in menu components
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
This commit is contained in:
parent
57660d7991
commit
8799799214
4 changed files with 131 additions and 111 deletions
|
|
@ -2,17 +2,15 @@
|
|||
import MenuItem from 'components/00_home/MenuItem.vue';
|
||||
import { useNavigator } from 'src/stores/navigator';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { getRole } from 'src/services/keycloak';
|
||||
import { canAccess } from 'src/stores/utils';
|
||||
|
||||
const navigatorStore = useNavigator();
|
||||
const menu = ref<InstanceType<typeof MenuItem>['$props']['list']>([]);
|
||||
const role = ref();
|
||||
|
||||
onMounted(() => {
|
||||
navigatorStore.current.title = '';
|
||||
navigatorStore.current.path = [{ text: '' }];
|
||||
|
||||
role.value = getRole();
|
||||
menu.value = [
|
||||
{
|
||||
value: 'branch-management',
|
||||
|
|
@ -20,14 +18,7 @@ onMounted(() => {
|
|||
color: 'green',
|
||||
title: 'menu.branch',
|
||||
caption: 'menu.branchCaption',
|
||||
hidden:
|
||||
role.value.includes('admin') ||
|
||||
role.value.includes('branch_admin') ||
|
||||
role.value.includes('head_of_admin') ||
|
||||
role.value.includes('system') ||
|
||||
role.value.includes('owner')
|
||||
? false
|
||||
: true,
|
||||
hidden: !canAccess('branch'),
|
||||
},
|
||||
{
|
||||
value: 'personnel-management',
|
||||
|
|
@ -35,15 +26,7 @@ onMounted(() => {
|
|||
color: 'cyan',
|
||||
title: 'menu.user',
|
||||
caption: 'menu.userCaption',
|
||||
hidden:
|
||||
role.value.includes('admin') ||
|
||||
role.value.includes('branch_admin') ||
|
||||
role.value.includes('head_of_admin') ||
|
||||
role.value.includes('system') ||
|
||||
role.value.includes('owner') ||
|
||||
role.value.includes('branch_manager')
|
||||
? false
|
||||
: true,
|
||||
hidden: !canAccess('personnel'),
|
||||
},
|
||||
{
|
||||
value: 'customer-management',
|
||||
|
|
@ -52,6 +35,7 @@ onMounted(() => {
|
|||
title: 'menu.customer',
|
||||
caption: 'menu.customerCaption',
|
||||
isax: true,
|
||||
hidden: !canAccess('customer'),
|
||||
},
|
||||
{
|
||||
value: 'product-service',
|
||||
|
|
@ -115,6 +99,7 @@ onMounted(() => {
|
|||
title: 'menu.dashboard',
|
||||
caption: 'menu.dashboardCaption',
|
||||
isax: true,
|
||||
hidden: !canAccess('dashBoard'),
|
||||
},
|
||||
];
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue