Skip to content

Commit c5688b2

Browse files
committed
Add new group entry on users list + fixes
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
1 parent 2f45045 commit c5688b2

File tree

12 files changed

+1575
-420
lines changed

12 files changed

+1575
-420
lines changed

settings/css/settings.scss

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,21 +1377,6 @@ doesnotexist:-o-prefocus, .strengthify-wrapper {
13771377

13781378
/* USERS LIST -------------------------------------------------------------- */
13791379
#body-settings {
1380-
#app-navigation {
1381-
/* Hack to override the javascript orderBy */
1382-
#usergrouplist > li {
1383-
order: 4;
1384-
&#everyone {
1385-
order:1;
1386-
}
1387-
&#admin {
1388-
order:2;
1389-
}
1390-
&#disabled {
1391-
order:3;
1392-
}
1393-
}
1394-
}
13951380
$grid-row-height: 46px;
13961381
#app-content.user-list-grid {
13971382
display: grid;

settings/js/settings-vue.js

Lines changed: 96 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

settings/js/settings-vue.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

settings/package-lock.json

Lines changed: 1355 additions & 143 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

settings/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "settings",
33
"description": "Nextcloud settings",
4-
"version": "1.2.0",
4+
"version": "1.2.1",
55
"author": "John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>",
66
"license": "AGPL3",
77
"private": true,
@@ -13,6 +13,7 @@
1313
"dependencies": {
1414
"axios": "^0.18.0",
1515
"babel-polyfill": "^6.26.0",
16+
"nextcloud-vue": "^0.1.2",
1617
"v-tooltip": "^2.0.0-rc.33",
1718
"vue": "^2.5.17",
1819
"vue-click-outside": "^1.0.7",
@@ -34,6 +35,8 @@
3435
"babel-preset-stage-3": "^6.24.1",
3536
"css-loader": "^1.0.0",
3637
"file-loader": "^1.1.11",
38+
"node-sass": "^4.9.3",
39+
"sass-loader": "^7.1.0",
3740
"vue-loader": "^15.4.2",
3841
"vue-template-compiler": "^2.5.17",
3942
"webpack": "^4.19.1",

settings/src/components/appNavigation.vue

Lines changed: 0 additions & 54 deletions
This file was deleted.

settings/src/components/appNavigation/navigationItem.vue

Lines changed: 0 additions & 155 deletions
This file was deleted.

settings/src/components/userList.vue

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
</div>
4545

4646
<form class="row" id="new-user" v-show="showConfig.showNewUserForm"
47-
v-on:submit.prevent="createUser" :disabled="loading"
47+
v-on:submit.prevent="createUser" :disabled="loading.all"
4848
:class="{'sticky': scrolled && showConfig.showNewUserForm}">
49-
<div :class="loading?'icon-loading-small':'icon-add'"></div>
49+
<div :class="loading.all?'icon-loading-small':'icon-add'"></div>
5050
<div class="name">
5151
<input id="newusername" type="text" required v-model="newUser.id"
5252
:placeholder="t('settings', 'Username')" name="username"
@@ -74,12 +74,13 @@
7474
<div class="groups">
7575
<!-- hidden input trick for vanilla html5 form validation -->
7676
<input type="text" :value="newUser.groups" v-if="!settings.isAdmin"
77-
tabindex="-1" id="newgroups" :required="!settings.isAdmin" />
78-
<multiselect :options="canAddGroups" v-model="newUser.groups"
79-
:placeholder="t('settings', 'Add user in group')"
80-
label="name" track-by="id" class="multiselect-vue"
81-
:multiple="true" :close-on-select="false"
82-
:allowEmpty="settings.isAdmin">
77+
tabindex="-1" id="newgroups" :required="!settings.isAdmin"
78+
:class="{'icon-loading-small': loading.groups}"/>
79+
<multiselect v-model="newUser.groups" :options="canAddGroups" :disabled="loading.groups||loading.all"
80+
tag-placeholder="create" :placeholder="t('settings', 'Add user in group')"
81+
label="name" track-by="id" class="multiselect-vue"
82+
:multiple="true" :taggable="true" :close-on-select="false"
83+
@tag="createGroup">
8384
<!-- If user is not admin, he is a subadmin.
8485
Subadmins can't create users outside their groups
8586
Therefore, empty select is forbidden -->
@@ -154,7 +155,10 @@ export default {
154155
return {
155156
unlimitedQuota: unlimitedQuota,
156157
defaultQuota: defaultQuota,
157-
loading: false,
158+
loading: {
159+
all: false,
160+
groups: false
161+
},
158162
scrolled: false,
159163
searchQuery: '',
160164
newUser: {
@@ -318,10 +322,10 @@ export default {
318322
resetForm() {
319323
// revert form to original state
320324
Object.assign(this.newUser, this.$options.data.call(this).newUser);
321-
this.loading = false;
325+
this.loading.all = false;
322326
},
323327
createUser() {
324-
this.loading = true;
328+
this.loading.all = true;
325329
this.$store.dispatch('addUser', {
326330
userid: this.newUser.id,
327331
password: this.newUser.password,
@@ -332,7 +336,7 @@ export default {
332336
quota: this.newUser.quota.id,
333337
language: this.newUser.language.code,
334338
}).then(() => this.resetForm())
335-
.catch(() => this.loading = false);
339+
.catch(() => this.loading.all = false);
336340
},
337341
setNewUserDefaultGroup(value) {
338342
if (value && value.length > 0) {
@@ -345,6 +349,25 @@ export default {
345349
}
346350
// fallback, empty selected group
347351
this.newUser.groups = [];
352+
},
353+
354+
/**
355+
* Create a new group
356+
*
357+
* @param {string} groups Group id
358+
* @returns {Promise}
359+
*/
360+
createGroup(gid) {
361+
this.loading.groups = true;
362+
this.$store.dispatch('addGroup', gid)
363+
.then((group) => {
364+
this.newUser.groups.push(this.groups.find(group => group.id === gid))
365+
this.loading.groups = false;
366+
})
367+
.catch(() => {
368+
this.loading.groups = false;
369+
});
370+
return this.$store.getters.getGroups[this.groups.length];
348371
}
349372
}
350373
}

settings/src/store/users.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,10 @@ const actions = {
296296
addGroup(context, gid) {
297297
return api.requireAdmin().then((response) => {
298298
return api.post(OC.linkToOCS(`cloud/groups`, 2), {groupid: gid})
299-
.then((response) => context.commit('addGroup', {gid: gid, displayName: gid}))
299+
.then((response) => {
300+
context.commit('addGroup', {gid: gid, displayName: gid})
301+
return {gid: gid, displayName: gid}
302+
})
300303
.catch((error) => {throw error;});
301304
}).catch((error) => {
302305
context.commit('API_FAILURE', { gid, error });

settings/src/views/Apps.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,14 @@
3434

3535

3636
<script>
37-
import appNavigation from '../components/appNavigation';
37+
import { AppNavigation } from 'nextcloud-vue';
3838
import appList from '../components/appList';
3939
import Vue from 'vue';
4040
import VueLocalStorage from 'vue-localstorage'
4141
import Multiselect from 'vue-multiselect';
4242
import api from '../store/api';
4343
import AppDetails from '../components/appDetails';
4444
45-
Vue.use(VueLocalStorage)
4645
Vue.use(VueLocalStorage)
4746
4847
export default {
@@ -59,7 +58,7 @@ export default {
5958
},
6059
components: {
6160
AppDetails,
62-
appNavigation,
61+
AppNavigation,
6362
appList,
6463
},
6564
methods: {

0 commit comments

Comments
 (0)