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());
|
2011-03-09 02:31:44 +01:00
|
|
|
$content = array();
|
|
|
|
|
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());
|
2012-03-24 01:11:15 +01:00
|
|
|
}
|
|
|
|
|
2015-03-07 00:32:12 +01:00
|
|
|
$history_panel = new PHUIObjectBoxView();
|
|
|
|
$history_panel->setHeaderText(pht('History'));
|
2015-05-20 08:14:22 +02:00
|
|
|
$history_panel->setTable($history_table);
|
2011-03-09 02:31:44 +01:00
|
|
|
|
|
|
|
$content[] = $history_panel;
|
|
|
|
|
2013-09-23 21:55:23 +02:00
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setPolicyObject($repository)
|
|
|
|
->setHeader($this->renderPathLinks($drequest, $mode = 'history'));
|
|
|
|
|
|
|
|
$actions = $this->buildActionView($drequest);
|
2013-10-11 16:53:56 +02:00
|
|
|
$properties = $this->buildPropertyView($drequest, $actions);
|
2011-03-13 01:17:34 +01:00
|
|
|
|
2013-09-29 00:55:38 +02:00
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
2013-10-11 16:53:56 +02:00
|
|
|
->addPropertyList($properties);
|
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',
|
|
|
|
));
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2016-01-05 17:13:05 +01:00
|
|
|
$pager_box = $this->renderTablePagerBox($pager);
|
2015-09-11 17:59:56 +02:00
|
|
|
|
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(
|
|
|
|
$object_box,
|
|
|
|
$content,
|
|
|
|
$pager_box,
|
|
|
|
));
|
2011-03-09 02:31:44 +01:00
|
|
|
}
|
|
|
|
|
2013-09-23 21:55:23 +02:00
|
|
|
private function buildActionView(DiffusionRequest $drequest) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$browse_uri = $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'browse',
|
|
|
|
));
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Browse Content'))
|
|
|
|
->setHref($browse_uri)
|
2014-05-13 16:45:39 +02:00
|
|
|
->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);
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName($branch_name)
|
2014-06-16 21:26:52 +02:00
|
|
|
->setIcon('fa-code-fork')
|
2013-09-23 21:55:23 +02:00
|
|
|
->setHref($branch_uri));
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
protected function buildPropertyView(
|
|
|
|
DiffusionRequest $drequest,
|
|
|
|
PhabricatorActionListView $actions) {
|
|
|
|
|
2013-09-23 21:55:23 +02:00
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$view = id(new PHUIPropertyListView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setActionList($actions);
|
2013-09-23 21:55:23 +02:00
|
|
|
|
2014-05-13 22:53:06 +02:00
|
|
|
$stable_commit = $drequest->getStableCommit();
|
2013-09-23 21:55:23 +02:00
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Commit'),
|
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'commit',
|
|
|
|
'commit' => $stable_commit,
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
$drequest->getRepository()->formatCommitName($stable_commit)));
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2011-03-09 02:31:44 +01:00
|
|
|
}
|