Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionHistoryController.php
| Show All 34 Lines | $history_results = $this->callConduitWithDiffusionRequest( | ||||
| 'diffusion.historyquery', | 'diffusion.historyquery', | ||||
| $params); | $params); | ||||
| $history = DiffusionPathChange::newFromConduit( | $history = DiffusionPathChange::newFromConduit( | ||||
| $history_results['pathChanges']); | $history_results['pathChanges']); | ||||
| $history = $pager->sliceResults($history); | $history = $pager->sliceResults($history); | ||||
| $show_graph = !strlen($drequest->getPath()); | $show_graph = !strlen($drequest->getPath()); | ||||
| $content = array(); | |||||
| $history_table = id(new DiffusionHistoryTableView()) | $history_table = id(new DiffusionHistoryTableView()) | ||||
| ->setUser($request->getUser()) | ->setUser($request->getUser()) | ||||
| ->setDiffusionRequest($drequest) | ->setDiffusionRequest($drequest) | ||||
| ->setHistory($history); | ->setHistory($history); | ||||
| $history_table->loadRevisions(); | $history_table->loadRevisions(); | ||||
| if ($show_graph) { | if ($show_graph) { | ||||
| $history_table->setParents($history_results['parents']); | $history_table->setParents($history_results['parents']); | ||||
| $history_table->setIsHead(!$pager->getOffset()); | $history_table->setIsHead(!$pager->getOffset()); | ||||
| $history_table->setIsTail(!$pager->getHasMorePages()); | $history_table->setIsTail(!$pager->getHasMorePages()); | ||||
| } | } | ||||
| $history_panel = new PHUIObjectBoxView(); | $history_header = $this->buildHistoryHeader($drequest); | ||||
| $history_panel->setHeaderText(pht('History')); | $history_panel = id(new PHUIObjectBoxView()) | ||||
| $history_panel->setTable($history_table); | ->setHeader($history_header) | ||||
| ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | |||||
| $content[] = $history_panel; | ->setTable($history_table); | ||||
| $header = id(new PHUIHeaderView()) | |||||
| ->setUser($viewer) | |||||
| ->setPolicyObject($repository) | |||||
| ->setHeader($this->renderPathLinks($drequest, $mode = 'history')); | |||||
| $actions = $this->buildActionView($drequest); | |||||
| $properties = $this->buildPropertyView($drequest, $actions); | |||||
| $object_box = id(new PHUIObjectBoxView()) | $header = $this->buildHeader($drequest, $repository); | ||||
| ->setHeader($header) | |||||
| ->addPropertyList($properties); | |||||
| $crumbs = $this->buildCrumbs( | $crumbs = $this->buildCrumbs( | ||||
| array( | array( | ||||
| 'branch' => true, | 'branch' => true, | ||||
| 'path' => true, | 'path' => true, | ||||
| 'view' => 'history', | 'view' => 'history', | ||||
| )); | )); | ||||
| $crumbs->setBorder(true); | |||||
| $pager_box = $this->renderTablePagerBox($pager); | $pager_box = $this->renderTablePagerBox($pager); | ||||
| $view = id(new PHUITwoColumnView()) | |||||
| ->setHeader($header) | |||||
| ->setFooter(array( | |||||
| $history_panel, | |||||
| $pager_box, | |||||
| )); | |||||
| return $this->newPage() | return $this->newPage() | ||||
| ->setTitle( | ->setTitle( | ||||
| array( | array( | ||||
| pht('History'), | pht('History'), | ||||
| $repository->getDisplayName(), | $repository->getDisplayName(), | ||||
| )) | )) | ||||
| ->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
| ->appendChild( | ->appendChild( | ||||
| array( | array( | ||||
| $object_box, | $view, | ||||
| $content, | |||||
| $pager_box, | |||||
| )); | )); | ||||
| } | } | ||||
| private function buildActionView(DiffusionRequest $drequest) { | private function buildHeader(DiffusionRequest $drequest) { | ||||
| $viewer = $this->getRequest()->getUser(); | $viewer = $this->getViewer(); | ||||
| $tag = $this->renderCommitHashTag($drequest); | |||||
| $view = id(new PhabricatorActionListView()) | $header = id(new PHUIHeaderView()) | ||||
| ->setUser($viewer); | ->setUser($viewer) | ||||
| ->setPolicyObject($drequest->getRepository()) | |||||
| ->addTag($tag) | |||||
| ->setHeader($this->renderPathLinks($drequest, $mode = 'history')) | |||||
| ->setHeaderIcon('fa-clock-o'); | |||||
| return $header; | |||||
| } | |||||
| private function buildHistoryHeader(DiffusionRequest $drequest) { | |||||
| $viewer = $this->getViewer(); | |||||
| $browse_uri = $drequest->generateURI( | $browse_uri = $drequest->generateURI( | ||||
| array( | array( | ||||
| 'action' => 'browse', | 'action' => 'browse', | ||||
| )); | )); | ||||
| $view->addAction( | $browse_button = id(new PHUIButtonView()) | ||||
| id(new PhabricatorActionView()) | ->setTag('a') | ||||
| ->setName(pht('Browse Content')) | ->setText(pht('Browse')) | ||||
| ->setHref($browse_uri) | ->setHref($browse_uri) | ||||
| ->setIcon('fa-files-o')); | ->setIcon('fa-files-o'); | ||||
| // TODO: Sometimes we do have a change view, we need to look at the most | // TODO: Sometimes we do have a change view, we need to look at the most | ||||
| // recent history entry to figure it out. | // recent history entry to figure it out. | ||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| if ($request->getBool('copies')) { | if ($request->getBool('copies')) { | ||||
| $branch_name = pht('Hide Copies/Branches'); | $branch_name = pht('Hide Copies/Branches'); | ||||
| $branch_uri = $request->getRequestURI() | $branch_uri = $request->getRequestURI() | ||||
| ->alter('offset', null) | ->alter('offset', null) | ||||
| ->alter('copies', null); | ->alter('copies', null); | ||||
| } else { | } else { | ||||
| $branch_name = pht('Show Copies/Branches'); | $branch_name = pht('Show Copies/Branches'); | ||||
| $branch_uri = $request->getRequestURI() | $branch_uri = $request->getRequestURI() | ||||
| ->alter('offset', null) | ->alter('offset', null) | ||||
| ->alter('copies', true); | ->alter('copies', true); | ||||
| } | } | ||||
| $view->addAction( | $branch_button = id(new PHUIButtonView()) | ||||
| id(new PhabricatorActionView()) | ->setTag('a') | ||||
| ->setName($branch_name) | ->setText($branch_name) | ||||
| ->setIcon('fa-code-fork') | ->setIcon('fa-code-fork') | ||||
| ->setHref($branch_uri)); | ->setHref($branch_uri); | ||||
| return $view; | |||||
| } | |||||
| protected function buildPropertyView( | |||||
| DiffusionRequest $drequest, | |||||
| PhabricatorActionListView $actions) { | |||||
| $viewer = $this->getRequest()->getUser(); | $header = id(new PHUIHeaderView()) | ||||
| ->setHeader(pht('History')) | |||||
| $view = id(new PHUIPropertyListView()) | ->addActionLink($browse_button) | ||||
| ->setUser($viewer) | ->addActionLink($branch_button); | ||||
| ->setActionList($actions); | |||||
| $stable_commit = $drequest->getStableCommit(); | |||||
| $view->addProperty( | |||||
| pht('Commit'), | |||||
| phutil_tag( | |||||
| 'a', | |||||
| array( | |||||
| 'href' => $drequest->generateURI( | |||||
| array( | |||||
| 'action' => 'commit', | |||||
| 'commit' => $stable_commit, | |||||
| )), | |||||
| ), | |||||
| $drequest->getRepository()->formatCommitName($stable_commit))); | |||||
| return $view; | return $header; | ||||
| } | } | ||||
| } | } | ||||