2017-06-18 09:53:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionGraphController extends DiffusionController {
|
|
|
|
|
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$response = $this->loadDiffusionContext();
|
|
|
|
if ($response) {
|
|
|
|
return $response;
|
|
|
|
}
|
2017-08-16 21:07:14 +02:00
|
|
|
require_celerity_resource('diffusion-css');
|
2017-06-18 09:53:43 +02:00
|
|
|
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
|
|
|
$pager = id(new PHUIPagerView())
|
|
|
|
->readFromRequest($request);
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
'commit' => $drequest->getCommit(),
|
|
|
|
'path' => $drequest->getPath(),
|
|
|
|
'offset' => $pager->getOffset(),
|
|
|
|
'limit' => $pager->getPageSize() + 1,
|
|
|
|
);
|
|
|
|
|
|
|
|
$history_results = $this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.historyquery',
|
|
|
|
$params);
|
|
|
|
$history = DiffusionPathChange::newFromConduit(
|
|
|
|
$history_results['pathChanges']);
|
|
|
|
|
|
|
|
$history = $pager->sliceResults($history);
|
|
|
|
|
|
|
|
$graph = id(new DiffusionHistoryTableView())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->setDiffusionRequest($drequest)
|
|
|
|
->setHistory($history);
|
|
|
|
|
|
|
|
$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);
|
|
|
|
|
|
|
|
$crumbs = $this->buildCrumbs(
|
|
|
|
array(
|
|
|
|
'branch' => true,
|
|
|
|
'path' => true,
|
|
|
|
'view' => 'graph',
|
|
|
|
));
|
|
|
|
$crumbs->setBorder(true);
|
|
|
|
|
|
|
|
$title = array(
|
|
|
|
pht('Graph'),
|
|
|
|
$repository->getDisplayName(),
|
|
|
|
);
|
|
|
|
|
|
|
|
$graph_view = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('History Graph'))
|
|
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
|
|
|
->setTable($graph)
|
Mobile layouts for Diffusion
Summary: Implements a new mobile view thats more fullscreen, not boxed, so more space. Fixes issues with mobile tables when scrolling overflowed content.
Test Plan: Test home, branch, tags, code, file browse, graph, compare, history, readme, open revisions, owners.
Reviewers: epriestley
Reviewed By: epriestley
Spies: Korvin
Differential Revision: https://secure.phabricator.com/D18505
2017-08-30 21:00:07 +02:00
|
|
|
->addClass('diffusion-mobile-view')
|
2017-06-18 09:53:43 +02:00
|
|
|
->setPager($pager);
|
|
|
|
|
2017-07-05 23:09:12 +02:00
|
|
|
$tabs = $this->buildTabsView('graph');
|
|
|
|
|
2017-06-18 09:53:43 +02:00
|
|
|
$view = id(new PHUITwoColumnView())
|
|
|
|
->setHeader($header)
|
2017-07-05 23:09:12 +02:00
|
|
|
->setTabs($tabs)
|
2017-06-18 09:53:43 +02:00
|
|
|
->setFooter($graph_view);
|
|
|
|
|
|
|
|
return $this->newPage()
|
|
|
|
->setTitle($title)
|
|
|
|
->setCrumbs($crumbs)
|
|
|
|
->appendChild($view);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildHeader(DiffusionRequest $drequest) {
|
|
|
|
$viewer = $this->getViewer();
|
2017-08-16 21:07:14 +02:00
|
|
|
$repository = $drequest->getRepository();
|
2017-06-18 09:53:43 +02:00
|
|
|
|
2017-07-05 23:09:12 +02:00
|
|
|
$no_path = !strlen($drequest->getPath());
|
|
|
|
if ($no_path) {
|
|
|
|
$header_text = pht('Graph');
|
|
|
|
} else {
|
|
|
|
$header_text = $this->renderPathLinks($drequest, $mode = 'history');
|
|
|
|
}
|
2017-06-18 09:53:43 +02:00
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setUser($viewer)
|
2017-07-05 23:09:12 +02:00
|
|
|
->setHeader($header_text)
|
|
|
|
->setHeaderIcon('fa-code-fork');
|
2017-06-18 09:53:43 +02:00
|
|
|
|
2017-08-16 21:07:14 +02:00
|
|
|
if (!$repository->isSVN()) {
|
|
|
|
$branch_tag = $this->renderBranchTag($drequest);
|
|
|
|
$header->addTag($branch_tag);
|
|
|
|
}
|
|
|
|
|
2017-06-18 09:53:43 +02:00
|
|
|
return $header;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|