Page MenuHomePhabricator

D18161.diff
No OneTemporary

D18161.diff

diff --git a/src/applications/diffusion/controller/DiffusionBranchTableController.php b/src/applications/diffusion/controller/DiffusionBranchTableController.php
--- a/src/applications/diffusion/controller/DiffusionBranchTableController.php
+++ b/src/applications/diffusion/controller/DiffusionBranchTableController.php
@@ -71,8 +71,11 @@
->setHeader(pht('Branches'))
->setHeaderIcon('fa-code-fork');
+ $tabs = $this->buildTabsView('branch');
+
$view = id(new PHUITwoColumnView())
->setHeader($header)
+ ->setTabs($tabs)
->setFooter(array(
$content,
));
diff --git a/src/applications/diffusion/controller/DiffusionController.php b/src/applications/diffusion/controller/DiffusionController.php
--- a/src/applications/diffusion/controller/DiffusionController.php
+++ b/src/applications/diffusion/controller/DiffusionController.php
@@ -123,10 +123,10 @@
private function buildCrumbList(array $spec = array()) {
$spec = $spec + array(
- 'commit' => null,
- 'tags' => null,
- 'branches' => null,
- 'view' => null,
+ 'commit' => null,
+ 'tags' => null,
+ 'branches' => null,
+ 'view' => null,
);
$crumb_list = array();
@@ -315,7 +315,7 @@
protected function renderStatusMessage($title, $body) {
return id(new PHUIInfoView())
- ->setSeverity(PHUIInfoView::SEVERITY_WARNING)
+ ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
->setTitle($title)
->setFlush(true)
->appendChild($body);
@@ -410,4 +410,74 @@
->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;
+
+ }
+
}
diff --git a/src/applications/diffusion/controller/DiffusionGraphController.php b/src/applications/diffusion/controller/DiffusionGraphController.php
--- a/src/applications/diffusion/controller/DiffusionGraphController.php
+++ b/src/applications/diffusion/controller/DiffusionGraphController.php
@@ -68,8 +68,11 @@
->setTable($graph)
->setPager($pager);
+ $tabs = $this->buildTabsView('graph');
+
$view = id(new PHUITwoColumnView())
->setHeader($header)
+ ->setTabs($tabs)
->setFooter($graph_view);
return $this->newPage()
@@ -81,25 +84,17 @@
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');
+ $no_path = !strlen($drequest->getPath());
+ if ($no_path) {
+ $header_text = pht('Graph');
+ } else {
+ $header_text = $this->renderPathLinks($drequest, $mode = '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);
+ ->setHeader($header_text)
+ ->setHeaderIcon('fa-code-fork');
return $header;
diff --git a/src/applications/diffusion/controller/DiffusionHistoryController.php b/src/applications/diffusion/controller/DiffusionHistoryController.php
--- a/src/applications/diffusion/controller/DiffusionHistoryController.php
+++ b/src/applications/diffusion/controller/DiffusionHistoryController.php
@@ -59,8 +59,11 @@
->addClass('mlb')
->appendChild($pager);
+ $tabs = $this->buildTabsView('history');
+
$view = id(new PHUITwoColumnView())
->setHeader($header)
+ ->setTabs($tabs)
->setFooter(array(
$history_list,
$pager,
@@ -76,30 +79,18 @@
private function buildHeader(DiffusionRequest $drequest) {
$viewer = $this->getViewer();
- $tag = $this->renderCommitHashTag($drequest);
- $show_graph = !strlen($drequest->getPath());
+ $no_path = !strlen($drequest->getPath());
+ if ($no_path) {
+ $header_text = pht('History');
+ } else {
+ $header_text = $this->renderPathLinks($drequest, $mode = 'history');
+ }
$header = id(new PHUIHeaderView())
->setUser($viewer)
- ->setPolicyObject($drequest->getRepository())
- ->addTag($tag)
- ->setHeader($this->renderPathLinks($drequest, $mode = 'history'))
+ ->setHeader($header_text)
->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;
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryController.php b/src/applications/diffusion/controller/DiffusionRepositoryController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryController.php
@@ -84,9 +84,12 @@
->setErrors(array($empty_message));
}
+ $tabs = $this->buildTabsView('home');
+
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
+ ->setTabs($tabs)
->setMainColumn(array(
$property_table,
$description,
@@ -134,32 +137,9 @@
'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(
$this->historyFuture,
$this->browseFuture,
- $this->tagFuture,
- $this->branchFuture,
);
$futures = array_filter($futures);
$futures = new FutureIterator($futures);
@@ -241,26 +221,6 @@
$history,
$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) {
$content[] = $readme;
}
@@ -366,6 +326,12 @@
$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())
->setHeaderText(pht('Details'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
@@ -412,123 +378,6 @@
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(
$history_results,
$history,
@@ -567,30 +416,10 @@
$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())
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
$header = id(new PHUIHeaderView())
- ->setHeader(pht('Recent Commits'))
- ->addActionLink($graph)
- ->addActionLink($history);
+ ->setHeader(pht('Recent Commits'));
$panel->setHeader($header);
$panel->setTable($history_table);
@@ -721,35 +550,8 @@
->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() {
return 15;
}
- private function needBranchFuture() {
- $drequest = $this->getDiffusionRequest();
-
- if ($drequest->getBranch() === null) {
- return false;
- }
-
- return true;
- }
-
- private function getBranchLimit() {
- return 15;
- }
-
}
diff --git a/src/applications/diffusion/controller/DiffusionTagListController.php b/src/applications/diffusion/controller/DiffusionTagListController.php
--- a/src/applications/diffusion/controller/DiffusionTagListController.php
+++ b/src/applications/diffusion/controller/DiffusionTagListController.php
@@ -88,8 +88,11 @@
));
$crumbs->setBorder(true);
+ $tabs = $this->buildTabsView('tags');
+
$view = id(new PHUITwoColumnView())
->setHeader($header)
+ ->setTabs($tabs)
->setFooter($content);
return $this->newPage()

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 13, 1:54 AM (6 d, 14 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7504006
Default Alt Text
D18161.diff (14 KB)

Event Timeline