-
Notifications
You must be signed in to change notification settings - Fork 350
Expand file tree
/
Copy pathAppNavigation.vue
More file actions
185 lines (180 loc) 路 5 KB
/
Copy pathAppNavigation.vue
File metadata and controls
185 lines (180 loc) 路 5 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!--
- @copyright Copyright (c) 2018 John Molakvo忙 <skjnldsv@protonmail.com>
-
- @author John Molakvo忙 <skjnldsv@protonmail.com>
-
- @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>
<AppNavigationVue :class="{'icon-loading': loading}">
<template #list>
<AppNavigationItem
:title="t('deck', 'Upcoming cards')"
icon="icon-calendar-dark"
:exact="true"
to="/" />
<AppNavigationBoardCategory
id="deck-navigation-all"
to="/board"
:text="t('deck', 'All boards')"
:boards="noneArchivedBoards"
:open-on-add-boards="true"
icon="icon-deck" />
<AppNavigationBoardCategory
id="deck-navigation-archived"
to="/board/archived"
:text="t('deck', 'Archived boards')"
:boards="archivedBoards"
icon="icon-archive" />
<AppNavigationBoardCategory
id="deck-navigation-shared"
to="/board/shared"
:text="t('deck', 'Shared with you')"
:boards="sharedBoards"
icon="icon-shared" />
<AppNavigationAddBoard v-if="canCreate" />
</template>
<template #footer>
<AppNavigationSettings>
<div>
<input id="toggle-modal"
v-model="cardDetailsInModal"
type="checkbox"
class="checkbox">
<label for="toggle-modal">
{{ t('deck', 'Use modal card view') }}
</label>
<Multiselect v-model="groupLimit"
:class="{'icon-loading-small': groupLimitDisabled}"
open-direction="bottom"
:options="groups"
:multiple="true"
:disabled="groupLimitDisabled"
:placeholder="t('deck', 'Limit deck usage of groups')"
label="displayname"
track-by="id"
@input="updateConfig" />
<p>{{ t('deck', 'Limiting Deck will block users not part of those groups from creating their own boards. Users will still be able to work on boards that have been shared with them.') }}</p>
</div>
</AppNavigationSettings>
</template>
</AppNavigationVue>
</template>
<script>
import axios from '@nextcloud/axios'
import { mapGetters } from 'vuex'
import ClickOutside from 'vue-click-outside'
import { AppNavigation as AppNavigationVue, AppNavigationItem, AppNavigationSettings, Multiselect } from '@nextcloud/vue'
import AppNavigationAddBoard from './AppNavigationAddBoard'
import AppNavigationBoardCategory from './AppNavigationBoardCategory'
import { loadState } from '@nextcloud/initial-state'
import { generateUrl, generateOcsUrl } from '@nextcloud/router'
const canCreateState = loadState('deck', 'canCreate')
export default {
name: 'AppNavigation',
components: {
AppNavigationVue,
AppNavigationSettings,
AppNavigationAddBoard,
AppNavigationBoardCategory,
Multiselect,
AppNavigationItem,
},
directives: {
ClickOutside,
},
props: {
loading: {
type: Boolean,
default: false,
},
},
data() {
return {
opened: false,
groups: [],
groupLimit: [],
groupLimitDisabled: true,
canCreate: canCreateState,
}
},
computed: {
...mapGetters([
'noneArchivedBoards',
'archivedBoards',
'sharedBoards',
]),
isAdmin() {
// eslint-disable-next-line
return OC.isUserAdmin()
},
cardDetailsInModal: {
get() {
return this.$store.getters.cardDetailsInModal
},
set(newValue) {
this.$store.dispatch('setCardDetailsInModal', newValue)
},
},
},
beforeMount() {
if (this.isAdmin) {
axios.get(generateUrl('apps/deck/config')).then((response) => {
this.groupLimit = response.data.groupLimit
this.groupLimitDisabled = false
}, (error) => {
console.error('Error while loading groupLimit', error.response)
})
axios.get(generateOcsUrl('cloud', 2) + 'groups').then((response) => {
this.groups = response.data.ocs.data.groups.reduce((obj, item) => {
obj.push({
id: item,
displayname: item,
})
return obj
}, [])
}, (error) => {
console.error('Error while loading group list', error.response)
})
}
},
methods: {
updateConfig() {
this.groupLimitDisabled = true
axios.post(generateUrl('apps/deck/config/groupLimit'), {
value: this.groupLimit,
}).then(() => {
this.groupLimitDisabled = false
}, (error) => {
console.error('Error while saving groupLimit', error.response)
})
},
},
}
</script>
<style scoped lang="scss">
#app-settings-content {
p {
margin-top: 20px;
margin-bottom: 20px;
color: var(--color-text-light);
}
}
::v-deep .app-navigation-toggle {
display: none;
}
</style>