mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
feat(profile): show Teams memberships on account details
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
This commit is contained in:
parent
7fa568b453
commit
5c1b795cb5
4 changed files with 51 additions and 2 deletions
|
|
@ -29,6 +29,8 @@ use OCP\L10N\IFactory;
|
|||
use OCP\Notification\IManager;
|
||||
use OCP\Server;
|
||||
use OCP\Settings\ISettings;
|
||||
use OCP\Teams\ITeamManager;
|
||||
use OCP\Teams\Team;
|
||||
use OCP\Util;
|
||||
|
||||
class PersonalInfo implements ISettings {
|
||||
|
|
@ -40,6 +42,7 @@ class PersonalInfo implements ISettings {
|
|||
private IConfig $config,
|
||||
private IUserManager $userManager,
|
||||
private IGroupManager $groupManager,
|
||||
private ITeamManager $teamManager,
|
||||
private IAccountManager $accountManager,
|
||||
ProfileManager $profileManager,
|
||||
private IAppManager $appManager,
|
||||
|
|
@ -87,6 +90,7 @@ class PersonalInfo implements ISettings {
|
|||
'userId' => $uid,
|
||||
'avatar' => $this->getProperty($account, IAccountManager::PROPERTY_AVATAR),
|
||||
'groups' => $this->getGroups($user),
|
||||
'teams' => $this->getTeamMemberships($user),
|
||||
'quota' => $storageInfo['quota'],
|
||||
'totalSpace' => $totalSpace,
|
||||
'usage' => Util::humanFileSize($storageInfo['used']),
|
||||
|
|
@ -192,6 +196,26 @@ class PersonalInfo implements ISettings {
|
|||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a sorted list of the user's team memberships
|
||||
*/
|
||||
private function getTeamMemberships(IUser $user): array {
|
||||
$circlesEnabled = $this->appManager->isEnabledForUser('circles');
|
||||
if (!$circlesEnabled) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$teams = array_map(
|
||||
static function (Team $team) {
|
||||
return $team->getDisplayName();
|
||||
},
|
||||
$this->teamManager->getMemberships($user->getUID())
|
||||
);
|
||||
sort($teams);
|
||||
|
||||
return $teams;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the primary email and additional emails in an
|
||||
* associative array
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<div class="details__groups-info">
|
||||
<p>{{ t('settings', 'You are a member of the following groups:') }}</p>
|
||||
<p class="details__groups-list">
|
||||
{{ groups.join(', ') }}
|
||||
{{ [...groups, ...teams].join(', ') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -43,7 +43,7 @@ import HeaderBar from './shared/HeaderBar.vue'
|
|||
/** SYNC to be kept in sync with `lib/public/Files/FileInfo.php` */
|
||||
const SPACE_UNLIMITED = -3
|
||||
|
||||
const { groups, quota, totalSpace, usage, usageRelative } = loadState('settings', 'personalInfoParameters', {})
|
||||
const { groups, teams, quota, totalSpace, usage, usageRelative } = loadState('settings', 'personalInfoParameters', {})
|
||||
|
||||
export default {
|
||||
name: 'DetailsSection',
|
||||
|
|
@ -58,6 +58,7 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
groups,
|
||||
teams,
|
||||
usageRelative,
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -144,4 +144,20 @@ class TeamManager implements ITeamManager {
|
|||
$this->circlesManager->startSession($federatedUser);
|
||||
return $this->circlesManager->getCirclesByIds($teams);
|
||||
}
|
||||
|
||||
public function getMemberships(string $userId): array {
|
||||
if (!$this->hasTeamSupport()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$federatedUser = $this->circlesManager->getFederatedUser($userId, Member::TYPE_USER);
|
||||
$this->circlesManager->startSession($federatedUser);
|
||||
return array_map(function (Circle $team) {
|
||||
return new Team(
|
||||
$team->getSingleId(),
|
||||
$team->getDisplayName(),
|
||||
$this->urlGenerator->linkToRouteAbsolute('contacts.contacts.directcircle', ['singleId' => $team->getSingleId()]),
|
||||
);
|
||||
}, $this->circlesManager->getCircles());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,4 +48,12 @@ interface ITeamManager {
|
|||
* @since 33.0.0
|
||||
*/
|
||||
public function getSharedWithList(array $teams, string $userId): array;
|
||||
|
||||
/**
|
||||
* Returns all teams that a given user is a member of
|
||||
*
|
||||
* @return Team[]
|
||||
* @since 33.0.0
|
||||
*/
|
||||
public function getMemberships(string $userId): array;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue