mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-12 00:26:13 +01:00
d0898116d8
Summary: Fixes T12840. This adds a parallel "graph" button next to history on home and on the history list page. I'll think more about better placement of how to get to this page with the upcoming redesign that's still sitting in Pholio. Test Plan: View History, View Graph, Try pager, go to a file, click view history, see no graph button. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T12840 Differential Revision: https://secure.phabricator.com/D18131
107 lines
2.6 KiB
PHP
107 lines
2.6 KiB
PHP
<?php
|
|
|
|
final class DiffusionHistoryController extends DiffusionController {
|
|
|
|
public function shouldAllowPublic() {
|
|
return true;
|
|
}
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$response = $this->loadDiffusionContext();
|
|
if ($response) {
|
|
return $response;
|
|
}
|
|
|
|
$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);
|
|
|
|
$history_list = id(new DiffusionHistoryListView())
|
|
->setViewer($viewer)
|
|
->setDiffusionRequest($drequest)
|
|
->setHistory($history);
|
|
|
|
$history_list->loadRevisions();
|
|
$header = $this->buildHeader($drequest);
|
|
|
|
$crumbs = $this->buildCrumbs(
|
|
array(
|
|
'branch' => true,
|
|
'path' => true,
|
|
'view' => 'history',
|
|
));
|
|
$crumbs->setBorder(true);
|
|
|
|
$title = array(
|
|
pht('History'),
|
|
$repository->getDisplayName(),
|
|
);
|
|
|
|
$pager = id(new PHUIBoxView())
|
|
->addClass('mlb')
|
|
->appendChild($pager);
|
|
|
|
$view = id(new PHUITwoColumnView())
|
|
->setHeader($header)
|
|
->setFooter(array(
|
|
$history_list,
|
|
$pager,
|
|
));
|
|
|
|
return $this->newPage()
|
|
->setTitle($title)
|
|
->setCrumbs($crumbs)
|
|
->appendChild($view)
|
|
->addClass('diffusion-history-view');
|
|
}
|
|
|
|
private function buildHeader(DiffusionRequest $drequest) {
|
|
$viewer = $this->getViewer();
|
|
|
|
$tag = $this->renderCommitHashTag($drequest);
|
|
$show_graph = !strlen($drequest->getPath());
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
->setUser($viewer)
|
|
->setPolicyObject($drequest->getRepository())
|
|
->addTag($tag)
|
|
->setHeader($this->renderPathLinks($drequest, $mode = 'history'))
|
|
->setHeaderIcon('fa-clock-o');
|
|
|
|
if ($show_graph) {
|
|
$graph_uri = $drequest->generateURI(
|
|
array(
|
|
'action' => 'graph',
|
|
));
|
|
|
|
$graph_button = id(new PHUIButtonView())
|
|
->setTag('a')
|
|
->setText(pht('Graph'))
|
|
->setHref($graph_uri)
|
|
->setIcon('fa-code-fork');
|
|
$header->addActionLink($graph_button);
|
|
}
|
|
|
|
return $header;
|
|
|
|
}
|
|
|
|
}
|