Skip to content

Commit

Permalink
fix: better handle some load errors
Browse files Browse the repository at this point in the history
  • Loading branch information
smarinier committed Feb 10, 2025
1 parent 7d7dd79 commit b6d7292
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
9 changes: 9 additions & 0 deletions lib/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ public function getUsers(int $spaceId): JSONResponse {

$groupfolder = $this->folderHelper->getFolder($space->getGroupfolderId(), $this->rootFolder->getRootFolderStorageId());

if ($groupfolder === false) {
return new JSONResponse(
[
'message' => 'Failed loading groupfolder '.$space->getGroupfolderId(),
'success' => false
],
Http::STATUS_BAD_REQUEST);
}

$workspace = array_merge($groupfolder, $space->jsonSerialize());
$users = $this->workspaceService->addUsersInfo($workspace);

Expand Down
17 changes: 12 additions & 5 deletions src/services/spaceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import AddGroupToGroupfolderError from '../Errors/Groupfolders/AddGroupToGroupfo

/**
* @param {string} spaceName it's a name for the space to create
* @param {number} folderId it's the id of groupfolder
* @param {object} vueInstance it's an instance of vue
* @return {object}
*/
Expand Down Expand Up @@ -60,7 +59,8 @@ export function createSpace(spaceName, vueInstance = undefined) {

/**
*
* @param spaceId
* @param {number} spaceId id of space
* @return {object}
*/
export function getUsers(spaceId) {
const result = axios.get(generateUrl(`/apps/workspace/spaces/${spaceId}/users`))
Expand All @@ -69,6 +69,12 @@ export function getUsers(spaceId) {
})
.catch(error => {
console.error('Impossible to get users from a workspace.', error)
let errorMessage = t('workspace', "Can't load workspace users")
if (error.response && error.response.data && error.response.data.message) {
console.error(error.response.data.message)
errorMessage += ': ' + error.response.data.message
}
throw new Error(errorMessage)
})
return result
}
Expand Down Expand Up @@ -144,7 +150,7 @@ export function addGroupToWorkspace(spaceId, gid) {
}

/**
* @param {integer} spaceId it's the id relative to workspace
* @param {number} spaceId it's the id relative to workspace
* @return {Promise}
*/
export function removeWorkspace(spaceId) {
Expand All @@ -161,8 +167,9 @@ export function removeWorkspace(spaceId) {

/**
*
* @param spaceId
* @param newSpaceName
* @param {number} spaceId if of space
* @param {string} newSpaceName new space name
* @return {object}
*/
export function renameSpace(spaceId, newSpaceName) {
const respFormat = {
Expand Down
3 changes: 3 additions & 0 deletions src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,9 @@ export default {
.catch(error => {
console.error('Impossible to get users for the workspace.')
console.error(error)
showNotificationError(t('workspace', "Can't load workspace users"))
context.commit('SET_LOADING_USERS_WAITTING', ({ activated: false }))
context.commit('SET_NO_USERS', ({ activated: true }))
})
},
}

0 comments on commit b6d7292

Please sign in to comment.