2011-03-09 02:31:44 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class DiffusionHistoryController extends DiffusionController {
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2013-09-23 21:55:23 +02:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-05 17:13:05 +01:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$response = $this->loadDiffusionContext();
|
|
|
|
if ($response) {
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
2013-09-23 21:55:23 +02:00
|
|
|
$repository = $drequest->getRepository();
|
2011-04-01 03:46:53 +02:00
|
|
|
|
2016-01-05 17:13:05 +01:00
|
|
|
$pager = id(new PHUIPagerView())
|
|
|
|
->readFromRequest($request);
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2013-05-20 21:45:34 +02:00
|
|
|
$params = array(
|
|
|
|
'commit' => $drequest->getCommit(),
|
|
|
|
'path' => $drequest->getPath(),
|
2016-01-05 17:13:05 +01:00
|
|
|
'offset' => $pager->getOffset(),
|
|
|
|
'limit' => $pager->getPageSize() + 1,
|
2014-10-07 15:01:04 +02:00
|
|
|
);
|
2013-09-23 21:55:23 +02:00
|
|
|
|
2011-05-20 21:35:26 +02:00
|
|
|
if (!$request->getBool('copies')) {
|
2013-05-20 21:45:34 +02:00
|
|
|
$params['needDirectChanges'] = true;
|
|
|
|
$params['needChildChanges'] = true;
|
2012-03-24 01:11:15 +01:00
|
|
|
}
|
|
|
|
|
2013-05-20 21:45:34 +02:00
|
|
|
$history_results = $this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.historyquery',
|
|
|
|
$params);
|
|
|
|
$history = DiffusionPathChange::newFromConduit(
|
|
|
|
$history_results['pathChanges']);
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2013-09-23 21:55:23 +02:00
|
|
|
$history = $pager->sliceResults($history);
|
|
|
|
|
2013-05-20 21:45:34 +02:00
|
|
|
$show_graph = !strlen($drequest->getPath());
|
2015-09-11 04:28:49 +02:00
|
|
|
$history_table = id(new DiffusionHistoryTableView())
|
|
|
|
->setUser($request->getUser())
|
|
|
|
->setDiffusionRequest($drequest)
|
|
|
|
->setHistory($history);
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2015-09-11 04:28:49 +02:00
|
|
|
$history_table->loadRevisions();
|
2012-03-23 23:32:26 +01:00
|
|
|
|
2012-03-24 01:11:15 +01:00
|
|
|
if ($show_graph) {
|
2013-05-20 21:45:34 +02:00
|
|
|
$history_table->setParents($history_results['parents']);
|
2016-01-05 17:13:05 +01:00
|
|
|
$history_table->setIsHead(!$pager->getOffset());
|
2016-01-08 20:41:49 +01:00
|
|
|
$history_table->setIsTail(!$pager->getHasMorePages());
|
2012-03-24 01:11:15 +01:00
|
|
|
}
|
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
$history_header = $this->buildHistoryHeader($drequest);
|
|
|
|
$history_panel = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($history_header)
|
|
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
2017-04-21 20:22:06 +02:00
|
|
|
->setTable($history_table)
|
|
|
|
->setPager($pager);
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2017-02-17 11:10:15 +01:00
|
|
|
$header = $this->buildHeader($drequest);
|
2013-09-29 00:55:38 +02:00
|
|
|
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
$crumbs = $this->buildCrumbs(
|
|
|
|
array(
|
|
|
|
'branch' => true,
|
|
|
|
'path' => true,
|
|
|
|
'view' => 'history',
|
|
|
|
));
|
2016-03-17 20:01:22 +01:00
|
|
|
$crumbs->setBorder(true);
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
$view = id(new PHUITwoColumnView())
|
|
|
|
->setHeader($header)
|
|
|
|
->setFooter(array(
|
|
|
|
$history_panel,
|
|
|
|
));
|
|
|
|
|
2016-01-05 17:13:05 +01:00
|
|
|
return $this->newPage()
|
|
|
|
->setTitle(
|
|
|
|
array(
|
2013-04-23 05:11:52 +02:00
|
|
|
pht('History'),
|
2016-01-05 17:13:05 +01:00
|
|
|
$repository->getDisplayName(),
|
|
|
|
))
|
|
|
|
->setCrumbs($crumbs)
|
|
|
|
->appendChild(
|
|
|
|
array(
|
2016-03-17 20:01:22 +01:00
|
|
|
$view,
|
2016-01-05 17:13:05 +01:00
|
|
|
));
|
2011-03-09 02:31:44 +01:00
|
|
|
}
|
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
private function buildHeader(DiffusionRequest $drequest) {
|
|
|
|
$viewer = $this->getViewer();
|
2013-09-23 21:55:23 +02:00
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
$tag = $this->renderCommitHashTag($drequest);
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->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();
|
2013-09-23 21:55:23 +02:00
|
|
|
|
|
|
|
$browse_uri = $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'browse',
|
|
|
|
));
|
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
$browse_button = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setText(pht('Browse'))
|
|
|
|
->setHref($browse_uri)
|
|
|
|
->setIcon('fa-files-o');
|
2013-09-23 21:55:23 +02:00
|
|
|
|
|
|
|
// 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_uri = $request->getRequestURI()
|
|
|
|
->alter('offset', null)
|
|
|
|
->alter('copies', null);
|
|
|
|
} else {
|
|
|
|
$branch_name = pht('Show Copies/Branches');
|
|
|
|
$branch_uri = $request->getRequestURI()
|
|
|
|
->alter('offset', null)
|
|
|
|
->alter('copies', true);
|
|
|
|
}
|
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
$branch_button = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setText($branch_name)
|
|
|
|
->setIcon('fa-code-fork')
|
|
|
|
->setHref($branch_uri);
|
2013-09-23 21:55:23 +02:00
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader(pht('History'))
|
|
|
|
->addActionLink($browse_button)
|
|
|
|
->addActionLink($branch_button);
|
2013-09-23 21:55:23 +02:00
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
return $header;
|
2013-09-23 21:55:23 +02:00
|
|
|
}
|
|
|
|
|
2011-03-09 02:31:44 +01:00
|
|
|
}
|