-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathAclStateButton.vue
162 lines (158 loc) Β· 4.28 KB
/
AclStateButton.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!--
- @copyright Copyright (c) 2018 Julius HΓ€rtl <jus@bitgrid.net>
-
- @author Julius HΓ€rtl <[email protected]>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->
<template>
<div v-if="readOnly">
<NcButton v-if="!isAllowed"
v-tooltip="t('groupfolders', 'Denied')"
:title="t('groupfolders', 'Denied')"
:aria-label="t('groupfolders', 'Access denied')">
<template #icon>
<Cancel :size="16" />
</template>
</NcButton>
<NcButton v-else
v-tooltip="t('groupfolders', 'Allowed')"
:title="t('groupfolders', 'Allowed')"
:aria-label="t('groupfolders', 'Access allowed')">
<template #icon>
<Check :size="16" />
</template>
</NcButton>
</div>
<div v-else>
<NcActions :aria-label="label" :v-tooltip="label">
<template #icon>
<component :is="icon" :class="{inherited: isInherited}" :size="16" />
</template>
<NcActionRadio name="state"
:checked="state === STATES.INHERIT_ALLOW || state === STATES.INHERIT_DENY || state === STATES.INHERIT_DEFAULT"
:disabled="disabled"
@change="$emit('update', STATES.INHERIT_DEFAULT)">
{{ t('groupfolders', 'Inherit permission') }}
</NcActionRadio>
<NcActionRadio name="state"
:checked="state === STATES.SELF_DENY"
:disabled="disabled"
@change="$emit('update', STATES.SELF_DENY)">
{{ t('groupfolders', 'Deny') }}
</NcActionRadio>
<NcActionRadio name="state"
:checked="state === STATES.SELF_ALLOW"
:disabled="disabled"
@change="$emit('update', STATES.SELF_ALLOW)">
{{ t('groupfolders', 'Allow') }}
</NcActionRadio>
</NcActions>
</div>
</template>
<script>
import Check from 'vue-material-design-icons/Check.vue'
import Cancel from 'vue-material-design-icons/Cancel.vue'
import Minus from 'vue-material-design-icons/Minus.vue'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcActionRadio from '@nextcloud/vue/dist/Components/NcActionRadio.js'
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip.js'
export const STATES = {
INHERIT_DENY: 0,
INHERIT_ALLOW: 1,
INHERIT_DEFAULT: 2,
SELF_DENY: 3,
SELF_ALLOW: 4,
}
export default {
name: 'AclStateButton',
directives: {
tooltip: Tooltip,
},
components: {
NcButton,
NcActions,
NcActionRadio,
Check,
Cancel,
},
props: {
inherited: {
type: Boolean,
default: false,
},
state: {
type: Number,
default: STATES.INHERIT_DENY,
},
readOnly: {
type: Boolean,
default: false,
},
disabled: {
type: Boolean,
default: false,
},
},
data() {
return {
STATES,
}
},
computed: {
isAllowed() {
return this.state === STATES.INHERIT_ALLOW || this.state === STATES.SELF_ALLOW || this.state === STATES.INHERIT_DEFAULT
},
isInherited() {
return this.state === STATES.INHERIT_ALLOW || this.state === STATES.INHERIT_DENY || this.state === STATES.INHERIT_DEFAULT
},
icon() {
switch (this.state) {
case STATES.INHERIT_DEFAULT:
return Minus
case STATES.INHERIT_ALLOW:
case STATES.SELF_ALLOW:
return Check
default:
return Cancel
}
},
label() {
switch (this.state) {
case STATES.INHERIT_DEFAULT:
return t('groupfolders', 'Unset')
case STATES.INHERIT_DENY:
return t('groupfolders', 'Denied (Inherited permission)')
case STATES.INHERIT_ALLOW:
return t('groupfolders', 'Allowed (Inherited permission)')
case STATES.SELF_DENY:
return t('groupfolders', 'Denied')
case STATES.SELF_ALLOW:
return t('groupfolders', 'Allowed')
}
return ''
},
},
}
</script>
<style scoped>
.inherited {
opacity: 0.5;
color: var(--color-text-maxcontrast);
}
</style>