Skip to content

Commit

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

SPDX Header BoardCloneModal.vue

Signed-off-by: grnd-alt <salimbelakkaf@outlook.de>
  • Loading branch information
grnd-alt committed May 24, 2024
1 parent 81b08ef commit 4ce2d79
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 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
23 changes: 3 additions & 20 deletions src/components/navigation/BoardCloneModal.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
<!--
- @copyright Copyright (c) 2021 Max Bachhuber <max.bachhuber@bahuma.io>
-
- @author Max Bachhuber <max.bachhuber@bahuma.io>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->
- SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<NcModal size="small" :show="true" @close="close(false)">
<div class="modal__content">
Expand Down

0 comments on commit 4ce2d79

Please sign in to comment.