mirror of
https://github.com/chenasraf/nextcloud-forum.git
synced 2026-05-18 01:28:58 +00:00
fix: roles error handling on admin ui
This commit is contained in:
@@ -29,6 +29,10 @@
|
||||
{{ strings.userRolesHelp }}
|
||||
</NcNoteCard>
|
||||
|
||||
<NcNoteCard v-if="rolesError" type="error">
|
||||
{{ rolesError }}
|
||||
</NcNoteCard>
|
||||
|
||||
<div class="settings-section-content">
|
||||
<div class="user-role-form">
|
||||
<div class="field-row">
|
||||
@@ -111,6 +115,7 @@ export default {
|
||||
|
||||
// User roles
|
||||
rolesLoading: true,
|
||||
rolesError: null,
|
||||
roles: [],
|
||||
userId: '',
|
||||
selectedRole: null,
|
||||
@@ -157,10 +162,12 @@ export default {
|
||||
async fetchRoles() {
|
||||
try {
|
||||
this.rolesLoading = true
|
||||
this.rolesError = null
|
||||
const resp = await ocs.get('/admin/roles')
|
||||
this.roles = resp.data.roles
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch roles', e)
|
||||
this.rolesError = e.response?.data?.message || t('forum', 'Failed to fetch roles')
|
||||
} finally {
|
||||
this.rolesLoading = false
|
||||
}
|
||||
|
||||
@@ -16,7 +16,11 @@ ocs.interceptors.response.use(
|
||||
if (ocsResponse !== undefined) {
|
||||
// Extract data from OCS response, falling back to meta message for errors
|
||||
const ocsData = ocsResponse.data
|
||||
if (ocsData !== undefined && ocsData !== null) {
|
||||
const isEmpty =
|
||||
ocsData === undefined ||
|
||||
ocsData === null ||
|
||||
(Array.isArray(ocsData) && ocsData.length === 0)
|
||||
if (!isEmpty) {
|
||||
error.response.data = ocsData
|
||||
} else if (ocsResponse.meta?.message) {
|
||||
// For OCS errors that only have meta message (no data)
|
||||
|
||||
Reference in New Issue
Block a user