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

36 lines
944 B
Vue
Raw Normal View History

2020-10-02 07:13:14 +00:00
<template>
<q-item v-if="isGranted" clickable tag="a" target="self" :to="{ name: entry.link }">
<q-item-section v-if="entry.icon" avatar>
<q-icon :name="entry.icon" />
2020-10-02 07:13:14 +00:00
</q-item-section>
<q-item-section>
<q-item-label>{{ title }}</q-item-label>
2020-10-02 07:13:14 +00:00
</q-item-section>
</q-item>
</template>
<script lang="ts">
import { computed, defineComponent, PropType } from 'vue';
import { hasPermissions } from 'src/utils/permission';
import { FG_Plugin } from 'src/plugins';
2020-10-02 07:13:14 +00:00
export default defineComponent({
name: 'EssentialLink',
props: {
entry: {
type: Object as PropType<FG_Plugin.MenuLink>,
required: true,
2020-10-02 07:13:14 +00:00
},
2020-10-09 16:04:32 +00:00
},
setup(props) {
const isGranted = computed(() => hasPermissions(props.entry.permissions || []));
const title = computed(() =>
typeof props.entry.title === 'function' ? props.entry.title() : props.entry.title
);
return { isGranted, title };
},
2020-10-02 07:13:14 +00:00
});
</script>