mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Add a graph view page to Diffusion
Summary: Fixes T12840. This adds a parallel "graph" button next to history on home and on the history list page. I'll think more about better placement of how to get to this page with the upcoming redesign that's still sitting in Pholio. Test Plan: View History, View Graph, Try pager, go to a file, click view history, see no graph button. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T12840 Differential Revision: https://secure.phabricator.com/D18131
This commit is contained in:
parent
9540ed7ec2
commit
d0898116d8
7 changed files with 161 additions and 37 deletions
|
@ -729,6 +729,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionGitResponse' => 'applications/diffusion/response/DiffusionGitResponse.php',
|
||||
'DiffusionGitSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitSSHWorkflow.php',
|
||||
'DiffusionGitUploadPackSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitUploadPackSSHWorkflow.php',
|
||||
'DiffusionGraphController' => 'applications/diffusion/controller/DiffusionGraphController.php',
|
||||
'DiffusionHistoryController' => 'applications/diffusion/controller/DiffusionHistoryController.php',
|
||||
'DiffusionHistoryListView' => 'applications/diffusion/view/DiffusionHistoryListView.php',
|
||||
'DiffusionHistoryQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php',
|
||||
|
@ -5706,6 +5707,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionRepositoryClusterEngineLogInterface',
|
||||
),
|
||||
'DiffusionGitUploadPackSSHWorkflow' => 'DiffusionGitSSHWorkflow',
|
||||
'DiffusionGraphController' => 'DiffusionController',
|
||||
'DiffusionHistoryController' => 'DiffusionController',
|
||||
'DiffusionHistoryListView' => 'DiffusionHistoryView',
|
||||
'DiffusionHistoryQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
|
||||
|
|
|
@ -56,6 +56,7 @@ final class PhabricatorDiffusionApplication extends PhabricatorApplication {
|
|||
'repository/(?P<dblob>.*)' => 'DiffusionRepositoryController',
|
||||
'change/(?P<dblob>.*)' => 'DiffusionChangeController',
|
||||
'history/(?P<dblob>.*)' => 'DiffusionHistoryController',
|
||||
'graph/(?P<dblob>.*)' => 'DiffusionGraphController',
|
||||
'browse/(?P<dblob>.*)' => 'DiffusionBrowseController',
|
||||
'lastmodified/(?P<dblob>.*)' => 'DiffusionLastModifiedController',
|
||||
'diff/' => 'DiffusionDiffController',
|
||||
|
|
|
@ -204,6 +204,9 @@ abstract class DiffusionController extends PhabricatorController {
|
|||
case 'history':
|
||||
$view_name = pht('History');
|
||||
break;
|
||||
case 'graph':
|
||||
$view_name = pht('Graph');
|
||||
break;
|
||||
case 'browse':
|
||||
$view_name = pht('Browse');
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionGraphController extends DiffusionController {
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$response = $this->loadDiffusionContext();
|
||||
if ($response) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$viewer = $this->getViewer();
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
$pager = id(new PHUIPagerView())
|
||||
->readFromRequest($request);
|
||||
|
||||
$params = array(
|
||||
'commit' => $drequest->getCommit(),
|
||||
'path' => $drequest->getPath(),
|
||||
'offset' => $pager->getOffset(),
|
||||
'limit' => $pager->getPageSize() + 1,
|
||||
);
|
||||
|
||||
$history_results = $this->callConduitWithDiffusionRequest(
|
||||
'diffusion.historyquery',
|
||||
$params);
|
||||
$history = DiffusionPathChange::newFromConduit(
|
||||
$history_results['pathChanges']);
|
||||
|
||||
$history = $pager->sliceResults($history);
|
||||
|
||||
$graph = id(new DiffusionHistoryTableView())
|
||||
->setViewer($viewer)
|
||||
->setDiffusionRequest($drequest)
|
||||
->setHistory($history);
|
||||
|
||||
$graph->loadRevisions();
|
||||
$show_graph = !strlen($drequest->getPath());
|
||||
if ($show_graph) {
|
||||
$graph->setParents($history_results['parents']);
|
||||
$graph->setIsHead(!$pager->getOffset());
|
||||
$graph->setIsTail(!$pager->getHasMorePages());
|
||||
}
|
||||
|
||||
$header = $this->buildHeader($drequest);
|
||||
|
||||
$crumbs = $this->buildCrumbs(
|
||||
array(
|
||||
'branch' => true,
|
||||
'path' => true,
|
||||
'view' => 'graph',
|
||||
));
|
||||
$crumbs->setBorder(true);
|
||||
|
||||
$title = array(
|
||||
pht('Graph'),
|
||||
$repository->getDisplayName(),
|
||||
);
|
||||
|
||||
$graph_view = id(new PHUIObjectBoxView())
|
||||
->setHeaderText(pht('History Graph'))
|
||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||
->setTable($graph)
|
||||
->setPager($pager);
|
||||
|
||||
$view = id(new PHUITwoColumnView())
|
||||
->setHeader($header)
|
||||
->setFooter($graph_view);
|
||||
|
||||
return $this->newPage()
|
||||
->setTitle($title)
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild($view);
|
||||
}
|
||||
|
||||
private function buildHeader(DiffusionRequest $drequest) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$tag = $this->renderCommitHashTag($drequest);
|
||||
$history_uri = $drequest->generateURI(
|
||||
array(
|
||||
'action' => 'history',
|
||||
));
|
||||
|
||||
$history_button = id(new PHUIButtonView())
|
||||
->setTag('a')
|
||||
->setText(pht('History'))
|
||||
->setHref($history_uri)
|
||||
->setIcon('fa-history');
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setUser($viewer)
|
||||
->setPolicyObject($drequest->getRepository())
|
||||
->addTag($tag)
|
||||
->setHeader($this->renderPathLinks($drequest, $mode = 'history'))
|
||||
->setHeaderIcon('fa-code-fork')
|
||||
->addActionLink($history_button);
|
||||
|
||||
return $header;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -77,24 +77,28 @@ final class DiffusionHistoryController extends DiffusionController {
|
|||
$viewer = $this->getViewer();
|
||||
|
||||
$tag = $this->renderCommitHashTag($drequest);
|
||||
$browse_uri = $drequest->generateURI(
|
||||
array(
|
||||
'action' => 'browse',
|
||||
));
|
||||
|
||||
$browse_button = id(new PHUIButtonView())
|
||||
->setTag('a')
|
||||
->setText(pht('Browse'))
|
||||
->setHref($browse_uri)
|
||||
->setIcon('fa-code');
|
||||
$show_graph = !strlen($drequest->getPath());
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setUser($viewer)
|
||||
->setPolicyObject($drequest->getRepository())
|
||||
->addTag($tag)
|
||||
->setHeader($this->renderPathLinks($drequest, $mode = 'history'))
|
||||
->setHeaderIcon('fa-clock-o')
|
||||
->addActionLink($browse_button);
|
||||
->setHeaderIcon('fa-clock-o');
|
||||
|
||||
if ($show_graph) {
|
||||
$graph_uri = $drequest->generateURI(
|
||||
array(
|
||||
'action' => 'graph',
|
||||
));
|
||||
|
||||
$graph_button = id(new PHUIButtonView())
|
||||
->setTag('a')
|
||||
->setText(pht('Graph'))
|
||||
->setHref($graph_uri)
|
||||
->setIcon('fa-code-fork');
|
||||
$header->addActionLink($graph_button);
|
||||
}
|
||||
|
||||
return $header;
|
||||
|
||||
|
|
|
@ -451,11 +451,11 @@ final class DiffusionRepositoryController extends DiffusionController {
|
|||
$header->setSubheader(pht('Showing %d branches.', $limit));
|
||||
}
|
||||
|
||||
$button = new PHUIButtonView();
|
||||
$button->setText(pht('Show All'));
|
||||
$button->setTag('a');
|
||||
$button->setIcon('fa-code-fork');
|
||||
$button->setHref($drequest->generateURI(
|
||||
$button = id(new PHUIButtonView())
|
||||
->setText(pht('Show All'))
|
||||
->setTag('a')
|
||||
->setIcon('fa-code-fork')
|
||||
->setHref($drequest->generateURI(
|
||||
array(
|
||||
'action' => 'branches',
|
||||
)));
|
||||
|
@ -511,11 +511,11 @@ final class DiffusionRepositoryController extends DiffusionController {
|
|||
pht('Showing the %d most recent tags.', $tag_limit));
|
||||
}
|
||||
|
||||
$button = new PHUIButtonView();
|
||||
$button->setText(pht('Show All Tags'));
|
||||
$button->setTag('a');
|
||||
$button->setIcon('fa-tag');
|
||||
$button->setHref($drequest->generateURI(
|
||||
$button = id(new PHUIButtonView())
|
||||
->setText(pht('Show All Tags'))
|
||||
->setTag('a')
|
||||
->setIcon('fa-tag')
|
||||
->setHref($drequest->generateURI(
|
||||
array(
|
||||
'action' => 'tags',
|
||||
)));
|
||||
|
@ -567,23 +567,30 @@ final class DiffusionRepositoryController extends DiffusionController {
|
|||
|
||||
$history_table->setIsHead(true);
|
||||
|
||||
$icon = id(new PHUIIconView())
|
||||
->setIcon('fa-list-alt');
|
||||
|
||||
$button = id(new PHUIButtonView())
|
||||
->setText(pht('View History'))
|
||||
$history = id(new PHUIButtonView())
|
||||
->setText(pht('History'))
|
||||
->setHref($drequest->generateURI(
|
||||
array(
|
||||
'action' => 'history',
|
||||
)))
|
||||
->setTag('a')
|
||||
->setIcon($icon);
|
||||
->setIcon('fa-history');
|
||||
|
||||
$graph = id(new PHUIButtonView())
|
||||
->setText(pht('Graph'))
|
||||
->setHref($drequest->generateURI(
|
||||
array(
|
||||
'action' => 'graph',
|
||||
)))
|
||||
->setTag('a')
|
||||
->setIcon('fa-code-fork');
|
||||
|
||||
$panel = id(new PHUIObjectBoxView())
|
||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader(pht('Recent Commits'))
|
||||
->addActionLink($button);
|
||||
->addActionLink($graph)
|
||||
->addActionLink($history);
|
||||
$panel->setHeader($header);
|
||||
$panel->setTable($history_table);
|
||||
|
||||
|
@ -672,14 +679,11 @@ final class DiffusionRepositoryController extends DiffusionController {
|
|||
$header = id(new PHUIHeaderView())
|
||||
->setHeader($repository->getName());
|
||||
|
||||
$icon = id(new PHUIIconView())
|
||||
->setIcon('fa-folder-open');
|
||||
|
||||
$button = new PHUIButtonView();
|
||||
$button->setText(pht('Browse Repository'));
|
||||
$button->setTag('a');
|
||||
$button->setIcon($icon);
|
||||
$button->setHref($browse_uri);
|
||||
$button = id(new PHUIButtonView())
|
||||
->setText(pht('Browse'))
|
||||
->setTag('a')
|
||||
->setIcon('fa-code')
|
||||
->setHref($browse_uri);
|
||||
|
||||
$header->addActionLink($button);
|
||||
$browse_panel->setHeader($header);
|
||||
|
|
|
@ -699,6 +699,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
|||
$action = idx($params, 'action');
|
||||
switch ($action) {
|
||||
case 'history':
|
||||
case 'graph':
|
||||
case 'browse':
|
||||
case 'change':
|
||||
case 'lastmodified':
|
||||
|
@ -776,6 +777,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
|||
switch ($action) {
|
||||
case 'change':
|
||||
case 'history':
|
||||
case 'graph':
|
||||
case 'browse':
|
||||
case 'lastmodified':
|
||||
case 'tags':
|
||||
|
|
Loading…
Reference in a new issue