1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 21:40:55 +01:00

Add tabs to Diffusion for consistent navigation

Summary:
Adds a responsive tab bar navigation to Diffusion. Working through the new design here in pieces, so keep in mind M1477 is the target. Notably:

- Removes "branches" and "tags" from RevisionView, now on tabs
- Keeps "browse", "history", "readme" on RevisionView
- Adds tabs for all main views, including Graph... unless how that feels, so let me know.

Test Plan: Browse all pages, desktop and mobile. Test hg, svn, git repositories.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D18161
This commit is contained in:
Chad Little 2017-07-05 22:09:12 +01:00
parent 7b6b3d722a
commit e516358d54
6 changed files with 112 additions and 248 deletions

View file

@ -71,8 +71,11 @@ final class DiffusionBranchTableController extends DiffusionController {
->setHeader(pht('Branches')) ->setHeader(pht('Branches'))
->setHeaderIcon('fa-code-fork'); ->setHeaderIcon('fa-code-fork');
$tabs = $this->buildTabsView('branch');
$view = id(new PHUITwoColumnView()) $view = id(new PHUITwoColumnView())
->setHeader($header) ->setHeader($header)
->setTabs($tabs)
->setFooter(array( ->setFooter(array(
$content, $content,
)); ));

View file

@ -315,7 +315,7 @@ abstract class DiffusionController extends PhabricatorController {
protected function renderStatusMessage($title, $body) { protected function renderStatusMessage($title, $body) {
return id(new PHUIInfoView()) return id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_WARNING) ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
->setTitle($title) ->setTitle($title)
->setFlush(true) ->setFlush(true)
->appendChild($body); ->appendChild($body);
@ -410,4 +410,74 @@ abstract class DiffusionController extends PhabricatorController {
->setContent($readme_corpus); ->setContent($readme_corpus);
} }
protected function buildTabsView($key) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$view = new PHUIListView();
$view->addMenuItem(
id(new PHUIListItemView())
->setKey('home')
->setName(pht('Home'))
->setIcon('fa-home')
->setHref($drequest->generateURI(
array(
'action' => 'branch',
'path' => '/',
)))
->setSelected($key == 'home'));
if (!$repository->isSVN()) {
$view->addMenuItem(
id(new PHUIListItemView())
->setKey('branch')
->setName(pht('Branches'))
->setIcon('fa-code-fork')
->setHref($drequest->generateURI(
array(
'action' => 'branches',
)))
->setSelected($key == 'branch'));
}
if (!$repository->isSVN()) {
$view->addMenuItem(
id(new PHUIListItemView())
->setKey('tags')
->setName(pht('Tags'))
->setIcon('fa-tags')
->setHref($drequest->generateURI(
array(
'action' => 'tags',
)))
->setSelected($key == 'tags'));
}
$view->addMenuItem(
id(new PHUIListItemView())
->setKey('history')
->setName(pht('History'))
->setIcon('fa-history')
->setHref($drequest->generateURI(
array(
'action' => 'history',
)))
->setSelected($key == 'history'));
$view->addMenuItem(
id(new PHUIListItemView())
->setKey('graph')
->setName(pht('Graph'))
->setIcon('fa-code-fork')
->setHref($drequest->generateURI(
array(
'action' => 'graph',
)))
->setSelected($key == 'graph'));
return $view;
}
} }

View file

