mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 23:01:04 +01:00
Modernize Diffusion "change" view
Summary: - Kicks it out to full width. - More useful header/crumbs/properties/actions (needs some more work). - Works for public repositories. - Fix a bug where the "rX" crumb would lose the branch you're on. Test Plan: See screenshot. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D7063
This commit is contained in:
parent
e7fbfb1eac
commit
b3fa9d0c2f
6 changed files with 108 additions and 19 deletions
|
@ -194,10 +194,14 @@ final class DifferentialChangesetListView extends AphrontView {
|
|||
));
|
||||
}
|
||||
|
||||
$header = null;
|
||||
if ($this->getTitle() !== null) {
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader($this->getTitle());
|
||||
}
|
||||
|
||||
return array(
|
||||
id(new PHUIHeaderView())
|
||||
->setHeader($this->getTitle())
|
||||
->render(),
|
||||
$header,
|
||||
phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
|
|
|
@ -65,7 +65,7 @@ abstract class DiffusionBrowseController extends DiffusionController {
|
|||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setUser($viewer)
|
||||
->setHeader($this->renderPathLinks($drequest))
|
||||
->setHeader($this->renderPathLinks($drequest, 'browse'))
|
||||
->setPolicyObject($drequest->getRepository());
|
||||
|
||||
return $header;
|
||||
|
|
|
@ -2,8 +2,13 @@
|
|||
|
||||
final class DiffusionChangeController extends DiffusionController {
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$drequest = $this->diffusionRequest;
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$content = array();
|
||||
|
||||
|
@ -11,7 +16,8 @@ final class DiffusionChangeController extends DiffusionController {
|
|||
'diffusion.diffquery',
|
||||
array(
|
||||
'commit' => $drequest->getCommit(),
|
||||
'path' => $drequest->getPath()));
|
||||
'path' => $drequest->getPath(),
|
||||
));
|
||||
$drequest->setCommit($data['effectiveCommit']);
|
||||
$raw_changes = ArcanistDiffChange::newFromConduit($data['changes']);
|
||||
$diff = DifferentialDiff::newFromRawChanges($raw_changes);
|
||||
|
@ -31,7 +37,6 @@ final class DiffusionChangeController extends DiffusionController {
|
|||
);
|
||||
|
||||
$changeset_view = new DifferentialChangesetListView();
|
||||
$changeset_view->setTitle(DiffusionView::nameCommit($repository, $commit));
|
||||
$changeset_view->setChangesets($changesets);
|
||||
$changeset_view->setVisibleChangesets($changesets);
|
||||
$changeset_view->setRenderingReferences(
|
||||
|
@ -45,13 +50,13 @@ final class DiffusionChangeController extends DiffusionController {
|
|||
'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->setRenderURI('/diffusion/'.$callsign.'/diff/');
|
||||
$changeset_view->setWhitespace(
|
||||
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
||||
$changeset_view->setUser($this->getRequest()->getUser());
|
||||
|
@ -61,22 +66,94 @@ final class DiffusionChangeController extends DiffusionController {
|
|||
require_celerity_resource('differential-core-view-css');
|
||||
$content[] = $changeset_view->render();
|
||||
|
||||
$nav = $this->buildSideNav('change', true);
|
||||
$nav->appendChild($content);
|
||||
$crumbs = $this->buildCrumbs(
|
||||
array(
|
||||
'branch' => true,
|
||||
'path' => true,
|
||||
'view' => 'change',
|
||||
));
|
||||
$nav->setCrumbs($crumbs);
|
||||
|
||||
$links = $this->renderPathLinks($drequest);
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader($links)
|
||||
->setUser($viewer)
|
||||
->setPolicyObject($drequest->getRepository());
|
||||
$actions = $this->buildActionView($drequest);
|
||||
$properties = $this->buildPropertyView($drequest);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$nav,
|
||||
array(
|
||||
$crumbs,
|
||||
$header,
|
||||
$actions,
|
||||
$properties,
|
||||
$content,
|
||||
),
|
||||
array(
|
||||
'title' => pht('Change'),
|
||||
'device' => true,
|
||||
));
|
||||
}
|
||||
|
||||
private function buildActionView(DiffusionRequest $drequest) {
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$view = id(new PhabricatorActionListView())
|
||||
->setUser($viewer);
|
||||
|
||||
$history_uri = $drequest->generateURI(
|
||||
array(
|
||||
'action' => 'history',
|
||||
));
|
||||
|
||||
$browse_uri = $drequest->generateURI(
|
||||
array(
|
||||
'action' => 'browse',
|
||||
));
|
||||
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('View History'))
|
||||
->setHref($history_uri)
|
||||
->setIcon('history'));
|
||||
|
||||
$history_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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -122,7 +122,12 @@ abstract class DiffusionController extends PhabricatorController {
|
|||
$crumb_list[] = $crumb;
|
||||
return $crumb_list;
|
||||
}
|
||||
$crumb->setHref("/diffusion/{$callsign}/");
|
||||
$crumb->setHref(
|
||||
$drequest->generateURI(
|
||||
array(
|
||||
'action' => 'branch',
|
||||
'path' => '/',
|
||||
)));
|
||||
$crumb_list[] = $crumb;
|
||||
|
||||
$raw_commit = $drequest->getRawCommit();
|
||||
|
@ -187,9 +192,7 @@ abstract class DiffusionController extends PhabricatorController {
|
|||
break;
|
||||
case 'change':
|
||||
$view_name = pht('Change');
|
||||
$crumb_list[] = $crumb->setName(
|
||||
hsprintf('%s (%s)', $path, $commit_link));
|
||||
return $crumb_list;
|
||||
break;
|
||||
}
|
||||
|
||||
$uri_params = array(
|
||||
|
@ -199,7 +202,7 @@ abstract class DiffusionController extends PhabricatorController {
|
|||
$crumb = id(new PhabricatorCrumbView())
|
||||
->setName($view_name);
|
||||
|
||||
if ($view == 'browse') {
|
||||
if ($view == 'browse' || $view == 'change') {
|
||||
$crumb_list[] = $crumb;
|
||||
return $crumb_list;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
final class DiffusionDiffController extends DiffusionController {
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$data = $data + array(
|
||||
'dblob' => $this->getRequest()->getStr('ref'),
|
||||
|
|
|
@ -371,7 +371,8 @@ abstract class DiffusionRequest {
|
|||
* and formatting to the URI. Parameters are:
|
||||
*
|
||||
* - `action` One of `history`, `browse`, `change`, `lastmodified`,
|
||||
* `branch` or `revision-ref`. The action specified by the URI.
|
||||
* `branch`, `tags`, `branches`, or `revision-ref`. The action specified
|
||||
* by the URI.
|
||||
* - `callsign` Repository callsign.
|
||||
* - `branch` Optional if action is not `branch`, branch name.
|
||||
* - `path` Optional, path to file.
|
||||
|
|
Loading…
Reference in a new issue