mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 11:37:58 +00:00
We previously relied on user roles to determine whether to render specific routes in our frontend components. A permissions-based model is replacing this approach. Follow up: #9695 Co-authored-by: Pranav <pranavrajs@gmail.com>
24 lines
521 B
Vue
24 lines
521 B
Vue
<script setup>
|
|
import { useStoreGetters } from 'dashboard/composables/store';
|
|
import { computed } from 'vue';
|
|
import { hasPermissions } from '../helper/permissionsHelper';
|
|
const props = defineProps({
|
|
permissions: {
|
|
type: Array,
|
|
required: true,
|
|
},
|
|
});
|
|
|
|
const getters = useStoreGetters();
|
|
const user = getters.getCurrentUser.value;
|
|
const hasPermission = computed(() =>
|
|
hasPermissions(props.permissions, user.permissions)
|
|
);
|
|
</script>
|
|
|
|
<template>
|
|
<div v-if="hasPermission">
|
|
<slot />
|
|
</div>
|
|
</template>
|