first commit
This commit is contained in:
31
src/components/security/FeatureGate.vue
Normal file
31
src/components/security/FeatureGate.vue
Normal file
@@ -0,0 +1,31 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { useEntitlementsStore } from '@/stores/entitlementsStore'
|
||||
|
||||
const props = defineProps({
|
||||
feature: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
fallback: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
})
|
||||
|
||||
const ent = useEntitlementsStore()
|
||||
|
||||
const allowed = computed(() => {
|
||||
return ent.can(props.feature)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="allowed">
|
||||
<slot />
|
||||
</template>
|
||||
|
||||
<template v-else-if="fallback">
|
||||
<slot name="fallback" />
|
||||
</template>
|
||||
</template>
|
||||
Reference in New Issue
Block a user