-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
feat: introduce a function to bind a teamfolder to a team #62476
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
Merged
CarlSchwan
merged 6 commits into
nextcloud:master
from
Dataport:feature/teams-auto-folder-creation
Aug 5, 2026
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
43f83ed
feat: introduce a function to bind a teamfolder to a team
stediefan faf66fe
fix(teams): add consumable and implementable annotations
stediefan 9869521
Merge branch 'master' into feature/teams-auto-folder-creation
stediefan 7912a85
fix: tests wrongly assumed ordered items
stediefan 9e0aabf
Merge branch 'master' into feature/teams-auto-folder-creation
stediefan c6e9d20
Merge branch 'master' into feature/teams-auto-folder-creation
stediefan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCP\Teams; | ||
|
|
||
| use OCP\AppFramework\Attribute\Consumable; | ||
| use OCP\AppFramework\Attribute\Implementable; | ||
|
|
||
| /** | ||
| * Provides the exclusive folder belonging to a team. | ||
| * | ||
| * Register implementations through | ||
| * {@see \OCP\AppFramework\Bootstrap\IRegistrationContext::registerTeamResourceProvider()}. | ||
| * | ||
| * @since 35.0.0 | ||
| */ | ||
| #[Consumable(since: '35.0.0')] | ||
| #[Implementable(since: '35.0.0')] | ||
| interface ITeamFolderProvider extends ITeamResourceProvider { | ||
| /** | ||
| * Return the folder exclusively linked to the team. | ||
| * | ||
| * @since 35.0.0 | ||
| */ | ||
| public function getTeamFolder(string $teamId): ?TeamFolder; | ||
|
|
||
| /** | ||
| * Create the exclusive folder for a team, or return its existing folder. | ||
| * | ||
| * @param Team $team The team that owns the folder. | ||
| * @param int $quota Quota in bytes; zero means unlimited. | ||
| * @since 35.0.0 | ||
| */ | ||
| public function createTeamFolder(Team $team, int $quota = 0): TeamFolder; | ||
|
|
||
| /** | ||
| * Remove the exclusive relationship but retain the folder and its contents. | ||
| * | ||
| * @return TeamFolder|null The unlinked folder, if one existed. | ||
| * @since 35.0.0 | ||
| */ | ||
| public function unlinkTeamFolder(string $teamId): ?TeamFolder; | ||
|
|
||
| /** | ||
| * Remove the team folder and its contents. | ||
| * | ||
| * @since 35.0.0 | ||
| */ | ||
| public function removeTeamFolder(string $teamId): bool; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCP\Teams; | ||
|
|
||
| use OCP\AppFramework\Attribute\Consumable; | ||
|
|
||
| /** | ||
| * A folder exclusively linked to a team. | ||
| * | ||
| * @since 35.0.0 | ||
| */ | ||
|
stediefan marked this conversation as resolved.
|
||
| #[Consumable(since: '35.0.0')] | ||
| class TeamFolder implements \JsonSerializable { | ||
| /** | ||
| * @since 35.0.0 | ||
| */ | ||
| public function __construct( | ||
| private int $id, | ||
| private string $mountPoint, | ||
| ) { | ||
| } | ||
|
|
||
| /** | ||
| * @since 35.0.0 | ||
| */ | ||
| public function getId(): int { | ||
| return $this->id; | ||
| } | ||
|
|
||
| /** | ||
| * @since 35.0.0 | ||
| */ | ||
| public function getMountPoint(): string { | ||
| return $this->mountPoint; | ||
| } | ||
|
|
||
| /** | ||
| * @return array{id: int, mountPoint: string} | ||
| * @since 35.0.0 | ||
| */ | ||
| #[\Override] | ||
| public function jsonSerialize(): array { | ||
| return [ | ||
| 'id' => $this->id, | ||
| 'mountPoint' => $this->mountPoint, | ||
| ]; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace Test\Teams; | ||
|
|
||
| use OCP\Teams\TeamFolder; | ||
| use Test\TestCase; | ||
|
|
||
| class TeamFolderTest extends TestCase { | ||
| public function testSerializesFolderIdentity(): void { | ||
| $folder = new TeamFolder(42, 'Engineering'); | ||
|
|
||
| $this->assertSame(42, $folder->getId()); | ||
| $this->assertSame('Engineering', $folder->getMountPoint()); | ||
| $this->assertSame(['id' => 42, 'mountPoint' => 'Engineering'], $folder->jsonSerialize()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace Test\Teams; | ||
|
|
||
| use OC\AppFramework\Bootstrap\Coordinator; | ||
| use OC\Teams\TeamManager; | ||
| use OCP\IURLGenerator; | ||
| use OCP\Teams\ITeamFolderProvider; | ||
| use OCP\Teams\ITeamResourceProvider; | ||
| use Test\TestCase; | ||
|
|
||
| class TeamManagerTest extends TestCase { | ||
| public function testGetTeamFolderProviderReturnsNullWithoutTeamSupport(): void { | ||
| $teamManager = $this->createTeamManager(); | ||
|
|
||
| $this->assertNull($teamManager->getTeamFolderProvider()); | ||
| } | ||
|
|
||
| public function testGetTeamFolderProviderReturnsNullWithoutFolderProvider(): void { | ||
| $teamManager = $this->createTeamManager(true); | ||
| $this->setProviders($teamManager, [ | ||
| 'other' => $this->createMock(ITeamResourceProvider::class), | ||
| ]); | ||
|
|
||
| $this->assertNull($teamManager->getTeamFolderProvider()); | ||
| } | ||
|
|
||
| public function testGetTeamFolderProviderReturnsRegisteredFolderProvider(): void { | ||
| $teamManager = $this->createTeamManager(true); | ||
| $folderProvider = $this->createMock(ITeamFolderProvider::class); | ||
| $this->setProviders($teamManager, [ | ||
| 'other' => $this->createMock(ITeamResourceProvider::class), | ||
| 'folder' => $folderProvider, | ||
| ]); | ||
|
|
||
| $this->assertSame($folderProvider, $teamManager->getTeamFolderProvider()); | ||
| } | ||
|
|
||
| private function createTeamManager(bool $hasTeamSupport = false): TeamManager { | ||
| return new class($this->createMock(Coordinator::class), $this->createMock(IURLGenerator::class), null, $hasTeamSupport, ) extends TeamManager { | ||
| public function __construct( | ||
| Coordinator $bootContext, | ||
| IURLGenerator $urlGenerator, | ||
| null $circlesManager, | ||
| private bool $hasTeamSupport, | ||
| ) { | ||
| parent::__construct($bootContext, $urlGenerator, $circlesManager); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function hasTeamSupport(): bool { | ||
| return $this->hasTeamSupport; | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * @param array<string, ITeamResourceProvider> $providers | ||
| */ | ||
| private function setProviders(TeamManager $teamManager, array $providers): void { | ||
| (new \ReflectionProperty(TeamManager::class, 'providers'))->setValue($teamManager, $providers); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.