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;
|
|
|
|
}
|
|
|
|
|
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();
|
2013-09-23 21:55:23 +02:00
|
|
|
$viewer = $request->getUser();
|
|
|
|
$repository = $drequest->getRepository();
|
2011-04-01 03:46:53 +02:00
|
|
|
|
|
|
|
$page_size = $request->getInt('pagesize', 100);
|
2013-09-23 21:55:23 +02:00
|
|
|
$offset = $request->getInt('offset', 0);
|
2011-03-09 02:31:44 +01:00
|
|
|
|
2013-05-20 21:45:34 +02:00
|
|
|
$params = array(
|
|
|
|
'commit' => $drequest->getCommit(),
|
|
|
|
'path' => $drequest->getPath(),
|
|
|
|
'offset' => $offset,
|
|
|
|
'limit' => $page_size + 1);
|
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
|
|
|
|
2011-04-01 03:46:53 +02:00
|
|
|
$pager = new AphrontPagerView();
|
|
|
|
$pager->setPageSize($page_size);
|
|
|
|
$pager->setOffset($offset);
|
2013-09-23 21:55:23 +02:00
|
|
|
$history = $pager->sliceResults($history);
|
|
|
|
|
|
|
|
$pager->setURI($request->getRequestURI(), 'offset');
|
2011-04-01 03:46:53 +02:00
|
|
|
|
2013-05-20 21:45:34 +02:00
|
|
|
$show_graph = !strlen($drequest->getPath());
|
2011-03-09 02:31:44 +01:00
|
|
|
$content = array();
|
|
|
|
|
|
|
|
$history_table = new DiffusionHistoryTableView();
|
2012-12-21 00:04:20 +01:00
|
|
|
$history_table->setUser($request->getUser());
|
2011-03-09 02:31:44 +01:00
|
|
|
$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) {
|
2013-05-20 21:45:34 +02:00
|
|
|
$history_table->setParents($history_results['parents']);
|
2012-03-24 01:11:15 +01:00
|
|
|
$history_table->setIsHead($offset == 0);
|
|
|
|
}
|
|
|
|
|
2011-03-09 02:31:44 +01:00
|
|
|
$history_panel = new AphrontPanelView();
|
|
|
|
$history_panel->appendChild($history_table);
|
2011-04-01 03:46:53 +02:00
|
|
|
$history_panel->appendChild($pager);
|
2013-01-15 01:40:04 +01:00
|
|
|
$history_panel->setNoBackground();
|
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);
|
|
|
|
$properties = $this->buildPropertyView($drequest);
|
2011-03-13 01:17:34 +01:00
|
|
|
|
2013-09-29 00:55:38 +02:00
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
Provide more structure to PHUIObjectBoxView
Summary:
Three changes here.
- Add `setActionList()`, and use that to set the action list.
- Add `setPropertyList()`, and use that to set the property list.
These will let us add some apropriate CSS so we can fix the border issue, and get rid of a bunch of goofy `.x + .y` selectors.
- Replace `addContent()` with `appendChild()`.
This is just a consistency thing; `AphrontView` already provides `appendChild()`, and `addContent()` did the same thing.
Test Plan:
- Viewed "All Config".
- Viewed a countdown.
- Viewed a revision (add comment, change list, table of contents, comment, local commits, open revisions affecting these files, update history).
- Viewed Diffusion (browse, change, history, repository, lint).
- Viewed Drydock (resource, lease).
- Viewed Files.
- Viewed Herald.
- Viewed Legalpad.
- Viewed macro (edit, edit audio, view).
- Viewed Maniphest.
- Viewed Applications.
- Viewed Paste.
- Viewed People.
- Viewed Phulux.
- Viewed Pholio.
- Viewed Phame (blog, post).
- Viewed Phortune (account, product).
- Viewed Ponder (questions, answers, comments).
- Viewed Releeph.
- Viewed Projects.
- Viewed Slowvote.
NOTE: Images in Files aren't on a black background anymore -- I assume that's on purpose?
NOTE: Some jankiness in Phortune, I'll clean that up when I get back to it. Not related to this diff.
Reviewers: chad
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D7174
2013-09-30 18:36:04 +02:00
|
|
|
->setActionList($actions)
|
|
|
|
->setPropertyList($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
|
|
|
|
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(
|
2013-09-23 21:55:23 +02:00
|
|
|
array(
|
|
|
|
$crumbs,
|
2013-09-29 00:55:38 +02:00
|
|
|
$object_box,
|
2013-09-23 21:55:23 +02:00
|
|
|
$content,
|
|
|
|
),
|
2011-03-09 02:31:44 +01:00
|
|
|
array(
|
2013-05-11 17:23:19 +02:00
|
|
|
'device' => true,
|
2013-04-23 05:11:52 +02:00
|
|
|
'title' => array(
|
|
|
|
pht('History'),
|
|
|
|
pht('%s Repository', $drequest->getRepository()->getCallsign()),
|
|
|
|
),
|
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)
|
|
|
|
->setIcon('file'));
|
|
|
|
|
|
|
|
// 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_icon = 'fork-grey';
|
|
|
|
$branch_uri = $request->getRequestURI()
|
|
|
|
->alter('offset', null)
|
|
|
|
->alter('copies', null);
|
|
|
|
} else {
|
|
|
|
$branch_name = pht('Show Copies/Branches');
|
|
|
|
$branch_icon = 'fork';
|
|
|
|
$branch_uri = $request->getRequestURI()
|
|
|
|
->alter('offset', null)
|
|
|
|
->alter('copies', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName($branch_name)
|
|
|
|
->setIcon($branch_icon)
|
|
|
|
->setHref($branch_uri));
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function buildPropertyView(DiffusionRequest $drequest) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorPropertyListView())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$stable_commit = $drequest->getStableCommitName();
|
|
|
|
$callsign = $drequest->getRepository()->getCallsign();
|
|
|
|
|
|
|
|
$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
|
|
|
}
|