Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionGraphController.php
- This file was copied from src/applications/diffusion/controller/DiffusionHistoryController.php.
<?php | <?php | ||||
final class DiffusionHistoryController extends DiffusionController { | final class DiffusionGraphController extends DiffusionController { | ||||
public function shouldAllowPublic() { | public function shouldAllowPublic() { | ||||
return true; | return true; | ||||
} | } | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$response = $this->loadDiffusionContext(); | $response = $this->loadDiffusionContext(); | ||||
if ($response) { | if ($response) { | ||||
Show All 17 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$history_results = $this->callConduitWithDiffusionRequest( | $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); | ||||
$history_list = id(new DiffusionHistoryListView()) | $graph = id(new DiffusionHistoryTableView()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->setDiffusionRequest($drequest) | ->setDiffusionRequest($drequest) | ||||
->setHistory($history); | ->setHistory($history); | ||||
$history_list->loadRevisions(); | $graph->loadRevisions(); | ||||
$show_graph = !strlen($drequest->getPath()); | |||||
if ($show_graph) { | |||||
$graph->setParents($history_results['parents']); | |||||
$graph->setIsHead(!$pager->getOffset()); | |||||
$graph->setIsTail(!$pager->getHasMorePages()); | |||||
} | |||||
$header = $this->buildHeader($drequest); | $header = $this->buildHeader($drequest); | ||||
$crumbs = $this->buildCrumbs( | $crumbs = $this->buildCrumbs( | ||||
array( | array( | ||||
'branch' => true, | 'branch' => true, | ||||
'path' => true, | 'path' => true, | ||||
'view' => 'history', | 'view' => 'graph', | ||||
)); | )); | ||||
$crumbs->setBorder(true); | $crumbs->setBorder(true); | ||||
$title = array( | $title = array( | ||||
pht('History'), | pht('Graph'), | ||||
$repository->getDisplayName(), | $repository->getDisplayName(), | ||||
); | ); | ||||
$pager = id(new PHUIBoxView()) | $graph_view = id(new PHUIObjectBoxView()) | ||||
->addClass('mlb') | ->setHeaderText(pht('History Graph')) | ||||
->appendChild($pager); | ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ||||
->setTable($graph) | |||||
->setPager($pager); | |||||
$view = id(new PHUITwoColumnView()) | $view = id(new PHUITwoColumnView()) | ||||
->setHeader($header) | ->setHeader($header) | ||||
->setFooter(array( | ->setFooter($graph_view); | ||||
$history_list, | |||||
$pager, | |||||
)); | |||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($title) | ->setTitle($title) | ||||
->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
->appendChild($view) | ->appendChild($view); | ||||
->addClass('diffusion-history-view'); | |||||
} | } | ||||
private function buildHeader(DiffusionRequest $drequest) { | private function buildHeader(DiffusionRequest $drequest) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$tag = $this->renderCommitHashTag($drequest); | $tag = $this->renderCommitHashTag($drequest); | ||||
$browse_uri = $drequest->generateURI( | $history_uri = $drequest->generateURI( | ||||
array( | array( | ||||
'action' => 'browse', | 'action' => 'history', | ||||
)); | )); | ||||
$browse_button = id(new PHUIButtonView()) | $history_button = id(new PHUIButtonView()) | ||||
->setTag('a') | ->setTag('a') | ||||
->setText(pht('Browse')) | ->setText(pht('History')) | ||||
->setHref($browse_uri) | ->setHref($history_uri) | ||||
->setIcon('fa-code'); | ->setIcon('fa-history'); | ||||
$header = id(new PHUIHeaderView()) | $header = id(new PHUIHeaderView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setPolicyObject($drequest->getRepository()) | ->setPolicyObject($drequest->getRepository()) | ||||
->addTag($tag) | ->addTag($tag) | ||||
->setHeader($this->renderPathLinks($drequest, $mode = 'history')) | ->setHeader($this->renderPathLinks($drequest, $mode = 'history')) | ||||
->setHeaderIcon('fa-clock-o') | ->setHeaderIcon('fa-code-fork') | ||||
->addActionLink($browse_button); | ->addActionLink($history_button); | ||||
return $header; | return $header; | ||||
} | } | ||||
} | } |