1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-19 03:01:11 +01:00

Improve branch table view with history link & other features

Summary: Add history column & history link per branch on branch table view, also later add some more features like last commit date, etc.

Test Plan: Checked if History column is in browser table view & history links are properly linked.

Reviewers: epriestley

Reviewed By: epriestley

CC: davidreuss, aran, Koolvin

Maniphest Tasks: T1201, T1202, T1200

Differential Revision: https://secure.phabricator.com/D2432
This commit is contained in:
Aurelijus 2012-05-08 22:28:27 +02:00 committed by epriestley
parent d2b01aead0
commit 872845cc6c
3 changed files with 52 additions and 0 deletions

View file

@ -99,9 +99,18 @@ final class DiffusionRepositoryController extends DiffusionController {
$branch_query = DiffusionBranchQuery::newFromDiffusionRequest($drequest);
$branches = $branch_query->loadBranches();
$commits = id(new PhabricatorAuditCommitQuery())
->withIdentifiers(
$drequest->getRepository()->getID(),
mpull($branches, 'getHeadCommitIdentifier'))
->needCommitData(true)
->execute();
$branch_table = new DiffusionBranchTableView();
$branch_table->setDiffusionRequest($drequest);
$branch_table->setBranches($branches);
$branch_table->setCommits($commits);
$branch_table->setUser($this->getRequest()->getUser());
$branch_panel = new AphrontPanelView();
$branch_panel->setHeader('Branches');

View file

@ -26,6 +26,16 @@ final class DiffusionBranchTableView extends DiffusionView {
return $this;
}
public function setCommits(array $commits) {
$this->commits = mpull($commits, null, 'getCommitIdentifier');
return $this;
}
public function setUser(PhabricatorUser $user) {
$this->user = $user;
return $this;
}
public function render() {
$drequest = $this->getDiffusionRequest();
$current_branch = $drequest->getBranch();
@ -33,7 +43,30 @@ final class DiffusionBranchTableView extends DiffusionView {
$rows = array();
$rowc = array();
foreach ($this->branches as $branch) {
$commit = idx($this->commits, $branch->getHeadCommitIdentifier());
if ($commit) {
$details = $commit->getCommitData()->getCommitMessage();
$details = idx(explode("\n", $details), 0);
$details = substr($details, 0, 80);
$datetime = phabricator_datetime($commit->getEpoch(), $this->user);
} else {
$datetime = null;
$details = null;
}
$rows[] = array(
phutil_render_tag(
'a',
array(
'href' => $drequest->generateURI(
array(
'action' => 'history',
'branch' => $branch->getName(),
))
),
'History'
),
phutil_render_tag(
'a',
array(
@ -47,6 +80,9 @@ final class DiffusionBranchTableView extends DiffusionView {
self::linkCommit(
$drequest->getRepository(),
$branch->getHeadCommitIdentifier()),
$datetime,
AphrontTableView::renderSingleDisplayLine(
phutil_escape_html($details))
// TODO: etc etc
);
if ($branch->getName() == $current_branch) {
@ -59,12 +95,18 @@ final class DiffusionBranchTableView extends DiffusionView {
$view = new AphrontTableView($rows);
$view->setHeaders(
array(
'History',
'Branch',
'Head',
'Modified',
'Details',
));
$view->setColumnClasses(
array(
'',
'pri',
'',
'',
'wide',
));
$view->setRowClasses($rowc);

View file

@ -8,6 +8,7 @@
phutil_require_module('phabricator', 'applications/diffusion/view/base');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/utils');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');