mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-28 06:29:27 +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:
parent
b3fa9d0c2f
commit
0271b051ae
4 changed files with 103 additions and 44 deletions
|
@ -65,7 +65,7 @@ abstract class DiffusionBrowseController extends DiffusionController {
|
||||||
|
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setHeader($this->renderPathLinks($drequest, 'browse'))
|
->setHeader($this->renderPathLinks($drequest, $mode = 'browse'))
|
||||||
->setPolicyObject($drequest->getRepository());
|
->setPolicyObject($drequest->getRepository());
|
||||||
|
|
||||||
return $header;
|
return $header;
|
||||||
|
|
|
@ -73,7 +73,7 @@ final class DiffusionChangeController extends DiffusionController {
|
||||||
'view' => 'change',
|
'view' => 'change',
|
||||||
));
|
));
|
||||||
|
|
||||||
$links = $this->renderPathLinks($drequest);
|
$links = $this->renderPathLinks($drequest, $mode = 'browse');
|
||||||
|
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setHeader($links)
|
->setHeader($links)
|
||||||
|
@ -106,18 +106,13 @@ final class DiffusionChangeController extends DiffusionController {
|
||||||
'action' => 'history',
|
'action' => 'history',
|
||||||
));
|
));
|
||||||
|
|
||||||
$browse_uri = $drequest->generateURI(
|
|
||||||
array(
|
|
||||||
'action' => 'browse',
|
|
||||||
));
|
|
||||||
|
|
||||||
$view->addAction(
|
$view->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('View History'))
|
->setName(pht('View History'))
|
||||||
->setHref($history_uri)
|
->setHref($history_uri)
|
||||||
->setIcon('history'));
|
->setIcon('history'));
|
||||||
|
|
||||||
$history_uri = $drequest->generateURI(
|
$browse_uri = $drequest->generateURI(
|
||||||
array(
|
array(
|
||||||
'action' => 'browse',
|
'action' => 'browse',
|
||||||
));
|
));
|
||||||
|
|
|
@ -202,7 +202,7 @@ abstract class DiffusionController extends PhabricatorController {
|
||||||
$crumb = id(new PhabricatorCrumbView())
|
$crumb = id(new PhabricatorCrumbView())
|
||||||
->setName($view_name);
|
->setName($view_name);
|
||||||
|
|
||||||
if ($view == 'browse' || $view == 'change') {
|
if ($view == 'browse' || $view == 'change' || $view == 'history') {
|
||||||
$crumb_list[] = $crumb;
|
$crumb_list[] = $crumb;
|
||||||
return $crumb_list;
|
return $crumb_list;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ abstract class DiffusionController extends PhabricatorController {
|
||||||
return $this->getApplicationURI($repository->getCallsign().'/'.$path);
|
return $this->getApplicationURI($repository->getCallsign().'/'.$path);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function renderPathLinks(DiffusionRequest $drequest) {
|
protected function renderPathLinks(DiffusionRequest $drequest, $action) {
|
||||||
$path = $drequest->getPath();
|
$path = $drequest->getPath();
|
||||||
$path_parts = array_filter(explode('/', trim($path, '/')));
|
$path_parts = array_filter(explode('/', trim($path, '/')));
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ abstract class DiffusionController extends PhabricatorController {
|
||||||
array(
|
array(
|
||||||
'href' => $drequest->generateURI(
|
'href' => $drequest->generateURI(
|
||||||
array(
|
array(
|
||||||
'action' => 'browse',
|
'action' => $action,
|
||||||
'path' => '',
|
'path' => '',
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
@ -315,7 +315,7 @@ abstract class DiffusionController extends PhabricatorController {
|
||||||
array(
|
array(
|
||||||
'href' => $drequest->generateURI(
|
'href' => $drequest->generateURI(
|
||||||
array(
|
array(
|
||||||
'action' => 'browse',
|
'action' => $action,
|
||||||
'path' => $accum,
|
'path' => $accum,
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
|
|
@ -2,18 +2,25 @@
|
||||||
|
|
||||||
final class DiffusionHistoryController extends DiffusionController {
|
final class DiffusionHistoryController extends DiffusionController {
|
||||||
|
|
||||||
|
public function shouldAllowPublic() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
$drequest = $this->diffusionRequest;
|
$drequest = $this->diffusionRequest;
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
$viewer = $request->getUser();
|
||||||
|
$repository = $drequest->getRepository();
|
||||||
|
|
||||||
$page_size = $request->getInt('pagesize', 100);
|
$page_size = $request->getInt('pagesize', 100);
|
||||||
$offset = $request->getInt('page', 0);
|
$offset = $request->getInt('offset', 0);
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'commit' => $drequest->getCommit(),
|
'commit' => $drequest->getCommit(),
|
||||||
'path' => $drequest->getPath(),
|
'path' => $drequest->getPath(),
|
||||||
'offset' => $offset,
|
'offset' => $offset,
|
||||||
'limit' => $page_size + 1);
|
'limit' => $page_size + 1);
|
||||||
|
|
||||||
if (!$request->getBool('copies')) {
|
if (!$request->getBool('copies')) {
|
||||||
$params['needDirectChanges'] = true;
|
$params['needDirectChanges'] = true;
|
||||||
$params['needChildChanges'] = true;
|
$params['needChildChanges'] = true;
|
||||||
|
@ -28,33 +35,13 @@ final class DiffusionHistoryController extends DiffusionController {
|
||||||
$pager = new AphrontPagerView();
|
$pager = new AphrontPagerView();
|
||||||
$pager->setPageSize($page_size);
|
$pager->setPageSize($page_size);
|
||||||
$pager->setOffset($offset);
|
$pager->setOffset($offset);
|
||||||
if (count($history) == $page_size + 1) {
|
$history = $pager->sliceResults($history);
|
||||||
array_pop($history);
|
|
||||||
$pager->setHasMorePages(true);
|
$pager->setURI($request->getRequestURI(), 'offset');
|
||||||
} else {
|
|
||||||
$pager->setHasMorePages(false);
|
|
||||||
}
|
|
||||||
$pager->setURI($request->getRequestURI(), 'page');
|
|
||||||
|
|
||||||
$show_graph = !strlen($drequest->getPath());
|
$show_graph = !strlen($drequest->getPath());
|
||||||
$content = array();
|
$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 = new DiffusionHistoryTableView();
|
||||||
$history_table->setUser($request->getUser());
|
$history_table->setUser($request->getUser());
|
||||||
$history_table->setDiffusionRequest($drequest);
|
$history_table->setDiffusionRequest($drequest);
|
||||||
|
@ -71,29 +58,35 @@ final class DiffusionHistoryController extends DiffusionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$history_panel = new AphrontPanelView();
|
$history_panel = new AphrontPanelView();
|
||||||
$history_panel->setHeader(pht('History'));
|
|
||||||
$history_panel->addButton($button);
|
|
||||||
$history_panel->appendChild($history_table);
|
$history_panel->appendChild($history_table);
|
||||||
$history_panel->appendChild($pager);
|
$history_panel->appendChild($pager);
|
||||||
$history_panel->setNoBackground();
|
$history_panel->setNoBackground();
|
||||||
|
|
||||||
$content[] = $history_panel;
|
$content[] = $history_panel;
|
||||||
|
|
||||||
// TODO: Sometimes we do have a change view, we need to look at the most
|
$header = id(new PHUIHeaderView())
|
||||||
// recent history entry to figure it out.
|
->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(
|
$crumbs = $this->buildCrumbs(
|
||||||
array(
|
array(
|
||||||
'branch' => true,
|
'branch' => true,
|
||||||
'path' => true,
|
'path' => true,
|
||||||
'view' => 'history',
|
'view' => 'history',
|
||||||
));
|
));
|
||||||
$nav->setCrumbs($crumbs);
|
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->buildApplicationPage(
|
||||||
$nav,
|
array(
|
||||||
|
$crumbs,
|
||||||
|
$header,
|
||||||
|
$actions,
|
||||||
|
$properties,
|
||||||
|
$content,
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
'device' => true,
|
'device' => true,
|
||||||
'title' => array(
|
'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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue