1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Clean up Diffusion repository list

Summary: Simplify rendering of the repository list. For inactive repositories, mark them disabled.

Test Plan: {F57615}

Reviewers: btrahan, rockybean

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6921
This commit is contained in:
epriestley 2013-09-08 12:10:11 -07:00
parent c74ebf9ce0
commit 51eb8a301a
2 changed files with 40 additions and 62 deletions

View file

@ -31,79 +31,53 @@ final class DiffusionRepositoryListController extends DiffusionController
$viewer = $this->getRequest()->getUser();
$rows = array();
$list = new PhabricatorObjectItemListView();
foreach ($repositories as $repository) {
$id = $repository->getID();
$item = id(new PhabricatorObjectItemView())
->setUser($viewer)
->setHeader($repository->getName())
->setHref($this->getApplicationURI($repository->getCallsign().'/'));
$commit = $repository->getMostRecentCommit();
if ($commit) {
$commit_link = DiffusionView::linkCommit(
$repository,
$commit->getCommitIdentifier(),
$commit->getSummary());
$item->setSubhead($commit_link);
$item->setEpoch($commit->getEpoch());
}
$item->addAttribute(
PhabricatorRepositoryType::getNameForRepositoryType(
$repository->getVersionControlSystem()));
$size = $repository->getCommitCount();
if ($size) {
$size = hsprintf(
'<a href="%s">%s</a>',
DiffusionRequest::generateDiffusionURI(array(
$history_uri = DiffusionRequest::generateDiffusionURI(
array(
'callsign' => $repository->getCallsign(),
'action' => 'history',
)),
pht('%s Commits', new PhutilNumber($size)));
));
$item->addAttribute(
phutil_tag(
'a',
array(
'href' => $history_uri,
),
pht('%s Commit(s)', new PhutilNumber($size))));
} else {
$item->addAttribute(pht('No Commits'));
}
$datetime = '';
$most_recent_commit = $repository->getMostRecentCommit();
if ($most_recent_commit) {
$date = phabricator_date($most_recent_commit->getEpoch(), $viewer);
$time = phabricator_time($most_recent_commit->getEpoch(), $viewer);
$datetime = $date.' '.$time;
if (!$repository->isTracked()) {
$item->setDisabled(true);
$item->addIcon('disable-grey', pht('Inactive'));
}
$rows[] = array(
$repository->getName(),
('/diffusion/'.$repository->getCallsign().'/'),
PhabricatorRepositoryType::getNameForRepositoryType(
$repository->getVersionControlSystem()),
$size ? $size : null,
$most_recent_commit
? DiffusionView::linkCommit(
$repository,
$most_recent_commit->getCommitIdentifier(),
$most_recent_commit->getSummary())
: pht('No Commits'),
$datetime
);
}
$repository_tool_uri = PhabricatorEnv::getProductionURI('/repository/');
$repository_tool = phutil_tag('a',
array(
'href' => $repository_tool_uri,
),
'repository tool');
$preface = pht('This instance of Phabricator does not have any '.
'configured repositories.');
if ($viewer->getIsAdmin()) {
$no_repositories_txt = hsprintf(
'%s %s',
$preface,
pht(
'To setup one or more repositories, visit the %s.',
$repository_tool));
} else {
$no_repositories_txt = hsprintf(
'%s %s',
$preface,
pht(
'Ask an administrator to setup one or more repositories '.
'via the %s.',
$repository_tool));
}
$list = new PHUIObjectItemListView();
foreach ($rows as $row) {
$item = id(new PHUIObjectItemView())
->setHeader($row[0])
->setSubHead($row[4])
->setHref($row[1])
->addAttribute(($row[2] ? $row[2] : pht('No Information')))
->addAttribute(($row[3] ? $row[3] : pht('0 Commits')))
->addIcon('none', $row[5]);
$list->addItem($item);
}

View file

@ -677,6 +677,10 @@ abstract class PhabricatorBaseEnglishTranslation
'Old (%s days)',
),
'%s Commit(s)' => array(
'%s Commit',
'%s Commits',
),
);
}