-
-
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
Open
stediefan
wants to merge
1
commit into
nextcloud:master
Choose a base branch
from
Dataport:feature/teams-auto-folder-creation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCP\Teams; | ||
|
|
||
| /** | ||
| * Provides the exclusive folder belonging to a team. | ||
| * | ||
| * Register implementations through | ||
| * {@see \OCP\AppFramework\Bootstrap\IRegistrationContext::registerTeamResourceProvider()}. | ||
| * | ||
| * @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,52 @@ | ||||||||
| <?php | ||||||||
|
|
||||||||
| declare(strict_types=1); | ||||||||
|
|
||||||||
| /** | ||||||||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||||||||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||||||||
| */ | ||||||||
|
|
||||||||
| namespace OCP\Teams; | ||||||||
|
|
||||||||
| /** | ||||||||
| * A folder exclusively linked to a team. | ||||||||
| * | ||||||||
| * @since 35.0.0 | ||||||||
| */ | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
And need a corresponding |
||||||||
| 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,61 @@ | ||
| <?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 OCA\Circles\CirclesManager; | ||
| 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(null); | ||
|
|
||
| $this->assertNull($teamManager->getTeamFolderProvider()); | ||
| } | ||
|
|
||
| public function testGetTeamFolderProviderReturnsNullWithoutFolderProvider(): void { | ||
| $teamManager = $this->createTeamManager($this->createMock(CirclesManager::class)); | ||
| $this->setProviders($teamManager, [ | ||
| 'other' => $this->createMock(ITeamResourceProvider::class), | ||
| ]); | ||
|
|
||
| $this->assertNull($teamManager->getTeamFolderProvider()); | ||
| } | ||
|
|
||
| public function testGetTeamFolderProviderReturnsRegisteredFolderProvider(): void { | ||
| $teamManager = $this->createTeamManager($this->createMock(CirclesManager::class)); | ||
| $folderProvider = $this->createMock(ITeamFolderProvider::class); | ||
| $this->setProviders($teamManager, [ | ||
| 'other' => $this->createMock(ITeamResourceProvider::class), | ||
| 'folder' => $folderProvider, | ||
| ]); | ||
|
|
||
| $this->assertSame($folderProvider, $teamManager->getTeamFolderProvider()); | ||
| } | ||
|
|
||
| private function createTeamManager(?CirclesManager $circlesManager): TeamManager { | ||
| return new TeamManager( | ||
| $this->createMock(Coordinator::class), | ||
| $this->createMock(IURLGenerator::class), | ||
| $circlesManager, | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And need
use OCP\AppFramework\Attribute\Consumable;anduse OCP\AppFramework\Attribute\Implementable;at the top of the file