mirror of
https://github.com/nextcloud/server.git
synced 2026-06-12 02:00:51 -04:00
fix(settings): Fix loaded groups being undefined
Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
parent
374197c721
commit
d32f2c761e
3 changed files with 16 additions and 26 deletions
|
|
@ -300,6 +300,7 @@ import UserRowActions from './UserRowActions.vue'
|
|||
|
||||
import UserRowMixin from '../../mixins/UserRowMixin.js'
|
||||
import { isObfuscated, unlimitedQuota } from '../../utils/userUtils.ts'
|
||||
import { searchGroups, loadUserGroups } from '../../service/groups.ts'
|
||||
import logger from '../../logger.ts'
|
||||
|
||||
export default {
|
||||
|
|
@ -556,14 +557,7 @@ export default {
|
|||
async loadGroupDetails() {
|
||||
this.loading.groups = true
|
||||
try {
|
||||
const { data } = await this.$store.dispatch('getUserGroups', {
|
||||
userId: this.user.id,
|
||||
})
|
||||
const groups = data.ocs?.data?.groups
|
||||
if (!groups) {
|
||||
logger.error(t('settings', 'Failed to load groups with details'))
|
||||
return
|
||||
}
|
||||
const groups = await loadUserGroups({ userId: this.user.id })
|
||||
this.availableGroups = this.availableGroups.map(availableGroup => groups.find(group => group.id === availableGroup.id) ?? availableGroup)
|
||||
} catch (error) {
|
||||
logger.error(t('settings', 'Failed to load groups with details'), { error })
|
||||
|
|
|
|||
|
|
@ -53,3 +53,17 @@ export const searchGroups = ({ search, offset, limit }): CancelablePromise<Requi
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Load user groups
|
||||
*
|
||||
* @param {object} options Options
|
||||
* @param {string} options.userId User id
|
||||
*/
|
||||
export const loadUserGroups = async ({ userId }): Promise<Required<IGroup>[]> => {
|
||||
const url = generateOcsUrl('/cloud/users/{userId}/groups/details', { userId })
|
||||
const { data } = await axios.get(url)
|
||||
const groups: Group[] = data.ocs?.data?.groups ?? []
|
||||
const formattedGroups = groups.map(formatGroup)
|
||||
return formattedGroups
|
||||
},
|
||||
|
|
|
|||
|
|
@ -464,24 +464,6 @@ const actions = {
|
|||
.catch((error) => context.commit('API_FAILURE', error))
|
||||
},
|
||||
|
||||
/**
|
||||
* Get user groups
|
||||
*
|
||||
* @param {object} context store context
|
||||
* @param {object} options destructuring object
|
||||
* @param {number} options.userId User id
|
||||
* @return {Promise}
|
||||
*/
|
||||
async getUserGroups(context, { userId }) {
|
||||
const url = generateOcsUrl('cloud/users/{userId}/groups/details', { userId })
|
||||
try {
|
||||
const response = await api.get(url)
|
||||
return response
|
||||
} catch (error) {
|
||||
context.commit('API_FAILURE', error)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Get all users with full details
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue