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

Modernize Diffusion browse views

Summary: Broadly, I'm trying to modernize these views and fix UI and at least mitigate mobile problems. See discussion.

Test Plan: See screenshots.

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7042
This commit is contained in:
epriestley 2013-09-19 11:57:33 -07:00
parent 3b5f0276d1
commit 09cdf0de48
4 changed files with 199 additions and 58 deletions

View file

@ -26,7 +26,8 @@ final class ConduitAPI_diffusion_tagsquery_Method
protected function getGitResult(ConduitAPIRequest $request) { protected function getGitResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest(); $drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository(); $repository = $drequest->getRepository();
$commit = $drequest->getCommit(); $commit = $drequest->getRawCommit();
$offset = $request->getValue('offset'); $offset = $request->getValue('offset');
$limit = $request->getValue('limit'); $limit = $request->getValue('limit');

View file

@ -29,22 +29,14 @@ final class DiffusionBrowseController extends DiffusionController {
$content = array(); $content = array();
if ($drequest->getTagContent()) { $content[] = $this->buildHeaderView($drequest);
$title = pht('Tag: %s', $drequest->getSymbolicCommit()); $content[] = $this->buildActionView($drequest);
$content[] = $this->buildPropertyView($drequest);
$tag_view = new AphrontPanelView();
$tag_view->setHeader($title);
$tag_view->appendChild(
$this->markupText($drequest->getTagContent()));
$content[] = $tag_view;
}
$content[] = $this->renderSearchForm(); $content[] = $this->renderSearchForm();
if ($this->getRequest()->getStr('grep') != '') { if ($this->getRequest()->getStr('grep') != '') {
$content[] = $this->renderSearchResults(); $content[] = $this->renderSearchResults();
} else { } else {
if (!$results->isValidResults()) { if (!$results->isValidResults()) {
$empty_result = new DiffusionEmptyResultView(); $empty_result = new DiffusionEmptyResultView();
@ -52,9 +44,7 @@ final class DiffusionBrowseController extends DiffusionController {
$empty_result->setDiffusionBrowseResultSet($results); $empty_result->setDiffusionBrowseResultSet($results);
$empty_result->setView($this->getRequest()->getStr('view')); $empty_result->setView($this->getRequest()->getStr('view'));
$content[] = $empty_result; $content[] = $empty_result;
} else { } else {
$phids = array(); $phids = array();
foreach ($results->getPaths() as $result) { foreach ($results->getPaths() as $result) {
$data = $result->getLastCommitData(); $data = $result->getLastCommitData();
@ -103,21 +93,20 @@ final class DiffusionBrowseController extends DiffusionController {
$box, $box,
); );
} }
} }
$nav = $this->buildSideNav('browse', false);
$nav->appendChild($content);
$crumbs = $this->buildCrumbs( $crumbs = $this->buildCrumbs(
array( array(
'branch' => true, 'branch' => true,
'path' => true, 'path' => true,
'view' => 'browse', 'view' => 'browse',
)); ));
$nav->setCrumbs($crumbs);
return $this->buildApplicationPage( return $this->buildApplicationPage(
$nav, array(
$crumbs,
$content,
),
array( array(
'device' => true, 'device' => true,
'title' => array( 'title' => array(
@ -146,16 +135,24 @@ final class DiffusionBrowseController extends DiffusionController {
->setLabel(pht('Search Here')) ->setLabel(pht('Search Here'))
->setName('grep') ->setName('grep')
->setValue($this->getRequest()->getStr('grep')) ->setValue($this->getRequest()->getStr('grep'))
->setCaption(pht('Regular expression'))) ->setCaption(pht('Enter a regular expression.')))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue(pht('Grep'))); ->setValue(pht('Search File Content')));
break; break;
} }
$filter = new AphrontListFilterView(); $filter = new AphrontListFilterView();
$filter->appendChild($form); $filter->appendChild($form);
if (!strlen($this->getRequest()->getStr('grep'))) {
$filter->setCollapsed(
pht('Show Search'),
pht('Hide Search'),
pht('Search for file content in this directory.'),
'#');
}
return $filter; return $filter;
} }
@ -249,7 +246,7 @@ final class DiffusionBrowseController extends DiffusionController {
->setNoDataString($no_data); ->setNoDataString($no_data);
return id(new AphrontPanelView()) return id(new AphrontPanelView())
->setHeader(pht('Search Results')) ->setNoBackground(true)
->appendChild($table) ->appendChild($table)
->appendChild($pager); ->appendChild($pager);
} }
@ -270,4 +267,141 @@ final class DiffusionBrowseController extends DiffusionController {
return $text; return $text;
} }
private function buildHeaderView(DiffusionRequest $drequest) {
$viewer = $this->getRequest()->getUser();
$header = id(new PHUIHeaderView())
->setUser($viewer)
->setHeader($this->renderPathLinks($drequest))
->setPolicyObject($drequest->getRepository());
return $header;
}
private function buildActionView(DiffusionRequest $drequest) {
$viewer = $this->getRequest()->getUser();
$view = id(new PhabricatorActionListView())
->setUser($viewer);
$history_uri = $drequest->generateURI(
array(
'action' => 'history',
));
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('View History'))
->setHref($history_uri)
->setIcon('perflab'));
$behind_head = $drequest->getRawCommit();
$head_uri = $drequest->generateURI(
array(
'commit' => '',
'action' => 'browse',
));
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Jump to HEAD'))
->setHref($head_uri)
->setIcon('home')
->setDisabled(!$behind_head));
// TODO: Ideally, this should live in Owners and be event-triggered, but
// there's no reasonable object for it to react to right now.
$owners_uri = id(new PhutilURI('/owners/view/search/'))
->setQueryParams(
array(
'repository' => $drequest->getCallsign(),
'path' => '/'.$drequest->getPath(),
));
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Find Owners'))
->setHref((string)$owners_uri)
->setIcon('preview'));
return $view;
}
private 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)));
if ($drequest->getTagContent()) {
$view->addProperty(
pht('Tag'),
$drequest->getSymbolicCommit());
$view->addSectionHeader(pht('Tag Content'));
$view->addTextContent($this->markupText($drequest->getTagContent()));
}
return $view;
}
private function renderPathLinks(DiffusionRequest $drequest) {
$path = $drequest->getPath();
$path_parts = array_filter(explode('/', trim($path, '/')));
$links = array();
if ($path_parts) {
$links[] = phutil_tag(
'a',
array(
'href' => $drequest->generateURI(
array(
'action' => 'browse',
'path' => '',
)),
),
'r'.$drequest->getRepository()->getCallsign().'/');
$accum = '';
$last_key = last_key($path_parts);
foreach ($path_parts as $key => $part) {
$links[] = ' ';
$accum .= '/'.$part;
if ($key === $last_key) {
$links[] = $part;
} else {
$links[] = phutil_tag(
'a',
array(
'href' => $drequest->generateURI(
array(
'action' => 'browse',
'path' => $accum,
)),
),
$part.'/');
}
}
} else {
$links[] = 'r'.$drequest->getRepository()->getCallsign().'/';
}
return $links;
}
} }

