flaschengeist-frontend/src/components/navigation/ShortCutLink.vue

39 lines
923 B
Vue
Raw Normal View History

<template>
2020-10-31 18:33:05 +00:00
<q-btn flat dense :icon="icon" :to="{ name: link }" v-if="hasPermissions"/>
</template>
<script lang="ts">
2020-10-31 18:33:05 +00:00
import {computed, defineComponent} from '@vue/composition-api';
import {Store} from "vuex";
import {StateInterface} from "src/store";
export default defineComponent({
name: 'ShortCutLink',
props: {
link: {
required: true,
type: String
},
icon: {
required: true,
type: String
2020-10-31 18:33:05 +00:00
},
permissions: {
default: undefined
}
2020-10-31 18:33:05 +00:00
},
setup(props, {root}) {
const hasPermissions = computed(() => {
let permissions = props.permissions
if (permissions) {
return (<string[]>permissions).every(permission => {
return (<{'user/permissions': string[]}>(<Store<StateInterface>>root.$store).getters)['user/permissions'].includes(permission)
})
}
return true
})
return {hasPermissions}
}
});
</script>