Browse Source

Add js methods for renaming a group.

Signed-off-by: Martin Jänel <spammemore@posteo.de>
Signed-off-by: Louis Chemineau <louis@chmn.me>
tags/v24.0.0beta1
ArcticFall 2 years ago
parent
commit
849d3697d3
1 changed files with 33 additions and 0 deletions
  1. 33
    0
      apps/settings/src/store/users.js

+ 33
- 0
apps/settings/src/store/users.js View File

@@ -96,6 +96,15 @@ const mutations = {
console.error('Can\'t create group', e)
}
},
renameGroup(state, { gid, displayname }) {
const groupIndex = state.groups.findIndex(groupSearch => groupSearch.id === gid)
if (groupIndex >= 0) {
const updatedGroup = state.groups[groupIndex]
updatedGroup.name = displayname
state.groups[groupIndex] = updatedGroup
state.groups = orderGroups(state.groups, state.orderBy)
}
},
removeGroup(state, gid) {
const groupIndex = state.groups.findIndex(groupSearch => groupSearch.id === gid)
if (groupIndex >= 0) {
@@ -341,6 +350,30 @@ const actions = {
})
},

/**
* Rename group
*
* @param {Object} context store context
* @param {string} groupid Group id
* @param {string} displayName Group display name
* @returns {Promise}
*/
renameGroup(context, { groupid, displayName }) {
return api.requireAdmin().then((response) => {
return api.put(generateOcsUrl('cloud/groups/{groupId}', { groupId: encodeURIComponent(groupid) }), { key: 'displayname', value: displayName })
.then((response) => {
context.commit('renameGroup', { gid: groupid, displayname: displayName })
return { groupid, displayName }
})
.catch((error) => { throw error })
}).catch((error) => {
context.commit('API_FAILURE', { groupid, error })
// let's throw one more time to prevent the view
// from renaming the group
throw error
})
},

/**
* Remove group
*

Loading…
Cancel
Save