forked from akhilrex/hammond
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnav-bar.vue
81 lines (79 loc) · 2.02 KB
/
nav-bar.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<script>
import { authComputed } from '@state/helpers'
import { mapGetters } from 'vuex'
import NavBarRoutes from './nav-bar-routes.vue'
export default {
components: { NavBarRoutes },
data() {
return {
persistentNavRoutes: [
{
name: 'home',
title: this.$t('menu.home'),
},
],
loggedInNavRoutes: [
{
name: 'quickEntries',
title: () => this.$t('menu.quickentries'),
badge: () => this.unprocessedQuickEntries.length,
},
{
name: 'import',
title: () => this.$t('menu.import'),
},
{
name: 'settings',
title: this.$t('menu.settings'),
},
{
name: 'logout',
title: this.$t('menu.logout'),
},
],
loggedOutNavRoutes: [
{
name: 'login',
title: this.$t('menu.login'),
},
],
adminNavRoutes: [
{
name: 'site-settings',
title: this.$t('menu.sitesettings'),
},
{
name: 'users',
title: this.$t('menu.users'),
},
],
}
},
computed: {
...authComputed,
...mapGetters('vehicles', ['unprocessedQuickEntries']),
isAdmin() {
return this.loggedIn && this.currentUser.role === 'ADMIN'
},
},
}
</script>
<template>
<div class="container">
<b-navbar class="" spaced>
<template v-slot:brand>
<b-navbar-item tag="router-link" :to="{ path: '/' }">
<h1 class="title" style="font-family:Arial Black">Hammond</h1>
</b-navbar-item>
</template>
<template v-slot:end>
<NavBarRoutes :routes="persistentNavRoutes" />
<NavBarRoutes v-if="loggedIn" :routes="loggedInNavRoutes" />
<NavBarRoutes v-else :routes="loggedOutNavRoutes" />
<b-navbar-dropdown v-if="loggedIn && isAdmin" :label="$t('menu.admin')">
<NavBarRoutes :routes="adminNavRoutes" />
</b-navbar-dropdown>
</template>
</b-navbar>
</div>
</template>