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
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$drequest = $this->diffusionRequest;
|
2011-04-01 03:46:53 +02:00
|
|
|
$request = $this->getRequest();
|
|
|
|
|
|
|
|
$page_size = $request->getInt('pagesize', 100);
|
|
|
|
$offset = $request->getInt('page', 0);
|
2011-03-09 02:31:44 +01:00
|
|
|
|
|
|
|
$history_query = DiffusionHistoryQuery::newFromDiffusionRequest(
|
|
|
|
$drequest);
|
2011-04-01 03:46:53 +02:00
|
|
|
$history_query->setOffset($offset);
|
|
|
|
$history_query->setLimit($page_size + 1);
|
2011-04-07 02:17:47 +02:00
|
|
|
|
2011-05-20 21:35:26 +02:00
|
|
|
if (!$request->getBool('copies')) {
|
2011-04-07 02:17:47 +02:00
|
|
|
$history_query->needDirectChanges(true);
|
2011-05-20 19:23:43 +02:00
|
|
|
$history_query->needChildChanges(true);
|
2011-04-07 02:17:47 +02:00
|
|
|
}
|
|
|
|
|
2012-03-24 01:11:15 +01:00
|
|
|
$show_graph = !strlen($drequest->getPath());
|
|
|
|
if ($show_graph) {
|
|
|
|
$history_query->needParents(true);
|
|
|
|
}
|
|
|
|
|
2011-03-09 02:31:44 +01:00
|
|
|
$history = $history_query->loadHistory();
|
|
|
|
|
2011-04-01 03:46:53 +02:00
|
|
|
$pager = new AphrontPagerView();
|
|
|
|
$pager->setPageSize($page_size);
|
|
|
|
$pager->setOffset($offset);
|
|
|
|
if (count($history) == $page_size + 1) {
|
|
|
|
array_pop($history);
|
|
|
|
$pager->setHasMorePages(true);
|
|
|
|
} else {
|
|
|
|
$pager->setHasMorePages(false);
|
|
|
|
}
|
|
|
|
$pager->setURI($request->getRequestURI(), 'page');
|
|
|
|
|
2011-03-09 02:31:44 +01:00
|
|
|
$content = array();
|
|
|
|
|
2011-05-20 21:35:26 +02:00
|
|
|
if ($request->getBool('copies')) {
|
2011-04-07 02:17:47 +02:00
|
|
|
$button_title = 'Hide Copies/Branches';
|
2012-01-16 23:41:07 +01:00
|
|
|
$copies_new = null;
|
2011-04-07 02:17:47 +02:00
|
|
|
} else {
|
|
|
|
$button_title = 'Show Copies/Branches';
|
2012-01-16 23:41:07 +01:00
|
|
|
$copies_new = true;
|
2011-04-07 02:17:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$button = phutil_render_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'class' => 'button small grey',
|
2012-01-16 23:41:07 +01:00
|
|
|
'href' => $request->getRequestURI()->alter('copies', $copies_new),
|
2011-04-07 02:17:47 +02:00
|
|
|
),
|
|
|
|
phutil_escape_html($button_title));
|
|
|
|
|
2011-03-09 02:31:44 +01:00
|
|
|
$history_table = new DiffusionHistoryTableView();
|
|
|
|
$history_table->setDiffusionRequest($drequest);
|
|
|
|
$history_table->setHistory($history);
|
2012-06-23 01:52:08 +02:00
|
|
|
$history_table->loadRevisions();
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2012-03-23 23:32:26 +01:00
|
|
|
$phids = $history_table->getRequiredHandlePHIDs();
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2012-03-23 23:32:26 +01:00
|
|
|
$history_table->setHandles($handles);
|
|
|
|
|
2012-03-24 01:11:15 +01:00
|
|
|
if ($show_graph) {
|
|
|
|
$history_table->setParents($history_query->getParents());
|
|
|
|
$history_table->setIsHead($offset == 0);
|
|
|
|
}
|
|
|
|
|
2011-03-09 02:31:44 +01:00
|
|
|
$history_panel = new AphrontPanelView();
|
2011-04-07 02:17:47 +02:00
|
|
|
$history_panel->setHeader('History');
|
|
|
|
$history_panel->addButton($button);
|
2011-03-09 02:31:44 +01:00
|
|
|
$history_panel->appendChild($history_table);
|
2011-04-01 03:46:53 +02:00
|
|
|
$history_panel->appendChild($pager);
|
2011-03-09 02:31:44 +01:00
|
|
|
|
|
|
|
$content[] = $history_panel;
|
|
|
|
|
2011-03-13 01:17:34 +01:00
|
|
|
// TODO: Sometimes we do have a change view, we need to look at the most
|
|
|
|
// recent history entry to figure it out.
|
|
|
|
|
|
|
|
$nav = $this->buildSideNav('history', false);
|
|
|
|
$nav->appendChild($content);
|
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',
|
|
|
|
));
|
|
|
|
$nav->setCrumbs($crumbs);
|
2011-03-09 02:31:44 +01: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
|
|
|
return $this->buildApplicationPage(
|
2011-03-13 01:17:34 +01:00
|
|
|
$nav,
|
2011-03-09 02:31:44 +01:00
|
|
|
array(
|
|
|
|
'title' => 'history',
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|