1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-30 02:32:42 +01:00

Modernize Diffusion "history" view

Summary: Fixes T903. Knock out the side nav, make it policy-aware, other minor cleanup.

Test Plan: See below.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T903

Differential Revision: https://secure.phabricator.com/D7064
This commit is contained in:
epriestley 2013-09-23 12:55:23 -07:00
parent b3fa9d0c2f
commit 0271b051ae
4 changed files with 103 additions and 44 deletions

View file

@ -65,7 +65,7 @@ abstract class DiffusionBrowseController extends DiffusionController {
$header = id(new PHUIHeaderView())
->setUser($viewer)
->setHeader($this->renderPathLinks($drequest, 'browse'))
->setHeader($this->renderPathLinks($drequest, $mode = 'browse'))
->setPolicyObject($drequest->getRepository());
return $header;

View file

@ -73,7 +73,7 @@ final class DiffusionChangeController extends DiffusionController {
'view' => 'change',
));
$links = $this->renderPathLinks($drequest);
$links = $this->renderPathLinks($drequest, $mode = 'browse');
$header = id(new PHUIHeaderView())
->setHeader($links)
@ -106,18 +106,13 @@ final class DiffusionChangeController extends DiffusionController {
'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(
$browse_uri = $drequest->generateURI(
array(
'action' => 'browse',
));

View file

@ -202,7 +202,7 @@ abstract class DiffusionController extends PhabricatorController {
$crumb = id(new PhabricatorCrumbView())
->setName($view_name);
if ($view == 'browse' || $view == 'change') {
if ($view == 'browse' || $view == 'change' || $view == 'history') {
$crumb_list[] = $crumb;
return $crumb_list;
}
@ -286,7 +286,7 @@ abstract class DiffusionController extends PhabricatorController {
return $this->getApplicationURI($repository->getCallsign().'/'.$path);
}
protected function renderPathLinks(DiffusionRequest $drequest) {
protected function renderPathLinks(DiffusionRequest $drequest, $action) {
$path = $drequest->getPath();
$path_parts = array_filter(explode('/', trim($path, '/')));
@ -297,7 +297,7 @@ abstract class DiffusionController extends PhabricatorController {
array(
'href' => $drequest->generateURI(
array(
'action' => 'browse',
'action' => $action,
'path' => '',
)),
),
@ -315,7 +315,7 @@ abstract class DiffusionController extends PhabricatorController {
array(
'href' => $drequest->generateURI(
array(
'action' => 'browse',
'action' => $action,
'path' => $accum,
)),
),

View file

@ -2,18 +2,25 @@
final class DiffusionHistoryController extends DiffusionController {
public function shouldAllowPublic() {
return true;
}
public function processRequest() {
$drequest = $this->diffusionRequest;
$request = $this->getRequest();
$viewer = $request->getUser();
$repository = $drequest->getRepository();
$page_size = $request->getInt('pagesize', 100);
$offset = $request->getInt('page', 0);
$offset = $request->getInt('offset', 0);
$params = array(
'commit' => $drequest->getCommit(),
'path' => $drequest->getPath(),
'offset' => $offset,
'limit' => $page_size + 1);
if (!$request->getBool('copies')) {
$params['needDirectChanges'] = true;
$params['needChildChanges'] = true;
@ -28,33 +35,13 @@ final class DiffusionHistoryController extends DiffusionController {
$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');
$history = $pager->sliceResults($history);
$pager->setURI($request->getRequestURI(), 'offset');
$show_graph = !strlen($drequest->getPath());
$content = array();
if ($request->getBool('copies')) {
$button_title = pht('Hide Copies/Branches');
$copies_new = null;
} else {
$button_title = pht('Show Copies/Branches');
$copies_new = true;
}
$button = phutil_tag(
'a',
array(
'class' => 'button small grey',
'href' => $request->getRequestURI()->alter('copies', $copies_new),
),
$button_title);
$history_table = new DiffusionHistoryTableView();
$history_table->setUser($request->getUser());
$history_table->setDiffusionRequest($drequest);
@ -71,29 +58,35 @@ final class DiffusionHistoryController extends DiffusionController {
}
$history_panel = new AphrontPanelView();
$history_panel->setHeader(pht('History'));
$history_panel->addButton($button);
$history_panel->appendChild($history_table);
$history_panel->appendChild($pager);
$history_panel->setNoBackground();
$content[] = $history_panel;
// TODO: Sometimes we do have a change view, we need to look at the most
// recent history entry to figure it out.
$header = id(new PHUIHeaderView())
->setUser($viewer)
->setPolicyObject($repository)
->setHeader($this->renderPathLinks($drequest, $mode = 'history'));
$actions = $this->buildActionView($drequest);
$properties = $this->buildPropertyView($drequest);
$nav = $this->buildSideNav('history', false);
$nav->appendChild($content);
$crumbs = $this->buildCrumbs(
array(
'branch' => true,
'path' => true,
'view' => 'history',
));
$nav->setCrumbs($crumbs);
return $this->buildApplicationPage(
$nav,
array(
$crumbs,
$header,
$actions,
$properties,
$content,
),
array(
'device' => true,
'title' => array(
@ -103,4 +96,75 @@ final class DiffusionHistoryController extends DiffusionController {
));
}
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;
}
}