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
});
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);
}
......
......@@ -4,10 +4,12 @@ namespace TracToGitlab;
final class GitlabIssue
{
private $issue;
private $mrs;
public function __construct(array $issue)
public function __construct(array $issue, array $mrs = [])
{
$this->issue = $issue;
$this->mrs = $mrs;
}
public function __get($offset)
......@@ -17,6 +19,7 @@ final class GitlabIssue
return $assignee['username'];
}, $this->issue['assignees']));
}
if ($offset === 'type') {
if ($this->isBiest()) {
return 'BIEST';
......@@ -29,6 +32,7 @@ final class GitlabIssue
}
return '?';
}
return $this->issue[$offset] ?? null;
}
......@@ -37,6 +41,19 @@ final class GitlabIssue
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()
{
return in_array('BIEST', $this->issue['labels']);
......
......@@ -10,6 +10,7 @@
<th><?= _('Issue') ?></th>
<th><?= _('Typ') ?></th>
<th><?= _('Status') ?></th>
<th><?= _('MR') ?></th>
<th><?= _('Titel') ?></th>
<th><?= _('Autor') ?></th>
<th><?= _('Bearbeiter') ?></th>
......@@ -25,7 +26,7 @@
<tbody>
<? if (!$issues): ?>
<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') ?>
</td>
</tr>
......@@ -45,6 +46,21 @@
open
<? endif; ?>
</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>
<a href="<?= htmlReady($issue->web_url) ?>" target="_blank">
<?= htmlReady($issue->title) ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment