committed by
Julius Härtl
parent
e28a47e9e0
commit
eb8bf3f22b
@@ -36,6 +36,7 @@ use OCA\Deck\Db\StackMapper;
|
||||
use OCA\Deck\Service\BoardService;
|
||||
use OCA\Deck\Service\LabelService;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IL10N;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
@@ -57,12 +58,12 @@ class TrelloHelper extends ImportAbstract implements ImportInterface {
|
||||
private $connection;
|
||||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
/** @var TrelloActions */
|
||||
private $trelloActions;
|
||||
/** @var Board */
|
||||
private $board;
|
||||
/** @var LabelService */
|
||||
private $labelService;
|
||||
/** @var IL10N */
|
||||
private $l10n;
|
||||
/**
|
||||
* Data object created from JSON of origin system
|
||||
*
|
||||
@@ -83,7 +84,7 @@ class TrelloHelper extends ImportAbstract implements ImportInterface {
|
||||
private $labels = [];
|
||||
/** @var Card[] */
|
||||
private $cards = [];
|
||||
/** @var IUser */
|
||||
/** @var IUser[] */
|
||||
private $members = [];
|
||||
|
||||
public function __construct(
|
||||
@@ -94,7 +95,8 @@ class TrelloHelper extends ImportAbstract implements ImportInterface {
|
||||
AssignmentMapper $assignmentMapper,
|
||||
AclMapper $aclMapper,
|
||||
IDBConnection $connection,
|
||||
IUserManager $userManager
|
||||
IUserManager $userManager,
|
||||
IL10N $l10n
|
||||
) {
|
||||
$this->boardService = $boardService;
|
||||
$this->labelService = $labelService;
|
||||
@@ -104,6 +106,7 @@ class TrelloHelper extends ImportAbstract implements ImportInterface {
|
||||
$this->aclMapper = $aclMapper;
|
||||
$this->connection = $connection;
|
||||
$this->userManager = $userManager;
|
||||
$this->l10n = $l10n;
|
||||
}
|
||||
|
||||
public function validate(InputInterface $input, OutputInterface $output): void {
|
||||
@@ -127,7 +130,7 @@ class TrelloHelper extends ImportAbstract implements ImportInterface {
|
||||
$this->importCards();
|
||||
}
|
||||
|
||||
private function assignUsersToBoard() {
|
||||
private function assignUsersToBoard(): void {
|
||||
foreach ($this->members as $member) {
|
||||
$acl = new Acl();
|
||||
$acl->setBoardId($this->board->getId());
|
||||
@@ -260,17 +263,15 @@ class TrelloHelper extends ImportAbstract implements ImportInterface {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private function appendAttachmentsToDescription($trelloCard) {
|
||||
if (empty($trelloCard->attachments)) {
|
||||
return;
|
||||
}
|
||||
$translations = $this->getSetting('translations');
|
||||
$attachmentsLabel = empty($translations->{'Attachments'}) ? 'Attachments' : $translations->{'Attachments'};
|
||||
$URLLabel = empty($translations->{'URL'}) ? 'URL' : $translations->{'URL'};
|
||||
$nameLabel = empty($translations->{'Name'}) ? 'Name' : $translations->{'Name'};
|
||||
$dateLabel = empty($translations->{'Date'}) ? 'Date' : $translations->{'Date'};
|
||||
$trelloCard->desc .= "\n\n## {$attachmentsLabel}\n";
|
||||
$trelloCard->desc .= "| $URLLabel | $nameLabel | $dateLabel |\n";
|
||||
$trelloCard->desc .= "\n\n## {$this->l10n->t('Attachments')}\n";
|
||||
$trelloCard->desc .= "| {$this->l10n->t('URL')} | {$this->l10n->t('Name')} | {$this->l10n->t('date')} |\n";
|
||||
$trelloCard->desc .= "|---|---|---|\n";
|
||||
foreach ($trelloCard->attachments as $attachment) {
|
||||
$name = $attachment->name === $attachment->url ? null : $attachment->name;
|
||||
@@ -278,7 +279,7 @@ class TrelloHelper extends ImportAbstract implements ImportInterface {
|
||||
}
|
||||
}
|
||||
|
||||
private function assignToMember(Card $card, $trelloCard) {
|
||||
private function assignToMember(Card $card, $trelloCard): void {
|
||||
foreach ($trelloCard->idMembers as $idMember) {
|
||||
$assignment = new Assignment();
|
||||
$assignment->setCardId($card->getId());
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"pattern": "^[0-9a-fA-F]{6}$"
|
||||
},
|
||||
"translations": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ use OCA\Deck\Db\StackMapper;
|
||||
use OCA\Deck\Service\BoardService;
|
||||
use OCA\Deck\Service\LabelService;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IL10N;
|
||||
use OCP\IUserManager;
|
||||
use Symfony\Component\Console\Helper\HelperSet;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
@@ -52,6 +53,8 @@ class TrelloHelperTest extends \Test\TestCase {
|
||||
private $userManager;
|
||||
/** @var TrelloHelper */
|
||||
private $trelloHelper;
|
||||
/** @var IL10N */
|
||||
private $l10n;
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->boardService = $this->createMock(BoardService::class);
|
||||
@@ -62,6 +65,7 @@ class TrelloHelperTest extends \Test\TestCase {
|
||||
$this->aclMapper = $this->createMock(AclMapper::class);
|
||||
$this->connection = $this->createMock(IDBConnection::class);
|
||||
$this->userManager = $this->createMock(IUserManager::class);
|
||||
$this->l10n = $this->createMock(IL10N::class);
|
||||
$this->trelloHelper = new TrelloHelper(
|
||||
$this->boardService,
|
||||
$this->labelService,
|
||||
@@ -70,7 +74,8 @@ class TrelloHelperTest extends \Test\TestCase {
|
||||
$this->assignmentMapper,
|
||||
$this->aclMapper,
|
||||
$this->connection,
|
||||
$this->userManager
|
||||
$this->userManager,
|
||||
$this->l10n
|
||||
);
|
||||
$questionHelper = new QuestionHelper();
|
||||
$command = new BoardImport($this->trelloHelper);
|
||||
|
||||
Reference in New Issue
Block a user