|
|
@@ -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 |
|
|
|
* |