From 872845cc6c5a0efecce13c0fd5789019e52d1b35 Mon Sep 17 00:00:00 2001 From: Aurelijus Date: Tue, 8 May 2012 22:28:27 +0200 Subject: [PATCH] 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 --- .../DiffusionRepositoryController.php | 9 ++++ .../branchtable/DiffusionBranchTableView.php | 42 +++++++++++++++++++ .../diffusion/view/branchtable/__init__.php | 1 + 3 files changed, 52 insertions(+) diff --git a/src/applications/diffusion/controller/repository/DiffusionRepositoryController.php b/src/applications/diffusion/controller/repository/DiffusionRepositoryController.php index 8863be0b8c..9a375c7478 100644 --- a/src/applications/diffusion/controller/repository/DiffusionRepositoryController.php +++ b/src/applications/diffusion/controller/repository/DiffusionRepositoryController.php @@ -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'); diff --git a/src/applications/diffusion/view/branchtable/DiffusionBranchTableView.php b/src/applications/diffusion/view/branchtable/DiffusionBranchTableView.php index e350c48cdb..eb6b0bf97c 100644 --- a/src/applications/diffusion/view/branchtable/DiffusionBranchTableView.php +++ b/src/applications/diffusion/view/branchtable/DiffusionBranchTableView.php @@ -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); diff --git a/src/applications/diffusion/view/branchtable/__init__.php b/src/applications/diffusion/view/branchtable/__init__.php index f72a35d580..fcb69782b1 100644 --- a/src/applications/diffusion/view/branchtable/__init__.php +++ b/src/applications/diffusion/view/branchtable/__init__.php @@ -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');