-
Notifications
You must be signed in to change notification settings - Fork 318
Transfer ownership #2496
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
Merged
Transfer ownership #2496
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
5d0b8d8
Add deck:transfer-ownership command
matchish 19a2aeb
Update docs
matchish 3d269e2
Add tests
matchish b45c454
Fix code style
matchish e3750a7
Fix wrong class name
matchish 8b45495
Check type before transfer card participants ownership
matchish 7df4b7c
Transfer deck ownership even if target user already participant of a …
matchish 6106066
Fix coding styles
matchish ba7cadf
Fix card mapper query for transfer
juliusknorr 3e7d0d3
Use proper description of what gets transferred
juliusknorr fa7fcef
Just cleanup old ACL rules, there are none for the board owner so not…
juliusknorr e8ada52
Make queries work with the new base mapper
juliusknorr 4d3dabb
fix: Assignment is the new AssignedUsers
max-nextcloud b6340e5
fix: queries with the new base mapper in BoardMapper
max-nextcloud afbbdf0
fix: unit test & psalm static code analysis issues
luka-nextcloud 4615926
fix: integration tests
luka-nextcloud e4551bd
feat: add integration test for transferring board ownership with data
luka-nextcloud 72134e6
fix: unit tests
juliusknorr b774090
fix: Psalm
juliusknorr a45e46f
Allow transfer of single boards
juliusknorr a032287
cleanup test cases
juliusknorr c214437
fix: Properly handle limited scope for remapping users
juliusknorr 4f13977
Reuse single board transfer for all user boards
juliusknorr 3a4ec07
fix: test cases using generator
juliusknorr bf9a51d
feat: add api endpoint and UI to transfer a board to a different user
luka-nextcloud 9f1dbd1
fix: feedback
luka-nextcloud 3f29cd9
Cover case where the owner is preserved
juliusknorr 23f0b16
Handle board exceptions more gracefully
juliusknorr c6aef45
Adjust documentaion wording
juliusknorr 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,105 @@ | ||
| <?php | ||
|
|
||
| namespace OCA\Deck\Command; | ||
|
|
||
| use OCA\Deck\Db\BoardMapper; | ||
| use OCA\Deck\Service\BoardService; | ||
| use OCA\Deck\Service\PermissionService; | ||
| use Symfony\Component\Console\Command\Command; | ||
| use Symfony\Component\Console\Helper\QuestionHelper; | ||
| use Symfony\Component\Console\Input\InputArgument; | ||
| use Symfony\Component\Console\Input\InputInterface; | ||
| use Symfony\Component\Console\Input\InputOption; | ||
| use Symfony\Component\Console\Output\OutputInterface; | ||
| use Symfony\Component\Console\Question\ConfirmationQuestion; | ||
|
|
||
| final class TransferOwnership extends Command { | ||
| protected $boardService; | ||
| protected $boardMapper; | ||
| protected $permissionService; | ||
| protected $questionHelper; | ||
|
|
||
| public function __construct(BoardService $boardService, BoardMapper $boardMapper, PermissionService $permissionService, QuestionHelper $questionHelper) { | ||
| parent::__construct(); | ||
|
|
||
| $this->boardService = $boardService; | ||
| $this->boardMapper = $boardMapper; | ||
| $this->permissionService = $permissionService; | ||
| $this->questionHelper = $questionHelper; | ||
| } | ||
|
|
||
| protected function configure() { | ||
| $this | ||
| ->setName('deck:transfer-ownership') | ||
| ->setDescription('Change owner of deck boards') | ||
| ->addArgument( | ||
| 'owner', | ||
| InputArgument::REQUIRED, | ||
| 'Owner uid' | ||
| ) | ||
| ->addArgument( | ||
| 'newOwner', | ||
| InputArgument::REQUIRED, | ||
| 'New owner uid' | ||
| ) | ||
| ->addArgument( | ||
| 'boardId', | ||
| InputArgument::OPTIONAL, | ||
| 'Single board ID' | ||
| ) | ||
| ->addOption( | ||
| 'remap', | ||
| 'r', | ||
| InputOption::VALUE_NONE, | ||
| 'Reassign card details of the old owner to the new one' | ||
| ) | ||
| ; | ||
| } | ||
|
|
||
| protected function execute(InputInterface $input, OutputInterface $output): int { | ||
| $owner = $input->getArgument('owner'); | ||
| $newOwner = $input->getArgument('newOwner'); | ||
| $boardId = $input->getArgument('boardId'); | ||
|
|
||
| $remapAssignment = $input->getOption('remap'); | ||
|
|
||
| $this->boardService->setUserId($owner); | ||
| $this->permissionService->setUserId($owner); | ||
|
|
||
| try { | ||
| $board = $boardId ? $this->boardMapper->find($boardId) : null; | ||
| } catch (\Exception $e) { | ||
| $output->writeln("Could not find a board for the provided id."); | ||
| return 1; | ||
| } | ||
|
|
||
| if ($boardId !== null && $board->getOwner() !== $owner) { | ||
| $output->writeln("$owner is not the owner of the board $boardId (" . $board->getTitle() . ")"); | ||
| return 1; | ||
| } | ||
|
|
||
| if ($boardId) { | ||
| $output->writeln("Transfer board " . $board->getTitle() . " from ". $board->getOwner() ." to $newOwner"); | ||
| } else { | ||
| $output->writeln("Transfer all boards from $owner to $newOwner"); | ||
| } | ||
|
|
||
| $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false); | ||
| if (!$this->questionHelper->ask($input, $output, $question)) { | ||
| return 1; | ||
| } | ||
|
|
||
| if ($boardId) { | ||
| $this->boardService->transferBoardOwnership($boardId, $newOwner, $remapAssignment); | ||
| $output->writeln("<info>Board " . $board->getTitle() . " from ". $board->getOwner() ." transferred to $newOwner completed</info>"); | ||
| return 0; | ||
| } | ||
|
|
||
| foreach ($this->boardService->transferOwnership($owner, $newOwner, $remapAssignment) as $board) { | ||
| $output->writeln(" - " . $board->getTitle() . " transferred"); | ||
| } | ||
| $output->writeln("<info>All boards from $owner to $newOwner transferred</info>"); | ||
|
|
||
| return 0; | ||
| } | ||
| } |
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
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.