aboutsummaryrefslogtreecommitdiffstats
path: root/settings/src
diff options
context:
space:
mode:
Diffstat (limited to 'settings/src')
-rw-r--r--settings/src/components/userList/userRow.vue19
-rw-r--r--settings/src/store/index.js4
-rw-r--r--settings/src/store/users.js32
3 files changed, 38 insertions, 17 deletions
diff --git a/settings/src/components/userList/userRow.vue b/settings/src/components/userList/userRow.vue
index bcdb4ba0042..67a2582fc11 100644
--- a/settings/src/components/userList/userRow.vue
+++ b/settings/src/components/userList/userRow.vue
@@ -326,18 +326,22 @@ export default {
},
/**
- * Create a new group
+ * Create a new group and add user to it
*
* @param {string} groups Group id
* @returns {Promise}
*/
createGroup(gid) {
this.loading = {groups:true, subadmins:true}
- this.$store.dispatch('addGroup', gid).then(() => {
- this.loading = {groups:false, subadmins:false};
- let userid = this.user.id;
- this.$store.dispatch('addUserGroup', {userid, gid});
- });
+ this.$store.dispatch('addGroup', gid)
+ .then(() => {
+ this.loading = {groups:false, subadmins:false};
+ let userid = this.user.id;
+ this.$store.dispatch('addUserGroup', {userid, gid});
+ })
+ .catch(() => {
+ this.loading = {groups:false, subadmins:false};
+ });
return this.$store.getters.getGroups[this.groups.length];
},
@@ -372,6 +376,9 @@ export default {
if (this.$route.params.selectedGroup === gid) {
this.$store.commit('deleteUser', userid);
}
+ })
+ .catch(() => {
+ this.loading.groups = false
});
},
diff --git a/settings/src/store/index.js b/settings/src/store/index.js
index aa64b245396..2bd8d76e41b 100644
--- a/settings/src/store/index.js
+++ b/settings/src/store/index.js
@@ -12,10 +12,10 @@ const mutations = {
API_FAILURE(state, error) {
try {
let message = error.error.response.data.ocs.meta.message;
+ OC.Notification.showHtml(t('settings','An error occured during the request. Unable to proceed.')+'<br>'+message, {timeout: 7});
} catch(e) {
- let message = error;
+ OC.Notification.showTemporary(t('settings','An error occured during the request. Unable to proceed.'));
}
- OC.Notification.showHtml(t('settings','An error occured during the request. Unable to proceed.')+'<br>'+message, {timeout: 7});
console.log(state, error);
}
};
diff --git a/settings/src/store/users.js b/settings/src/store/users.js
index 63a1568e048..5fac0c6f327 100644
--- a/settings/src/store/users.js
+++ b/settings/src/store/users.js
@@ -6,7 +6,7 @@ const orderGroups = function(groups, orderBy) {
* https://github.com/nextcloud/server/blob/208e38e84e1a07a49699aa90dc5b7272d24489f0/lib/private/Group/MetaData.php#L34
*/
if (orderBy === 1) {
- return groups.sort((a, b) => a.usercount < b.usercount);
+ return groups.sort((a, b) => a.usercount-a.disabled < b.usercount - b.disabled);
} else {
return groups.sort((a, b) => a.name.localeCompare(b.name));
}
@@ -69,19 +69,23 @@ const mutations = {
},
addUserGroup(state, { userid, gid }) {
let group = state.groups.find(groupSearch => groupSearch.id == gid);
- if (group) {
- group.usercount++; // increase count
+ let user = state.users.find(user => user.id == userid);
+ // increase count if user is enabled
+ if (group && user.enabled) {
+ group.usercount++;
}
- let groups = state.users.find(user => user.id == userid).groups;
+ let groups = user.groups;
groups.push(gid);
state.groups = orderGroups(state.groups, state.orderBy);
},
removeUserGroup(state, { userid, gid }) {
let group = state.groups.find(groupSearch => groupSearch.id == gid);
- if (group) {
- group.usercount--; // lower count
+ let user = state.users.find(user => user.id == userid);
+ // lower count if user is enabled
+ if (group && user.enabled) {
+ group.usercount--;
}
- let groups = state.users.find(user => user.id == userid).groups;
+ let groups = user.groups;
groups.splice(groups.indexOf(gid),1);
state.groups = orderGroups(state.groups, state.orderBy);
},
@@ -251,7 +255,12 @@ const actions = {
return api.post(OC.linkToOCS(`cloud/groups`, 2), {groupid: gid})
.then((response) => context.commit('addGroup', gid))
.catch((error) => {throw error;});
- }).catch((error) => context.commit('API_FAILURE', { userid, error }));
+ }).catch((error) => {
+ context.commit('API_FAILURE', { gid, error });
+ // let's throw one more time to prevent the view
+ // from adding the user to a group that doesn't exists
+ throw error;
+ });
},
/**
@@ -300,7 +309,12 @@ const actions = {
return api.delete(OC.linkToOCS(`cloud/users/${userid}/groups`, 2), { groupid: gid })
.then((response) => context.commit('removeUserGroup', { userid, gid }))
.catch((error) => {throw error;});
- }).catch((error) => context.commit('API_FAILURE', { userid, error }));
+ }).catch((error) => {
+ context.commit('API_FAILURE', { userid, error });
+ // let's throw one more time to prevent
+ // the view from removing the user row on failure
+ throw error;
+ });
},
/**