Skip to content

fix: Properly display teams in usergroup #1754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/Constants/UsergroupType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Tables\Constants;

class UsergroupType {
public const USER = 0;
public const GROUP = 1;
public const CIRCLE = 2;
}
12 changes: 11 additions & 1 deletion lib/Db/RowCellUsergroupMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@

namespace OCA\Tables\Db;

use OCA\Tables\Constants\UsergroupType;
use OCA\Tables\Helper\CircleHelper;
use OCP\IDBConnection;
use OCP\IUserManager;
use OCP\IUserSession;

/** @template-extends RowCellMapperSuper<RowCellUsergroup, array, array> */
class RowCellUsergroupMapper extends RowCellMapperSuper {
Expand All @@ -17,6 +20,8 @@ class RowCellUsergroupMapper extends RowCellMapperSuper {
public function __construct(
IDBConnection $db,
private IUserManager $userManager,
private CircleHelper $circleHelper,
protected IUserSession $userSession,
) {
parent::__construct($db, $this->table, RowCellUsergroup::class);
}
Expand All @@ -34,7 +39,12 @@ public function applyDataToEntity(Column $column, RowCellSuper $cell, $data): vo
}

public function formatEntity(Column $column, RowCellSuper $cell) {
$displayName = $cell->getValueType() === 0 ? ($this->userManager->getDisplayName($cell->getValue()) ?? $cell->getValue()) : $cell->getValue();
$displayName = $cell->getValue();
if ($cell->getValueType() === UsergroupType::USER) {
$displayName = $this->userManager->getDisplayName($cell->getValue()) ?? $cell->getValue();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw groups also have displaynames

} elseif ($cell->getValueType() === UsergroupType::CIRCLE) {
$displayName = $this->circleHelper->getCircleDisplayName($cell->getValue(), ($this->userSession->getUser()?->getUID() ?: '')) ?: $cell->getValue();
}
return [
'id' => $cell->getValue(),
'type' => $cell->getValueType(),
Expand Down
16 changes: 14 additions & 2 deletions src/shared/components/ncTable/partials/TableCellUsergroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
<!-- eslint-disable-next-line vue/no-v-html -->
<div v-if="value" class="table-cell-usergroup">
<div v-for="item in value" :key="item.id" class="inline usergroup-entry">
<NcUserBubble :user="item.id" :avatar-image="item.type === 1 ? 'icon-group' : ''" :is-no-user="item.type !== 0" :display-name="item.displayName ?? item.id" :show-user-status="isUser(item) && column.showUserStatus" :size="column.showUserStatus ? 34 : 20" :primary="isCurrentUser(item)" />
<NcUserBubble :user="item.id" :avatar-image="getAvatarImage(item)" :is-no-user="!isUser(item)" :display-name="item.displayName ?? item.id" :show-user-status="isUser(item) && column.showUserStatus" :size="column.showUserStatus ? 34 : 20" :primary="isCurrentUser(item)" />
</div>
</div>
</template>

<script>
import { getCurrentUser } from '@nextcloud/auth'
import { NcUserBubble } from '@nextcloud/vue'
import { USERGROUP_TYPE } from '../../../constants.js'

const currentUser = getCurrentUser()

Expand Down Expand Up @@ -41,7 +42,18 @@ export default {
return (item) => this.isUser(item) && item.id === currentUser?.uid
},
isUser() {
return (item) => item.type === 0
return (item) => item.type === USERGROUP_TYPE.USER
},
},
methods: {
getAvatarImage(item) {
if (item.type === USERGROUP_TYPE.GROUP) {
return 'icon-group'
}
if (item.type === USERGROUP_TYPE.CIRCLE) {
return 'icon-circles'
}
return ''
},
},
}
Expand Down
6 changes: 6 additions & 0 deletions src/shared/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ export const NAV_ENTRY_MODE = {
}

export const ALLOWED_PROTOCOLS = ['http:', 'https:']

export const USERGROUP_TYPE = {
USER: 0,
GROUP: 1,
CIRCLE: 2,
}
Loading