Skip to content

Commit 578a47f

Browse files
committed
Updating the homepage
1 parent e47f276 commit 578a47f

File tree

8 files changed

+49
-22
lines changed

8 files changed

+49
-22
lines changed

app/Resources/views/default/homepage.html.twig

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,24 @@
1111

1212
<h1>Carson: The Issue Butler</h1>
1313

14-
<div>
15-
<a href="{{ needsReviewUrl }}" class="btn btn-primary">Find "Needs Review" issues and pull requests</a>
16-
</div>
17-
14+
<table class="table">
15+
<thead>
16+
<tr>
17+
<th>Repository</th>
18+
<th>Needs Review issues & pull requests</th>
19+
</tr>
20+
</thead>
21+
<tbody>
22+
{% for repository in repositories %}
23+
<tr>
24+
<td>{{ repository.vendor }}/{{ repository.name }}</td>
25+
<td>
26+
<a href="{{ repository.needsReviewUrl }}" class="btn btn-xs btn-default">Needs Review Issues</a>
27+
</td>
28+
</tr>
29+
{% endfor %}
30+
</tbody>
31+
</table>
1832
</div>
1933
</div>
2034
</div>

src/AppBundle/Controller/DefaultController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ class DefaultController extends Controller
1212
*/
1313
public function homepageAction()
1414
{
15+
$repositories = $this->get('app.repository_provider')->getAllRepositories();
16+
1517
return $this->render('default/homepage.html.twig', [
16-
'needsReviewUrl' => $this->get('app.status_api')->getNeedsReviewUrl(),
18+
'repositories' => $repositories
1719
]);
1820
}
1921
}

src/AppBundle/Issues/GitHub/GitHubStatusApi.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class GitHubStatusApi implements StatusApi
1010
{
11-
private $statusToLabel = [
11+
private static $statusToLabel = [
1212
Status::NEEDS_REVIEW => 'Status: Needs Review',
1313
Status::NEEDS_WORK => 'Status: Needs Work',
1414
Status::WORKS_FOR_ME => 'Status: Works for me',
@@ -25,7 +25,7 @@ class GitHubStatusApi implements StatusApi
2525
public function __construct(CachedLabelsApi $labelsApi)
2626
{
2727
$this->labelsApi = $labelsApi;
28-
$this->labelToStatus = array_flip($this->statusToLabel);
28+
$this->labelToStatus = array_flip(self::$statusToLabel);
2929
}
3030

3131
/**
@@ -35,11 +35,11 @@ public function __construct(CachedLabelsApi $labelsApi)
3535
*/
3636
public function setIssueStatus($issueNumber, $newStatus, Repository $repository)
3737
{
38-
if (!isset($this->statusToLabel[$newStatus])) {
38+
if (!isset(self::$statusToLabel[$newStatus])) {
3939
throw new \InvalidArgumentException(sprintf('Invalid status "%s"', $newStatus));
4040
}
4141

42-
$newLabel = $this->statusToLabel[$newStatus];
42+
$newLabel = self::$statusToLabel[$newStatus];
4343
$currentLabels = $this->labelsApi->getIssueLabels($issueNumber, $repository);
4444
$addLabel = true;
4545

@@ -82,13 +82,8 @@ public function getIssueStatus($issueNumber, Repository $repository)
8282
return;
8383
}
8484

85-
public function getNeedsReviewUrl(Repository $repository)
85+
public static function getNeedsReviewLabel()
8686
{
87-
return sprintf(
88-
'https://github.com/%s/%s/labels/%s',
89-
$repository->getVendor(),
90-
$repository->getName(),
91-
rawurlencode($this->statusToLabel[Status::NEEDS_REVIEW])
92-
);
87+
return self::$statusToLabel[Status::NEEDS_REVIEW];
9388
}
9489
}

src/AppBundle/Issues/NullStatusApi.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,4 @@ public function getIssueStatus($issueNumber, Repository $repository)
1515
public function setIssueStatus($issueNumber, $newStatus, Repository $repository)
1616
{
1717
}
18-
19-
public function getNeedsReviewUrl(Repository $repository)
20-
{
21-
}
2218
}

src/AppBundle/Issues/StatusApi.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@ interface StatusApi
1313
public function getIssueStatus($issueNumber, Repository $repository);
1414

1515
public function setIssueStatus($issueNumber, $newStatus, Repository $repository);
16-
17-
public function getNeedsReviewUrl(Repository $repository);
1816
}

src/AppBundle/Repository/Provider/InMemoryRepositoryProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public function getRepository($repositoryName)
4444
return isset($this->repositories[$repositoryName]) ? $this->repositories[$repositoryName] : null;
4545
}
4646

47+
public function getAllRepositories()
48+
{
49+
return array_values($this->repositories);
50+
}
51+
4752
private function addRepository(Repository $repository)
4853
{
4954
$this->repositories[strtolower($repository->getVendor().'/'.$repository->getName())] = $repository;

src/AppBundle/Repository/Provider/RepositoryProviderInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@ interface RepositoryProviderInterface
1515
* @return Repository
1616
*/
1717
public function getRepository($repositoryName);
18+
19+
/**
20+
* @return Repository[]
21+
*/
22+
public function getAllRepositories();
1823
}

src/AppBundle/Repository/Repository.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

33
namespace AppBundle\Repository;
4+
use AppBundle\Issues\GitHub\GitHubStatusApi;
5+
use AppBundle\Issues\Status;
46

57
/**
68
* @author Ener-Getick <egetick@gmail.com>
@@ -83,4 +85,14 @@ public function getSecret()
8385
{
8486
return $this->secret;
8587
}
88+
89+
public function getNeedsReviewUrl()
90+
{
91+
return sprintf(
92+
'https://github.com/%s/%s/labels/%s',
93+
$this->getVendor(),
94+
$this->getName(),
95+
rawurlencode(GitHubStatusApi::getNeedsReviewLabel())
96+
);
97+
}
8698
}

0 commit comments

Comments
 (0)