@ -68,8 +68,11 @@ final class DiffusionGraphController extends DiffusionController {
->setTable($graph) ->setTable($graph)
->setPager($pager); ->setPager($pager);
$tabs = $this->buildTabsView('graph');
$view = id(new PHUITwoColumnView()) $view = id(new PHUITwoColumnView())
->setHeader($header) ->setHeader($header)
->setTabs($tabs)
->setFooter($graph_view); ->setFooter($graph_view);
return $this->newPage() return $this->newPage()
@ -81,25 +84,17 @@ final class DiffusionGraphController extends DiffusionController {
private function buildHeader(DiffusionRequest $drequest) { private function buildHeader(DiffusionRequest $drequest) {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$tag = $this->renderCommitHashTag($drequest); $no_path = !strlen($drequest->getPath());
$history_uri = $drequest->generateURI( if ($no_path) {
array( $header_text = pht('Graph');
'action' => 'history', } else {
)); $header_text = $this->renderPathLinks($drequest, $mode = 'history');
}
$history_button = id(new PHUIButtonView())
->setTag('a')
->setText(pht('History'))
->setHref($history_uri)
->setIcon('fa-history');
$header = id(new PHUIHeaderView()) $header = id(new PHUIHeaderView())
->setUser($viewer) ->setUser($viewer)
->setPolicyObject($drequest->getRepository()) ->setHeader($header_text)
->addTag($tag) ->setHeaderIcon('fa-code-fork');
->setHeader($this->renderPathLinks($drequest, $mode = 'history'))
->setHeaderIcon('fa-code-fork')
->addActionLink($history_button);
return $header; return $header;

View file

@ -59,8 +59,11 @@ final class DiffusionHistoryController extends DiffusionController {
->addClass('mlb') ->addClass('mlb')
->appendChild($pager); ->appendChild($pager);
$tabs = $this->buildTabsView('history');
$view = id(new PHUITwoColumnView()) $view = id(new PHUITwoColumnView())
->setHeader($header) ->setHeader($header)
->setTabs($tabs)
->setFooter(array( ->setFooter(array(
$history_list, $history_list,
$pager, $pager,
@ -76,30 +79,18 @@ final class DiffusionHistoryController extends DiffusionController {
private function buildHeader(DiffusionRequest $drequest) { private function buildHeader(DiffusionRequest $drequest) {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$tag = $this->renderCommitHashTag($drequest); $no_path = !strlen($drequest->getPath());
$show_graph = !strlen($drequest->getPath()); if ($no_path) {
$header_text = pht('History');
} else {
$header_text = $this->renderPathLinks($drequest, $mode = 'history');
}
$header = id(new PHUIHeaderView()) $header = id(new PHUIHeaderView())
->setUser($viewer) ->setUser($viewer)
->setPolicyObject($drequest->getRepository()) ->setHeader($header_text)
->addTag($tag)
->setHeader($this->renderPathLinks($drequest, $mode = 'history'))
->setHeaderIcon('fa-clock-o'); ->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; return $header;
} }

View file

@ -84,9 +84,12 @@ final class DiffusionRepositoryController extends DiffusionController {
->setErrors(array($empty_message)); ->setErrors(array($empty_message));
} }
$tabs = $this->buildTabsView('home');
$view = id(new PHUITwoColumnView()) $view = id(new PHUITwoColumnView())
->setHeader($header) ->setHeader($header)
->setCurtain($curtain) ->setCurtain($curtain)
->setTabs($tabs)
->setMainColumn(array( ->setMainColumn(array(
$property_table, $property_table,
$description, $description,
@ -134,32 +137,9 @@ final class DiffusionRepositoryController extends DiffusionController {
'limit' => $browse_pager->getPageSize() + 1, 'limit' => $browse_pager->getPageSize() + 1,
)); ));
if ($this->needTagFuture()) {
$tag_limit = $this->getTagLimit();
$this->tagFuture = $this->callConduitMethod(
'diffusion.tagsquery',
array(
// On the home page, we want to find tags on any branch.
'commit' => null,
'limit' => $tag_limit + 1,
));
}
if ($this->needBranchFuture()) {
$branch_limit = $this->getBranchLimit();
$this->branchFuture = $this->callConduitMethod(
'diffusion.branchquery',
array(
'closed' => false,
'limit' => $branch_limit + 1,
));
}
$futures = array( $futures = array(
$this->historyFuture, $this->historyFuture,
$this->browseFuture, $this->browseFuture,
$this->tagFuture,
$this->branchFuture,
); );
$futures = array_filter($futures); $futures = array_filter($futures);
$futures = new FutureIterator($futures); $futures = new FutureIterator($futures);
@ -241,26 +221,6 @@ final class DiffusionRepositoryController extends DiffusionController {
$history, $history,
$history_exception); $history_exception);
try {
$content[] = $this->buildTagListTable($drequest);
} catch (Exception $ex) {
if (!$repository->isImporting()) {
$content[] = $this->renderStatusMessage(
pht('Unable to Load Tags'),
$ex->getMessage());
}
}
try {
$content[] = $this->buildBranchListTable($drequest);
} catch (Exception $ex) {
if (!$repository->isImporting()) {
$content[] = $this->renderStatusMessage(
pht('Unable to Load Branches'),
$ex->getMessage());
}
}
if ($readme) { if ($readme) {
$content[] = $readme; $content[] = $readme;
} }
@ -366,6 +326,12 @@ final class DiffusionRepositoryController extends DiffusionController {
$this->renderCloneURI($repository, $uri)); $this->renderCloneURI($repository, $uri));
} }
if (!$view->hasAnyProperties()) {
$view = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
->appendChild(pht('Repository has no URIs set.'));
}
$box = id(new PHUIObjectBoxView()) $box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Details')) ->setHeaderText(pht('Details'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
@ -412,123 +378,6 @@ final class DiffusionRepositoryController extends DiffusionController {
return $box; return $box;
} }
private function buildBranchListTable(DiffusionRequest $drequest) {
$viewer = $this->getViewer();
if (!$this->needBranchFuture()) {
return null;
}
$branches = $this->branchFuture->resolve();
if (!$branches) {
return null;
}
$limit = $this->getBranchLimit();
$more_branches = (count($branches) > $limit);
$branches = array_slice($branches, 0, $limit);
$branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches);
$commits = id(new DiffusionCommitQuery())
->setViewer($viewer)
->withIdentifiers(mpull($branches, 'getCommitIdentifier'))
->withRepository($drequest->getRepository())
->execute();
$table = id(new DiffusionBranchTableView())
->setUser($viewer)
->setDiffusionRequest($drequest)
->setBranches($branches)
->setCommits($commits);
$panel = id(new PHUIObjectBoxView())
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
$header = new PHUIHeaderView();
$header->setHeader(pht('Branches'));
if ($more_branches) {
$header->setSubheader(pht('Showing %d branches.', $limit));
}
$button = id(new PHUIButtonView())
->setText(pht('Show All'))
->setTag('a')
->setIcon('fa-code-fork')
->setHref($drequest->generateURI(
array(
'action' => 'branches',
)));
$header->addActionLink($button);
$panel->setHeader($header);
$panel->setTable($table);
return $panel;
}
private function buildTagListTable(DiffusionRequest $drequest) {
$viewer = $this->getViewer();
$repository = $drequest->getRepository();
if (!$this->needTagFuture()) {
return null;
}
$tags = $this->tagFuture->resolve();
$tags = DiffusionRepositoryTag::newFromConduit($tags);
if (!$tags) {
return null;
}
$tag_limit = $this->getTagLimit();
$more_tags = (count($tags) > $tag_limit);
$tags = array_slice($tags, 0, $tag_limit);
$commits = id(new DiffusionCommitQuery())
->setViewer($viewer)
->withIdentifiers(mpull($tags, 'getCommitIdentifier'))
->withRepository($repository)
->needCommitData(true)
->execute();
$view = id(new DiffusionTagTableView())
->setUser($viewer)
->setDiffusionRequest($drequest)
->setTags($tags)
->setCommits($commits);
$phids = $view->getRequiredHandlePHIDs();
$handles = $this->loadViewerHandles($phids);
$view->setHandles($handles);
$panel = new PHUIObjectBoxView();
$header = new PHUIHeaderView();
$header->setHeader(pht('Tags'));
if ($more_tags) {
$header->setSubheader(
pht('Showing the %d most recent tags.', $tag_limit));
}
$button = id(new PHUIButtonView())
->setText(pht('Show All Tags'))
->setTag('a')
->setIcon('fa-tag')
->setHref($drequest->generateURI(
array(
'action' => 'tags',
)));
$header->addActionLink($button);
$panel->setHeader($header);
$panel->setTable($view);
$panel->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
return $panel;
}
private function buildHistoryTable( private function buildHistoryTable(
$history_results, $history_results,
$history, $history,
@ -567,30 +416,10 @@ final class DiffusionRepositoryController extends DiffusionController {
$history_table->setIsHead(true); $history_table->setIsHead(true);
$history = id(new PHUIButtonView())
->setText(pht('History'))
->setHref($drequest->generateURI(
array(
'action' => 'history',
)))
->setTag('a')
->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($graph)
->addActionLink($history);
$panel->setHeader($header); $panel->setHeader($header);
$panel->setTable($history_table); $panel->setTable($history_table);
@ -721,35 +550,8 @@ final class DiffusionRepositoryController extends DiffusionController {
->setDisplayURI($display); ->setDisplayURI($display);
} }
private function needTagFuture() {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
// No tags in SVN.
return false;
}
return true;
}
private function getTagLimit() { private function getTagLimit() {
return 15; return 15;
} }
private function needBranchFuture() {
$drequest = $this->getDiffusionRequest();
if ($drequest->getBranch() === null) {
return false;
}
return true;
}
private function getBranchLimit() {
return 15;
}
} }

View file

@ -88,8 +88,11 @@ final class DiffusionTagListController extends DiffusionController {
)); ));
$crumbs->setBorder(true); $crumbs->setBorder(true);
$tabs = $this->buildTabsView('tags');
$view = id(new PHUITwoColumnView()) $view = id(new PHUITwoColumnView())
->setHeader($header) ->setHeader($header)
->setTabs($tabs)
->setFooter($content); ->setFooter($content);
return $this->newPage() return $this->newPage()