Skip to content
Snippets Groups Projects
Commit 3e29e4e0 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fixes #30

parent 876757b1
No related branches found
No related tags found
No related merge requests found
...@@ -104,7 +104,11 @@ final class DashboardController extends TracToGitlab\Controller ...@@ -104,7 +104,11 @@ final class DashboardController extends TracToGitlab\Controller
}); });
return array_map(function ($issue) { return array_map(function ($issue) {
return new TracToGitlab\GitlabIssue($issue); $mrs = [];
if ($issue['merge_requests_count'] > 0) {
$mrs = $this->gitlab->issues()->relatedMergeRequests($this->gitlabProjectId, $issue['iid']);
}
return new TracToGitlab\GitlabIssue($issue, $mrs);
}, $issues); }, $issues);
} }
......
...@@ -4,10 +4,12 @@ namespace TracToGitlab; ...@@ -4,10 +4,12 @@ namespace TracToGitlab;
final class GitlabIssue final class GitlabIssue
{ {
private $issue; private $issue;
private $mrs;
public function __construct(array $issue) public function __construct(array $issue, array $mrs = [])
{ {
$this->issue = $issue; $this->issue = $issue;
$this->mrs = $mrs;
} }
public function __get($offset) public function __get($offset)
...@@ -17,6 +19,7 @@ final class GitlabIssue ...@@ -17,6 +19,7 @@ final class GitlabIssue
return $assignee['username']; return $assignee['username'];
}, $this->issue['assignees'])); }, $this->issue['assignees']));
} }
if ($offset === 'type') { if ($offset === 'type') {
if ($this->isBiest()) { if ($this->isBiest()) {
return 'BIEST'; return 'BIEST';
...@@ -29,6 +32,7 @@ final class GitlabIssue ...@@ -29,6 +32,7 @@ final class GitlabIssue
} }
return '?'; return '?';
} }
return $this->issue[$offset] ?? null; return $this->issue[$offset] ?? null;
} }
...@@ -37,6 +41,19 @@ final class GitlabIssue ...@@ -37,6 +41,19 @@ final class GitlabIssue
return $this->issue['state'] !== 'opened'; return $this->issue['state'] !== 'opened';
} }
public function hasMergeRequests(): bool
{
return $this->issue['merge_requests_count'] > 0;
}
public function isMerged()
{
return $this->hasMergeRequests()
&& count(array_filter($this->mrs, function ($mr) {
return $mr['state'] !== 'merged';
})) === 0;
}
public function isBiest() public function isBiest()
{ {
return in_array('BIEST', $this->issue['labels']); return in_array('BIEST', $this->issue['labels']);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<th><?= _('Issue') ?></th> <th><?= _('Issue') ?></th>
<th><?= _('Typ') ?></th> <th><?= _('Typ') ?></th>
<th><?= _('Status') ?></th> <th><?= _('Status') ?></th>
<th><?= _('MR') ?></th>
<th><?= _('Titel') ?></th> <th><?= _('Titel') ?></th>
<th><?= _('Autor') ?></th> <th><?= _('Autor') ?></th>
<th><?= _('Bearbeiter') ?></th> <th><?= _('Bearbeiter') ?></th>
...@@ -25,7 +26,7 @@ ...@@ -25,7 +26,7 @@
<tbody> <tbody>
<? if (!$issues): ?> <? if (!$issues): ?>
<tr> <tr>
<td colspan="<?= 6 + count($mapping) ?>" style="text-align: center"> <td colspan="<?= 7 + count($mapping) ?>" style="text-align: center">
<?= _('Keine Issues für diesen Meilenstein und Typ') ?> <?= _('Keine Issues für diesen Meilenstein und Typ') ?>
</td> </td>
</tr> </tr>
...@@ -45,6 +46,21 @@ ...@@ -45,6 +46,21 @@
open open
<? endif; ?> <? endif; ?>
</td> </td>
<td>
<? if (!$issue->hasMergeRequests()): ?>
<abbr title="<?= _('Kein MR') ?>">
<?= Icon::create('decline', Icon::ROLE_STATUS_RED) ?>
</abbr>
<? elseif ($issue->isMerged()): ?>
<abbr title="<?= _('MR bereits gemerget') ?>">
<?= Icon::create('accept', Icon::ROLE_STATUS_GREEN) ?>
</abbr>
<? else: ?>
<abbr title="<?= _('MR noch nicht gemerget') ?>">
<?= Icon::create('date', Icon::ROLE_STATUS_YELLOW) ?>
</abbr>
<? endif; ?>
</td>
<td> <td>
<a href="<?= htmlReady($issue->web_url) ?>" target="_blank"> <a href="<?= htmlReady($issue->web_url) ?>" target="_blank">
<?= htmlReady($issue->title) ?> <?= htmlReady($issue->title) ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment