mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-02 11:42:42 +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',
|
'DiffusionGitResponse' => 'applications/diffusion/response/DiffusionGitResponse.php',
|
||||||
'DiffusionGitSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitSSHWorkflow.php',
|
'DiffusionGitSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitSSHWorkflow.php',
|
||||||
'DiffusionGitUploadPackSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitUploadPackSSHWorkflow.php',
|
'DiffusionGitUploadPackSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitUploadPackSSHWorkflow.php',
|
||||||
|
'DiffusionGraphController' => 'applications/diffusion/controller/DiffusionGraphController.php',
|
||||||
'DiffusionHistoryController' => 'applications/diffusion/controller/DiffusionHistoryController.php',
|
'DiffusionHistoryController' => 'applications/diffusion/controller/DiffusionHistoryController.php',
|
||||||
'DiffusionHistoryListView' => 'applications/diffusion/view/DiffusionHistoryListView.php',
|
'DiffusionHistoryListView' => 'applications/diffusion/view/DiffusionHistoryListView.php',
|
||||||
'DiffusionHistoryQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php',
|
'DiffusionHistoryQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php',
|
||||||
|
@ -5706,6 +5707,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionRepositoryClusterEngineLogInterface',
|
'DiffusionRepositoryClusterEngineLogInterface',
|
||||||
),
|
),
|
||||||
'DiffusionGitUploadPackSSHWorkflow' => 'DiffusionGitSSHWorkflow',
|
'DiffusionGitUploadPackSSHWorkflow' => 'DiffusionGitSSHWorkflow',
|
||||||
|
'DiffusionGraphController' => 'DiffusionController',
|
||||||
'DiffusionHistoryController' => 'DiffusionController',
|
'DiffusionHistoryController' => 'DiffusionController',
|
||||||
'DiffusionHistoryListView' => 'DiffusionHistoryView',
|
'DiffusionHistoryListView' => 'DiffusionHistoryView',
|
||||||
'DiffusionHistoryQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
|
'DiffusionHistoryQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
|
||||||
|
|
|
@ -56,6 +56,7 @@ final class PhabricatorDiffusionApplication extends PhabricatorApplication {
|
||||||
'repository/(?P<dblob>.*)' => 'DiffusionRepositoryController',
|
'repository/(?P<dblob>.*)' => 'DiffusionRepositoryController',
|
||||||
'change/(?P<dblob>.*)' => 'DiffusionChangeController',
|
'change/(?P<dblob>.*)' => 'DiffusionChangeController',
|
||||||
'history/(?P<dblob>.*)' => 'DiffusionHistoryController',
|
'history/(?P<dblob>.*)' => 'DiffusionHistoryController',
|
||||||
|
'graph/(?P<dblob>.*)' => 'DiffusionGraphController',
|
||||||
'browse/(?P<dblob>.*)' => 'DiffusionBrowseController',
|
'browse/(?P<dblob>.*)' => 'DiffusionBrowseController',
|
||||||
'lastmodified/(?P<dblob>.*)' => 'DiffusionLastModifiedController',
|
'lastmodified/(?P<dblob>.*)' => 'DiffusionLastModifiedController',
|
||||||
'diff/' => 'DiffusionDiffController',
|
'diff/' => 'DiffusionDiffController',
|
||||||
|
|
|
@ -204,6 +204,9 @@ abstract class DiffusionController extends PhabricatorController {
|
||||||
case 'history':
|
case 'history':
|
||||||
$view_name = pht('History');
|
$view_name = pht('History');
|
||||||
break;
|
break;
|
||||||
|
case 'graph':
|
||||||
|
$view_name = pht('Graph');
|
||||||
|
break;
|
||||||
case 'browse':
|
case 'browse':
|
||||||
$view_name = pht('Browse');
|
$view_name = pht('Browse');
|
||||||
break;
|
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();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$tag = $this->renderCommitHashTag($drequest);
|
$tag = $this->renderCommitHashTag($drequest);
|
||||||
$browse_uri = $drequest->generateURI(
|
$show_graph = !strlen($drequest->getPath());
|
||||||
array(
|
|
||||||
'action' => 'browse',
|
|
||||||
));
|
|
||||||
|
|
||||||
$browse_button = id(new PHUIButtonView())
|
|
||||||
->setTag('a')
|
|
||||||
->setText(pht('Browse'))
|
|
||||||
->setHref($browse_uri)
|
|
||||||
->setIcon('fa-code');
|
|
||||||
|
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setPolicyObject($drequest->getRepository())
|
->setPolicyObject($drequest->getRepository())
|
||||||
->addTag($tag)
|
->addTag($tag)
|
||||||
->setHeader($this->renderPathLinks($drequest, $mode = 'history'))
|
->setHeader($this->renderPathLinks($drequest, $mode = 'history'))
|
||||||
->setHeaderIcon('fa-clock-o')
|
->setHeaderIcon('fa-clock-o');
|
||||||
->addActionLink($browse_button);
|
|
||||||
|
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;
|
return $header;
|
||||||
|
|
||||||
|
|
|
@ -451,11 +451,11 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||||
$header->setSubheader(pht('Showing %d branches.', $limit));
|
$header->setSubheader(pht('Showing %d branches.', $limit));
|
||||||
}
|
}
|
||||||
|
|
||||||
$button = new PHUIButtonView();
|
$button = id(new PHUIButtonView())
|
||||||
$button->setText(pht('Show All'));
|
->setText(pht('Show All'))
|
||||||
$button->setTag('a');
|
->setTag('a')
|
||||||
$button->setIcon('fa-code-fork');
|
->setIcon('fa-code-fork')
|
||||||
$button->setHref($drequest->generateURI(
|
->setHref($drequest->generateURI(
|
||||||
array(
|
array(
|
||||||
'action' => 'branches',
|
'action' => 'branches',
|
||||||
)));
|
)));
|
||||||
|
@ -511,11 +511,11 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||||
pht('Showing the %d most recent tags.', $tag_limit));
|
pht('Showing the %d most recent tags.', $tag_limit));
|
||||||
}
|
}
|
||||||
|
|
||||||
$button = new PHUIButtonView();
|
$button = id(new PHUIButtonView())
|
||||||
$button->setText(pht('Show All Tags'));
|
->setText(pht('Show All Tags'))
|
||||||
$button->setTag('a');
|
->setTag('a')
|
||||||
$button->setIcon('fa-tag');
|
->setIcon('fa-tag')
|
||||||
$button->setHref($drequest->generateURI(
|
->setHref($drequest->generateURI(
|
||||||
array(
|
array(
|
||||||
'action' => 'tags',
|
'action' => 'tags',
|
||||||
)));
|
)));
|
||||||
|
@ -567,23 +567,30 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||||
|
|
||||||
$history_table->setIsHead(true);
|
$history_table->setIsHead(true);
|
||||||
|
|
||||||
$icon = id(new PHUIIconView())
|
$history = id(new PHUIButtonView())
|
||||||
->setIcon('fa-list-alt');
|
->setText(pht('History'))
|
||||||
|
|
||||||
$button = id(new PHUIButtonView())
|
|
||||||
->setText(pht('View History'))
|
|
||||||
->setHref($drequest->generateURI(
|
->setHref($drequest->generateURI(
|
||||||
array(
|
array(
|
||||||
'action' => 'history',
|
'action' => 'history',
|
||||||
)))
|
)))
|
||||||
->setTag('a')
|
->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())
|
$panel = id(new PHUIObjectBoxView())
|
||||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setHeader(pht('Recent Commits'))
|
->setHeader(pht('Recent Commits'))
|
||||||
->addActionLink($button);
|
->addActionLink($graph)
|
||||||
|
->addActionLink($history);
|
||||||
$panel->setHeader($header);
|
$panel->setHeader($header);
|
||||||
$panel->setTable($history_table);
|
$panel->setTable($history_table);
|
||||||
|
|
||||||
|
@ -672,14 +679,11 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setHeader($repository->getName());
|
->setHeader($repository->getName());
|
||||||
|
|
||||||
$icon = id(new PHUIIconView())
|
$button = id(new PHUIButtonView())
|
||||||
->setIcon('fa-folder-open');
|
->setText(pht('Browse'))
|
||||||
|
->setTag('a')
|
||||||
$button = new PHUIButtonView();
|
->setIcon('fa-code')
|
||||||
$button->setText(pht('Browse Repository'));
|
->setHref($browse_uri);
|
||||||
$button->setTag('a');
|
|
||||||
$button->setIcon($icon);
|
|
||||||
$button->setHref($browse_uri);
|
|
||||||
|
|
||||||
$header->addActionLink($button);
|
$header->addActionLink($button);
|
||||||
$browse_panel->setHeader($header);
|
$browse_panel->setHeader($header);
|
||||||
|
|
|
@ -699,6 +699,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
$action = idx($params, 'action');
|
$action = idx($params, 'action');
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'history':
|
case 'history':
|
||||||
|
case 'graph':
|
||||||
case 'browse':
|
case 'browse':
|
||||||
case 'change':
|
case 'change':
|
||||||
case 'lastmodified':
|
case 'lastmodified':
|
||||||
|
@ -776,6 +777,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'change':
|
case 'change':
|
||||||
case 'history':
|
case 'history':
|
||||||
|
case 'graph':
|
||||||
case 'browse':
|
case 'browse':
|
||||||
case 'lastmodified':
|
case 'lastmodified':
|
||||||
case 'tags':
|
case 'tags':
|
||||||
|
|
Loading…
Reference in a new issue