diff --git a/src/applications/diffusion/controller/DiffusionBrowseController.php b/src/applications/diffusion/controller/DiffusionBrowseController.php index 48313014c0..ea960bdae0 100644 --- a/src/applications/diffusion/controller/DiffusionBrowseController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseController.php @@ -65,7 +65,7 @@ abstract class DiffusionBrowseController extends DiffusionController { $header = id(new PHUIHeaderView()) ->setUser($viewer) - ->setHeader($this->renderPathLinks($drequest, 'browse')) + ->setHeader($this->renderPathLinks($drequest, $mode = 'browse')) ->setPolicyObject($drequest->getRepository()); return $header; diff --git a/src/applications/diffusion/controller/DiffusionChangeController.php b/src/applications/diffusion/controller/DiffusionChangeController.php index ee803f1da2..1e8192c35e 100644 --- a/src/applications/diffusion/controller/DiffusionChangeController.php +++ b/src/applications/diffusion/controller/DiffusionChangeController.php @@ -73,7 +73,7 @@ final class DiffusionChangeController extends DiffusionController { 'view' => 'change', )); - $links = $this->renderPathLinks($drequest); + $links = $this->renderPathLinks($drequest, $mode = 'browse'); $header = id(new PHUIHeaderView()) ->setHeader($links) @@ -106,18 +106,13 @@ final class DiffusionChangeController extends DiffusionController { 'action' => 'history', )); - $browse_uri = $drequest->generateURI( - array( - 'action' => 'browse', - )); - $view->addAction( id(new PhabricatorActionView()) ->setName(pht('View History')) ->setHref($history_uri) ->setIcon('history')); - $history_uri = $drequest->generateURI( + $browse_uri = $drequest->generateURI( array( 'action' => 'browse', )); diff --git a/src/applications/diffusion/controller/DiffusionController.php b/src/applications/diffusion/controller/DiffusionController.php index b45c4b010d..f75a75f389 100644 --- a/src/applications/diffusion/controller/DiffusionController.php +++ b/src/applications/diffusion/controller/DiffusionController.php @@ -202,7 +202,7 @@ abstract class DiffusionController extends PhabricatorController { $crumb = id(new PhabricatorCrumbView()) ->setName($view_name); - if ($view == 'browse' || $view == 'change') { + if ($view == 'browse' || $view == 'change' || $view == 'history') { $crumb_list[] = $crumb; return $crumb_list; } @@ -286,7 +286,7 @@ abstract class DiffusionController extends PhabricatorController { return $this->getApplicationURI($repository->getCallsign().'/'.$path); } - protected function renderPathLinks(DiffusionRequest $drequest) { + protected function renderPathLinks(DiffusionRequest $drequest, $action) { $path = $drequest->getPath(); $path_parts = array_filter(explode('/', trim($path, '/'))); @@ -297,7 +297,7 @@ abstract class DiffusionController extends PhabricatorController { array( 'href' => $drequest->generateURI( array( - 'action' => 'browse', + 'action' => $action, 'path' => '', )), ), @@ -315,7 +315,7 @@ abstract class DiffusionController extends PhabricatorController { array( 'href' => $drequest->generateURI( array( - 'action' => 'browse', + 'action' => $action, 'path' => $accum, )), ), diff --git a/src/applications/diffusion/controller/DiffusionHistoryController.php b/src/applications/diffusion/controller/DiffusionHistoryController.php index ab37b920a5..e243c48bb0 100644 --- a/src/applications/diffusion/controller/DiffusionHistoryController.php +++ b/src/applications/diffusion/controller/DiffusionHistoryController.php @@ -2,18 +2,25 @@ final class DiffusionHistoryController extends DiffusionController { + public function shouldAllowPublic() { + return true; + } + public function processRequest() { $drequest = $this->diffusionRequest; $request = $this->getRequest(); + $viewer = $request->getUser(); + $repository = $drequest->getRepository(); $page_size = $request->getInt('pagesize', 100); - $offset = $request->getInt('page', 0); + $offset = $request->getInt('offset', 0); $params = array( 'commit' => $drequest->getCommit(), 'path' => $drequest->getPath(), 'offset' => $offset, 'limit' => $page_size + 1); + if (!$request->getBool('copies')) { $params['needDirectChanges'] = true; $params['needChildChanges'] = true; @@ -28,33 +35,13 @@ final class DiffusionHistoryController extends DiffusionController { $pager = new AphrontPagerView(); $pager->setPageSize($page_size); $pager->setOffset($offset); - if (count($history) == $page_size + 1) { - array_pop($history); - $pager->setHasMorePages(true); - } else { - $pager->setHasMorePages(false); - } - $pager->setURI($request->getRequestURI(), 'page'); + $history = $pager->sliceResults($history); + + $pager->setURI($request->getRequestURI(), 'offset'); $show_graph = !strlen($drequest->getPath()); $content = array(); - if ($request->getBool('copies')) { - $button_title = pht('Hide Copies/Branches'); - $copies_new = null; - } else { - $button_title = pht('Show Copies/Branches'); - $copies_new = true; - } - - $button = phutil_tag( - 'a', - array( - 'class' => 'button small grey', - 'href' => $request->getRequestURI()->alter('copies', $copies_new), - ), - $button_title); - $history_table = new DiffusionHistoryTableView(); $history_table->setUser($request->getUser()); $history_table->setDiffusionRequest($drequest); @@ -71,29 +58,35 @@ final class DiffusionHistoryController extends DiffusionController { } $history_panel = new AphrontPanelView(); - $history_panel->setHeader(pht('History')); - $history_panel->addButton($button); $history_panel->appendChild($history_table); $history_panel->appendChild($pager); $history_panel->setNoBackground(); $content[] = $history_panel; - // TODO: Sometimes we do have a change view, we need to look at the most - // recent history entry to figure it out. + $header = id(new PHUIHeaderView()) + ->setUser($viewer) + ->setPolicyObject($repository) + ->setHeader($this->renderPathLinks($drequest, $mode = 'history')); + + $actions = $this->buildActionView($drequest); + $properties = $this->buildPropertyView($drequest); - $nav = $this->buildSideNav('history', false); - $nav->appendChild($content); $crumbs = $this->buildCrumbs( array( 'branch' => true, 'path' => true, 'view' => 'history', )); - $nav->setCrumbs($crumbs); return $this->buildApplicationPage( - $nav, + array( + $crumbs, + $header, + $actions, + $properties, + $content, + ), array( 'device' => true, 'title' => array( @@ -103,4 +96,75 @@ final class DiffusionHistoryController extends DiffusionController { )); } + private function buildActionView(DiffusionRequest $drequest) { + $viewer = $this->getRequest()->getUser(); + + $view = id(new PhabricatorActionListView()) + ->setUser($viewer); + + $browse_uri = $drequest->generateURI( + array( + 'action' => 'browse', + )); + + $view->addAction( + id(new PhabricatorActionView()) + ->setName(pht('Browse Content')) + ->setHref($browse_uri) + ->setIcon('file')); + + // TODO: Sometimes we do have a change view, we need to look at the most + // recent history entry to figure it out. + + $request = $this->getRequest(); + if ($request->getBool('copies')) { + $branch_name = pht('Hide Copies/Branches'); + $branch_icon = 'fork-grey'; + $branch_uri = $request->getRequestURI() + ->alter('offset', null) + ->alter('copies', null); + } else { + $branch_name = pht('Show Copies/Branches'); + $branch_icon = 'fork'; + $branch_uri = $request->getRequestURI() + ->alter('offset', null) + ->alter('copies', true); + } + + $view->addAction( + id(new PhabricatorActionView()) + ->setName($branch_name) + ->setIcon($branch_icon) + ->setHref($branch_uri)); + + return $view; + } + + protected function buildPropertyView(DiffusionRequest $drequest) { + $viewer = $this->getRequest()->getUser(); + + $view = id(new PhabricatorPropertyListView()) + ->setUser($viewer); + + $stable_commit = $drequest->getStableCommitName(); + $callsign = $drequest->getRepository()->getCallsign(); + + $view->addProperty( + pht('Commit'), + phutil_tag( + 'a', + array( + 'href' => $drequest->generateURI( + array( + 'action' => 'commit', + 'commit' => $stable_commit, + )), + ), + $drequest->getRepository()->formatCommitName($stable_commit))); + + return $view; + } + + + }