Skip to content

Commit ce6ff23

Browse files
committed
Set visibility to the side bar according to the project role
1 parent 9b6ce98 commit ce6ff23

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

frontend/components/organisms/layout/TheSideBar.vue

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,8 @@
1111
Start annotation
1212
</v-btn>
1313
<template v-for="(item, i) in items">
14-
<v-divider
15-
v-if="item.divider"
16-
:key="i"
17-
dark
18-
class="my-4"
19-
/>
2014
<v-list-item
21-
v-else
15+
v-if="isVisible(item)"
2216
:key="i"
2317
@click="$router.push('/projects/' + $route.params.id + '/' + item.link)"
2418
>
@@ -44,18 +38,23 @@ export default {
4438
type: String,
4539
default: '',
4640
required: true
41+
},
42+
role: {
43+
type: Object,
44+
default: () => {},
45+
required: true
4746
}
4847
},
4948
5049
data() {
5150
return {
5251
items: [
53-
{ icon: 'mdi-home', text: 'Home', link: '' },
54-
{ icon: 'mdi-database', text: 'Dataset', link: 'dataset' },
55-
{ icon: 'label', text: 'Labels', link: 'labels' },
56-
{ icon: 'person', text: 'Members', link: 'members' },
57-
{ icon: 'mdi-book-open-outline', text: 'Guideline', link: 'guideline' },
58-
{ icon: 'mdi-chart-bar', text: 'Statistics', link: 'statistics' }
52+
{ icon: 'mdi-home', text: 'Home', link: '', adminOnly: false },
53+
{ icon: 'mdi-database', text: 'Dataset', link: 'dataset', adminOnly: true },
54+
{ icon: 'label', text: 'Labels', link: 'labels', adminOnly: true },
55+
{ icon: 'person', text: 'Members', link: 'members', adminOnly: true },
56+
{ icon: 'mdi-book-open-outline', text: 'Guideline', link: 'guideline', adminOnly: true },
57+
{ icon: 'mdi-chart-bar', text: 'Statistics', link: 'statistics', adminOnly: true }
5958
]
6059
}
6160
},
@@ -64,6 +63,12 @@ export default {
6463
to() {
6564
return `/projects/${this.$route.params.id}/${this.link}`
6665
}
66+
},
67+
68+
methods: {
69+
isVisible(item) {
70+
return !item.adminOnly || this.role.is_project_admin
71+
}
6772
}
6873
}
6974
</script>

frontend/layouts/annotation.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
clipped
1313
color=""
1414
>
15-
<the-side-bar :link="getLink" />
15+
<the-side-bar
16+
:link="getLink"
17+
:role="getCurrentUserRole"
18+
/>
1619
</v-navigation-drawer>
1720

1821
<nuxt />
@@ -36,7 +39,7 @@ export default {
3639
},
3740
3841
computed: {
39-
...mapGetters('projects', ['getLink'])
42+
...mapGetters('projects', ['getLink', 'getCurrentUserRole'])
4043
},
4144
4245
created() {

frontend/layouts/project.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
clipped
1313
color=""
1414
>
15-
<the-side-bar :link="getLink" />
15+
<the-side-bar
16+
:link="getLink"
17+
:role="getCurrentUserRole"
18+
/>
1619
</v-navigation-drawer>
1720

1821
<v-content>
@@ -50,7 +53,7 @@ export default {
5053
},
5154
5255
computed: {
53-
...mapGetters('projects', ['getLink'])
56+
...mapGetters('projects', ['getLink', 'getCurrentUserRole'])
5457
},
5558
5659
created() {

frontend/store/projects.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ export const getters = {
1414
currentProject(state) {
1515
return state.current
1616
},
17+
getCurrentUserRole(state) {
18+
return state.current.current_users_role || {}
19+
},
1720
getFilterOption(state) {
1821
if (state.current.project_type === 'DocumentClassification') {
1922
return 'doc_annotations__isnull'

0 commit comments

Comments
 (0)