View file

@ -259,9 +259,11 @@ abstract class DiffusionController extends PhabricatorController {
$crumb = id(new PhabricatorCrumbView()) $crumb = id(new PhabricatorCrumbView())
->setName($view_name); ->setName($view_name);
if (!strlen($path)) {
if ($view == 'browse') {
$crumb_list[] = $crumb; $crumb_list[] = $crumb;
} else { return $crumb_list;
}
$crumb->setHref($drequest->generateURI( $crumb->setHref($drequest->generateURI(
array( array(
@ -272,7 +274,7 @@ abstract class DiffusionController extends PhabricatorController {
$path_parts = explode('/', $path); $path_parts = explode('/', $path);
do { do {
$last = array_pop($path_parts); $last = array_pop($path_parts);
} while ($last == ''); } while (count($path_parts) && $last == '');
$path_sections = array(); $path_sections = array();
$thus_far = ''; $thus_far = '';
@ -294,7 +296,6 @@ abstract class DiffusionController extends PhabricatorController {
$crumb_list[] = id(new PhabricatorCrumbView()) $crumb_list[] = id(new PhabricatorCrumbView())
->setName($path_sections); ->setName($path_sections);
}
$last_crumb = array_pop($crumb_list); $last_crumb = array_pop($crumb_list);

View file

@ -238,7 +238,11 @@ final class DiffusionRepositoryController extends DiffusionController {
$tags = DiffusionRepositoryTag::newFromConduit( $tags = DiffusionRepositoryTag::newFromConduit(
$this->callConduitWithDiffusionRequest( $this->callConduitWithDiffusionRequest(
'diffusion.tagsquery', 'diffusion.tagsquery',
array('limit' => $tag_limit + 1))); array(
// On the home page, we want to find tags on any branch.
'commit' => null,
'limit' => $tag_limit + 1,
)));
} catch (ConduitException $e) { } catch (ConduitException $e) {
if ($e->getMessage() != 'ERR-UNSUPPORTED-VCS') { if ($e->getMessage() != 'ERR-UNSUPPORTED-VCS') {
throw $e; throw $e;
@ -271,6 +275,7 @@ final class DiffusionRepositoryController extends DiffusionController {
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->setHeader(pht('Tags')); $panel->setHeader(pht('Tags'));
$panel->setNoBackground(true);
if ($more_tags) { if ($more_tags) {
$panel->setCaption(pht('Showing the %d most recent tags.', $tag_limit)); $panel->setCaption(pht('Showing the %d most recent tags.', $tag_limit));