mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 11:22:40 +01:00
b592630d72
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
157 lines
4.2 KiB
PHP
157 lines
4.2 KiB
PHP
<?php
|
|
|
|
final class DiffusionChangeController extends DiffusionController {
|
|
|
|
public function shouldAllowPublic() {
|
|
return true;
|
|
}
|
|
|
|
public function processRequest() {
|
|
$drequest = $this->diffusionRequest;
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
$content = array();
|
|
|
|
$data = $this->callConduitWithDiffusionRequest(
|
|
'diffusion.diffquery',
|
|
array(
|
|
'commit' => $drequest->getCommit(),
|
|
'path' => $drequest->getPath(),
|
|
));
|
|
$drequest->setCommit($data['effectiveCommit']);
|
|
$raw_changes = ArcanistDiffChange::newFromConduit($data['changes']);
|
|
$diff = DifferentialDiff::newFromRawChanges($raw_changes);
|
|
$changesets = $diff->getChangesets();
|
|
$changeset = reset($changesets);
|
|
|
|
if (!$changeset) {
|
|
// TODO: Refine this.
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$repository = $drequest->getRepository();
|
|
$callsign = $repository->getCallsign();
|
|
$commit = $drequest->getRawCommit();
|
|
$changesets = array(
|
|
0 => $changeset,
|
|
);
|
|
|
|
$changeset_view = new DifferentialChangesetListView();
|
|
$changeset_view->setChangesets($changesets);
|
|
$changeset_view->setVisibleChangesets($changesets);
|
|
$changeset_view->setRenderingReferences(
|
|
array(
|
|
0 => $drequest->generateURI(array('action' => 'rendering-ref'))
|
|
));
|
|
|
|
$raw_params = array(
|
|
'action' => 'browse',
|
|
'params' => array(
|
|
'view' => 'raw',
|
|
),
|
|
);
|
|
|
|
$right_uri = $drequest->generateURI($raw_params);
|
|
$raw_params['params']['before'] = $drequest->getRawCommit();
|
|
$left_uri = $drequest->generateURI($raw_params);
|
|
$changeset_view->setRawFileURIs($left_uri, $right_uri);
|
|
|
|
$changeset_view->setRenderURI('/diffusion/'.$callsign.'/diff/');
|
|
$changeset_view->setWhitespace(
|
|
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
|
$changeset_view->setUser($this->getRequest()->getUser());
|
|
|
|
// TODO: This is pretty awkward, unify the CSS between Diffusion and
|
|
// Differential better.
|
|
require_celerity_resource('differential-core-view-css');
|
|
$content[] = $changeset_view->render();
|
|
|
|
$crumbs = $this->buildCrumbs(
|
|
array(
|
|
'branch' => true,
|
|
'path' => true,
|
|
'view' => 'change',
|
|
));
|
|
|
|
$links = $this->renderPathLinks($drequest, $mode = 'browse');
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
->setHeader($links)
|
|
->setUser($viewer)
|
|
->setPolicyObject($drequest->getRepository());
|
|
$actions = $this->buildActionView($drequest);
|
|
$properties = $this->buildPropertyView($drequest);
|
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
->setHeader($header)
|
|
->setActionList($actions)
|
|
->setPropertyList($properties);
|
|
|
|
return $this->buildApplicationPage(
|
|
array(
|
|
$crumbs,
|
|
$object_box,
|
|
$content,
|
|
),
|
|
array(
|
|
'title' => pht('Change'),
|
|
));
|
|
}
|
|
|
|
private function buildActionView(DiffusionRequest $drequest) {
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
->setUser($viewer);
|
|
|
|
$history_uri = $drequest->generateURI(
|
|
array(
|
|
'action' => 'history',
|
|
));
|
|
|
|
$view->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setName(pht('View History'))
|
|
->setHref($history_uri)
|
|
->setIcon('history'));
|
|
|
|
$browse_uri = $drequest->generateURI(
|
|
array(
|
|
'action' => 'browse',
|
|
));
|
|
|
|
$view->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setName(pht('Browse Content'))
|
|
->setHref($browse_uri)
|
|
->setIcon('file'));
|
|
|
|
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;
|
|
}
|
|
|
|
}
|