diff --git a/lib/Group/GroupBackend.php b/lib/Group/GroupBackend.php index 469887630..68d09c2b6 100644 --- a/lib/Group/GroupBackend.php +++ b/lib/Group/GroupBackend.php @@ -126,7 +126,7 @@ public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { return []; } - $groups = $this->connectedGroups->getConnectedGroupsToSpace($gid); + $groups = $this->connectedGroups->getConnectedGroupsToSpaceGroup($gid); if ($groups === null) { return []; } diff --git a/lib/Service/Group/ConnectedGroupsService.php b/lib/Service/Group/ConnectedGroupsService.php index e45f83bf1..b79762a6d 100644 --- a/lib/Service/Group/ConnectedGroupsService.php +++ b/lib/Service/Group/ConnectedGroupsService.php @@ -81,7 +81,7 @@ public function getConnectedSpaceToGroupIds(string $gid): ?array { * @param string $spaceGid * @return array|null */ - public function getConnectedGroupsToSpace(string $spaceGid): ?array { + public function getConnectedGroupsToSpaceGroup(string $spaceGid): ?array { if (!isset(self::$LINKED_SPACE_GROUPS[$spaceGid])) { return null; } @@ -96,7 +96,7 @@ public function getConnectedGroupsToSpace(string $spaceGid): ?array { * @param string $gid * @return bool */ - public function hasConnectedgroups(string $gid) : bool { + public function hasConnectedGroups(string $gid) : bool { return isset(self::$LINKED_SPACE_GROUPS[$gid]); } } diff --git a/lib/Service/WorkspaceService.php b/lib/Service/WorkspaceService.php index 990bc912a..39451e94b 100644 --- a/lib/Service/WorkspaceService.php +++ b/lib/Service/WorkspaceService.php @@ -26,6 +26,7 @@ namespace OCA\Workspace\Service; use OCA\Workspace\Db\SpaceMapper; +use OCA\Workspace\Service\Group\ConnectedGroupsService; use OCA\Workspace\Service\Group\GroupFormatter; use OCA\Workspace\Service\Group\UserGroup; use OCA\Workspace\Service\Group\WorkspaceManagerGroup; @@ -47,7 +48,8 @@ public function __construct( private SpaceMapper $spaceMapper, private UserService $userService, private ShareMembersOnlyFilter $shareMembersFilter, - private GroupMembersOnlyChecker $memberGroupOnlyChecker + private GroupMembersOnlyChecker $memberGroupOnlyChecker, + private ConnectedGroupsService $connectedGroups, ) { } @@ -194,12 +196,23 @@ public function addUsersInfo(string|array $workspace): \stdClass { * */ public function addGroupsInfo(array|string $workspace): array { + if (!isset($workspace['groups'])) { + return $workspace; + } $groups = array_map( - fn($gid) => $this->groupManager->get($gid), - array_keys($workspace['groups']) - ); + fn($gid) => $this->groupManager->get($gid), + array_keys($workspace['groups']) + ); + $addedGroups = []; + foreach(array_keys($workspace['groups']) as $gid) { + $addedToGroup = $this->connectedGroups->getConnectedGroupsToSpaceGroup($gid); + if ($addedToGroup !== null) { + $addedGroups = array_merge($addedGroups, $addedToGroup); + } + } $workspace['groups'] = GroupFormatter::formatGroups($groups); + $workspace['addedGroups'] = GroupFormatter::formatGroups($addedGroups); return $workspace; } diff --git a/src/GroupDetails.vue b/src/GroupDetails.vue index ee6ed4f0a..dac7a162a 100644 --- a/src/GroupDetails.vue +++ b/src/GroupDetails.vue @@ -29,7 +29,7 @@ {{ $store.getters.groupName($route.params.space, $route.params.group) }} -
+
- + @@ -95,6 +95,12 @@ export default { showSelectUsersModal: false, // true to display user selection Modal windows } }, + computed: { + // The title to display at the top of the page + isAddedGroup() { + return this.$store.getters.isSpaceAddedGroup(this.$route.params.space, this.$route.params.group) + }, + }, methods: { deleteGroup() { // Prevents deleting GE- and U- groups diff --git a/src/GroupMenuItem.vue b/src/GroupMenuItem.vue index 38758b024..5e7462bdd 100644 --- a/src/GroupMenuItem.vue +++ b/src/GroupMenuItem.vue @@ -27,7 +27,11 @@ export default { spaceName: { type: String, required: true, - + }, + addedGroup: { + type: Boolean, + required: false, + default: false, }, }, } diff --git a/src/SelectConnectedGroups.vue b/src/SelectConnectedGroups.vue index a6c2c56c4..36799d86c 100644 --- a/src/SelectConnectedGroups.vue +++ b/src/SelectConnectedGroups.vue @@ -1,7 +1,7 @@ @@ -77,9 +83,7 @@ export default { }, beforeMount() { // console.debug(this.space.groups.types) - // const groupnames = // const workspaceGroups = this.space.groups.filter((groupname)) - // this.workspaceGroups.push() }, methods: { diff --git a/src/UserTable.vue b/src/UserTable.vue index 0e5fda071..18d9f90af 100644 --- a/src/UserTable.vue +++ b/src/UserTable.vue @@ -64,13 +64,13 @@ : t('workspace', 'Remove admin rights') }} - {{ t('workspace', 'Delete user') }} - diff --git a/src/services/groupfoldersService.js b/src/services/groupfoldersService.js index b2121ebaf..40defbdba 100644 --- a/src/services/groupfoldersService.js +++ b/src/services/groupfoldersService.js @@ -64,7 +64,7 @@ export function get(groupfolderId) { const workspace = resp.data.ocs.data return workspace } else { - throw new GetGroupfolderError('Impossible to get the groupfolder. May be an error network ?') + return {} // might happen on empty workspaces } }) .catch((error) => { diff --git a/src/store/getters.js b/src/store/getters.js index ad295316b..677b297bd 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -31,7 +31,13 @@ export const getters = { }, // Returns the name of a group groupName: state => (name, gid) => { - return state.spaces[name].groups[gid] ? state.spaces[name].groups[gid].displayName : '[' + gid + ']' + if (state.spaces[name].groups[gid]) { + return state.spaces[name].groups[gid].displayName + } + if (state.spaces[name].addedGroups[gid]) { + return state.spaces[name].addedGroups[gid].displayName + } + return '[' + gid + ']' }, // Returns the number of users in a group groupUserCount: state => (spaceName, gid) => { @@ -47,6 +53,17 @@ export const getters = { isSpaceAdmin: state => (user, spaceName) => { return user.groups.includes(ManagerGroup.getGid(state.spaces[spaceName])) }, + // Test whether a user if from and added group from the space + isFromAddedGroups: state => (user, spaceName) => { + const addedGroups = Object.keys(state.spaces[spaceName].addedGroups) + const hasAddedGroups = user.groups.filter((group) => addedGroups.includes(group)) + return hasAddedGroups.length > 0 + }, + // Test if group is from space added groups + isSpaceAddedGroup: state => (spaceName, groupName) => { + const space = state.spaces[spaceName] + return space.addedGroups[groupName] + }, // Tests wheter a group is the GE or U group of a space isGEorUGroup: (state, getters) => (spaceName, gid) => { return gid === getters.GEGroup(spaceName) || gid === getters.UGroup(spaceName) @@ -66,8 +83,11 @@ export const getters = { }, // Returns the number of users in a space spaceUserCount: state => name => { + if (state.spaces[name] === undefined) { + return 0 + } const users = state.spaces[name].users - if (users.length === 0) { + if (users === undefined || users.length === 0) { return 0 } else { return Object.keys(users).length