Skip to content

Commit

Permalink
update cloneBoards phpdoc
Browse files Browse the repository at this point in the history
make error message clear

Signed-off-by: grnd-alt <salimbelakkaf@outlook.de>
  • Loading branch information
grnd-alt committed May 24, 2024
1 parent 81b08ef commit c0d6d4f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions lib/Service/BoardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,12 @@ public function deleteAcl(int $id): ?Acl {
/**
* @param $id
* @param $userId
* @param $withCards
* @param $withAssignments
* @param $withLabels
* @param $withDueDate
* @param $moveCardsToLeftStack
* @param $restoreArchivedCards
* @return Board
* @throws DoesNotExistException
* @throws \OCA\Deck\NoPermissionException
Expand All @@ -492,9 +498,9 @@ public function clone($id, $userId, $withCards = false, $withAssignments = false
throw new NoPermissionException('Creating boards has been disabled for your account.');
}

$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);

$board = $this->boardMapper->find($boardId);
$board = $this->boardMapper->find($id);
$newBoard = new Board();
$newBoard->setTitle($board->getTitle() . ' (' . $this->l10n->t('copy') . ')');
$newBoard->setOwner($userId);
Expand All @@ -518,7 +524,7 @@ public function clone($id, $userId, $withCards = false, $withAssignments = false
}


$labels = $this->labelMapper->findAll($boardId);
$labels = $this->labelMapper->findAll($id);
foreach ($labels as $label) {
$newLabel = new Label();
$newLabel->setTitle($label->getTitle());
Expand All @@ -527,7 +533,7 @@ public function clone($id, $userId, $withCards = false, $withAssignments = false
$this->labelMapper->insert($newLabel);
}

$stacks = $this->stackMapper->findAll($boardId);
$stacks = $this->stackMapper->findAll($id);
foreach ($stacks as $stack) {
$newStack = new Stack();
$newStack->setTitle($stack->getTitle());
Expand Down Expand Up @@ -654,7 +660,7 @@ private function cloneCards(Board $board, Board $newBoard, bool $withAssignments
});

$newStacks = $this->stackMapper->findAll($newBoard->getId());
usort($stacks, function (Stack $a, Stack $b) {
usort($newStacks, function (Stack $a, Stack $b) {
return $a->getOrder() - $b->getOrder();
});

Expand All @@ -670,6 +676,7 @@ private function cloneCards(Board $board, Board $newBoard, bool $withAssignments
$targetStackId = $moveCardsToLeftStack ? $newStacks[0]->getId() : $newStacks[$i]->getId();

// Create a cloned card.
// Done with setters as only fields set via setters get written to db
$newCard = new Card();
$newCard->setTitle($card->getTitle());
$newCard->setDescription($card->getDescription());
Expand All @@ -680,6 +687,7 @@ private function cloneCards(Board $board, Board $newBoard, bool $withAssignments
$newCard->setDuedate($withDueDate ? $card->getDuedate() : null);
$newCard->setArchived($restoreArchivedCards ? false : $card->getArchived());
$newCard->setStackId($targetStackId);
$newCard->setAssignedUsers($card->getAssignedUsers());

Check failure on line 690 in lib/Service/BoardService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidArgument

lib/Service/BoardService.php:690:32: InvalidArgument: Argument 1 of setAssignedUsers expects array<array-key, OCA\Deck\Db\Assignment>, but array<array-key, OCA\Deck\Db\User>|null provided (see https://psalm.dev/004)

// Persist the cloned card.
$newCard = $this->cardMapper->insert($newCard);
Expand Down
2 changes: 1 addition & 1 deletion src/components/navigation/AppNavigationBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export default {
this.loading = false
await this.$router.push({ name: 'board', params: { id: newBoard.id } })
} catch (e) {
OC.Notification.showTemporary(t('deck', 'An error occurred'))
OC.Notification.showTemporary(t('deck', `Failed to clone board ${this.board.title}`))
console.error(e)
}
}
Expand Down

0 comments on commit c0d6d4f

Please sign in to comment.