-
Notifications
You must be signed in to change notification settings - Fork 159
/
collaborators.js
78 lines (70 loc) · 2 KB
/
collaborators.js
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
import { mapGetters } from 'vuex'
import roles from '../helpers/collaboratorRolesDefinition'
export default {
computed: {
...mapGetters(['getToken']),
...mapGetters('Files', ['highlightedFile']),
ownerRole() {
return {
name: 'owner',
label: this.$gettext('Owner')
}
},
resharerRole() {
return {
name: 'resharer',
label: this.$gettext('Resharer')
}
},
advancedRole() {
const advancedRole = {
name: 'advancedRole',
label: this.$gettext('Advanced permissions'),
description: this.$gettext('Set detailed permissions'),
permissions: ['read'],
additionalPermissions: {
share: {
name: 'share',
description: this.$gettext('Allow re-Sharing')
},
update: {
name: 'update',
description: this.$gettext('Allow editing')
}
}
}
if (this.highlightedFile.type === 'folder') {
const permissions = advancedRole.additionalPermissions
permissions.create = {
name: 'create',
description: this.$gettext('Allow creating')
}
permissions.delete = {
name: 'delete',
description: this.$gettext('Allow deleting')
}
}
return advancedRole
},
roles() {
const isFolder = this.highlightedFile.type === 'folder'
const $gettext = this.$gettext
const collaboratorRoles = roles({ $gettext, isFolder: isFolder })
collaboratorRoles.advancedRole = this.advancedRole
return collaboratorRoles
},
displayRoles() {
const result = this.roles
result[this.resharerRole.name] = this.resharerRole
result[this.ownerRole.name] = this.ownerRole
return result
}
},
methods: {
collaboratorOptionChanged({ role, permissions, expirationDate }) {
this.selectedRole = role
this.additionalPermissions = permissions
this.expirationDate = expirationDate
}
}
}