mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 06:37:56 -04:00
Add js methods for renaming a group.
Signed-off-by: Martin Jänel <spammemore@posteo.de> Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
parent
1f80d767b4
commit
849d3697d3
1 changed files with 33 additions and 0 deletions
|
|
@ -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…
Reference in a new issue