From b25b379ca089055b63da6a5ba984f6ab0e2af6b9 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sat, 1 Jul 2017 17:38:17 +0200 Subject: [PATCH 1/7] Move Diffusion Browse to a single column layout Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header. Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17766 --- resources/celerity/map.php | 2 + .../controller/DiffusionBrowseController.php | 197 +++++++++--------- .../controller/DiffusionController.php | 1 + .../diffusion/view/DiffusionReadmeView.php | 6 +- src/view/layout/PhabricatorActionView.php | 5 + .../diffusion/diffusion-repository.css | 13 ++ 6 files changed, 125 insertions(+), 99 deletions(-) create mode 100644 webroot/rsrc/css/application/diffusion/diffusion-repository.css diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 0619fc34f8..6a3b8778e6 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -74,6 +74,7 @@ return array( 'rsrc/css/application/diffusion/diffusion-history.css' => '4540f568', 'rsrc/css/application/diffusion/diffusion-icons.css' => 'a6a1e2ba', 'rsrc/css/application/diffusion/diffusion-readme.css' => '419dd5b6', + 'rsrc/css/application/diffusion/diffusion-repository.css' => 'ee6f20ec', 'rsrc/css/application/diffusion/diffusion-source.css' => '750add59', 'rsrc/css/application/feed/feed.css' => 'ecd4ec57', 'rsrc/css/application/files/global-drag-and-drop.css' => '5c1b47c2', @@ -572,6 +573,7 @@ return array( 'diffusion-history-css' => '4540f568', 'diffusion-icons-css' => 'a6a1e2ba', 'diffusion-readme-css' => '419dd5b6', + 'diffusion-repository-css' => 'ee6f20ec', 'diffusion-source-css' => '750add59', 'diviner-shared-css' => '896f1d43', 'font-fontawesome' => 'e838e088', diff --git a/src/applications/diffusion/controller/DiffusionBrowseController.php b/src/applications/diffusion/controller/DiffusionBrowseController.php index 4eb6144ede..3fa9e62948 100644 --- a/src/applications/diffusion/controller/DiffusionBrowseController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseController.php @@ -106,7 +106,6 @@ final class DiffusionBrowseController extends DiffusionController { $path = $drequest->getPath(); $blame_key = PhabricatorDiffusionBlameSetting::SETTINGKEY; - $show_blame = $request->getBool( 'blame', $viewer->getUserSetting($blame_key)); @@ -160,6 +159,7 @@ final class DiffusionBrowseController extends DiffusionController { $hit_time_limit = $response['tooSlow']; $file_phid = $response['filePHID']; + $show_editor = false; if ($hit_byte_limit) { $corpus = $this->buildErrorCorpus( pht( @@ -215,6 +215,7 @@ final class DiffusionBrowseController extends DiffusionController { } else { $this->loadLintMessages(); $this->coverage = $drequest->loadCoverage(); + $show_editor = true; // Build the content of the file. $corpus = $this->buildCorpus( @@ -234,12 +235,7 @@ final class DiffusionBrowseController extends DiffusionController { require_celerity_resource('diffusion-source-css'); // Render the page. - $view = $this->buildCurtain($drequest); - $curtain = $this->enrichCurtain( - $view, - $drequest, - $show_blame); - + $curtain = $this->buildCurtain($drequest, $show_blame, $show_editor); $properties = $this->buildPropertyView($drequest); $header = $this->buildHeaderView($drequest); $header->setHeaderIcon('fa-file-code-o'); @@ -327,7 +323,7 @@ final class DiffusionBrowseController extends DiffusionController { $reason = $results->getReasonForEmptyResultSet(); - $curtain = $this->buildCurtain($drequest); + $actions = $this->getActions($drequest); $details = $this->buildPropertyView($drequest); $header = $this->buildHeaderView($drequest); @@ -363,9 +359,9 @@ final class DiffusionBrowseController extends DiffusionController { ->setPaths($results->getPaths()) ->setUser($request->getUser()); - $browse_header = id(new PHUIHeaderView()) - ->setHeader(nonempty(basename($drequest->getPath()), '/')) - ->setHeaderIcon('fa-folder-open'); + $title = nonempty(basename($drequest->getPath()), '/'); + $icon = 'fa-folder-open'; + $browse_header = $this->buildPanelHeaderView($title, $icon, $actions); $browse_panel = id(new PHUIObjectBoxView()) ->setHeader($browse_header) @@ -400,15 +396,11 @@ final class DiffusionBrowseController extends DiffusionController { $view = id(new PHUITwoColumnView()) ->setHeader($header) - ->setCurtain($curtain) - ->setMainColumn( + ->setFooter( array( $branch_panel, $empty_result, $browse_panel, - )) - ->setFooter( - array( $open_revisions, $readme, )); @@ -745,14 +737,14 @@ final class DiffusionBrowseController extends DiffusionController { Javelin::initBehavior('load-blame', array('id' => $id)); - - $edit = $this->renderEditButton(); $file = $this->renderFileButton(); - $header = id(new PHUIHeaderView()) - ->setHeader(basename($this->getDiffusionRequest()->getPath())) - ->setHeaderIcon('fa-file-code-o') - ->addActionLink($edit) - ->addActionLink($file); + $title = basename($this->getDiffusionRequest()->getPath()); + $icon = 'fa-file-code-o'; + $drequest = $this->getDiffusionRequest(); + $actions = $this->getActions($drequest); + + $header = $this->buildPanelHeaderView($title, $icon, $actions); + $header->addActionLink($file); $corpus = id(new PHUIObjectBoxView()) ->setHeader($header) @@ -791,14 +783,23 @@ final class DiffusionBrowseController extends DiffusionController { return $corpus; } - private function enrichCurtain( - PHUICurtainView $curtain, + private function buildCurtain( DiffusionRequest $drequest, - $show_blame) { + $show_blame, + $show_editor) { + $curtain = $this->newCurtainView($drequest); $viewer = $this->getViewer(); $base_uri = $this->getRequest()->getRequestURI(); + $user = $this->getRequest()->getUser(); + $repository = $drequest->getRepository(); + $path = $drequest->getPath(); + $line = nonempty((int)$drequest->getLine(), 1); + + $editor_link = $user->loadEditorLink($path, $line, $repository); + $template = $user->loadEditorLink($path, '%l', $repository); + $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Show Last Change')) @@ -827,6 +828,15 @@ final class DiffusionBrowseController extends DiffusionController { ->setUser($viewer) ->setRenderAsForm($viewer->isLoggedIn())); + $curtain->addAction( + id(new PhabricatorActionView()) + ->setName(pht('Open in Editor')) + ->setHref($editor_link) + ->setIcon('fa-pencil') + ->setID('editor_link') + ->setMetadata(array('link_template' => $template)) + ->setDisabled(!$editor_link)); + $href = null; if ($this->getRequest()->getStr('lint') !== null) { $lint_text = pht('Hide %d Lint Message(s)', count($this->lintMessages)); @@ -897,41 +907,16 @@ final class DiffusionBrowseController extends DiffusionController { return $curtain; } - private function renderEditButton() { - $request = $this->getRequest(); - $user = $request->getUser(); - - $drequest = $this->getDiffusionRequest(); - - $repository = $drequest->getRepository(); - $path = $drequest->getPath(); - $line = nonempty((int)$drequest->getLine(), 1); - - $editor_link = $user->loadEditorLink($path, $line, $repository); - $template = $user->loadEditorLink($path, '%l', $repository); - - $button = id(new PHUIButtonView()) - ->setTag('a') - ->setText(pht('Open in Editor')) - ->setHref($editor_link) - ->setIcon('fa-pencil') - ->setID('editor_link') - ->setMetadata(array('link_template' => $template)) - ->setDisabled(!$editor_link); - - return $button; - } - private function renderFileButton($file_uri = null, $label = null) { $base_uri = $this->getRequest()->getRequestURI(); if ($file_uri) { - $text = pht('Download Raw File'); + $text = pht('Download Raw'); $href = $file_uri; $icon = 'fa-download'; } else { - $text = pht('View Raw File'); + $text = pht('View Raw'); $href = $base_uri->alter('view', 'raw'); $icon = 'fa-file-text'; } @@ -1374,10 +1359,12 @@ final class DiffusionBrowseController extends DiffusionController { ))); $file = $this->renderFileButton($file_uri); - $header = id(new PHUIHeaderView()) - ->setHeader(basename($this->getDiffusionRequest()->getPath())) - ->addActionLink($file) - ->setHeaderIcon('fa-file-image-o'); + $title = basename($this->getDiffusionRequest()->getPath()); + $icon = 'fa-file-image-o'; + $drequest = $this->getDiffusionRequest(); + $actions = $this->getActions($drequest); + $header = $this->buildPanelHeaderView($title, $icon, $actions); + $header->addActionLink($file); return id(new PHUIObjectBoxView()) ->setHeader($header) @@ -1393,9 +1380,12 @@ final class DiffusionBrowseController extends DiffusionController { ->appendChild($text); $file = $this->renderFileButton($file_uri); - $header = id(new PHUIHeaderView()) - ->setHeader(pht('Details')) - ->addActionLink($file); + $title = basename($this->getDiffusionRequest()->getPath()); + $icon = 'fa-file'; + $drequest = $this->getDiffusionRequest(); + $actions = $this->getActions($drequest); + $header = $this->buildPanelHeaderView($title, $icon, $actions); + $header->addActionLink($file); $box = id(new PHUIObjectBoxView()) ->setHeader($header) @@ -1656,52 +1646,61 @@ final class DiffusionBrowseController extends DiffusionController { return $header; } - protected function buildCurtain(DiffusionRequest $drequest) { + protected function buildPanelHeaderView($title, $icon, array $actions) { + + $header = id(new PHUIHeaderView()) + ->setHeader($title) + ->setHeaderIcon($icon) + ->addClass('diffusion-panel-header-view'); + + foreach ($actions as $action_link) { + if ($action_link) { + $header->addActionLink($action_link); + } + } + return $header; + + } + + protected function getActions(DiffusionRequest $drequest) { $viewer = $this->getViewer(); $repository = $drequest->getRepository(); - - $curtain = $this->newCurtainView($drequest); - - $history_uri = $drequest->generateURI( - array( - 'action' => 'history', - )); - - $curtain->addAction( - id(new PhabricatorActionView()) - ->setName(pht('View History')) - ->setHref($history_uri) - ->setIcon('fa-list')); - + $history_uri = $drequest->generateURI(array('action' => 'history')); $behind_head = $drequest->getSymbolicCommit(); - - if ($repository->supportsBranchComparison()) { - $compare_uri = $drequest->generateURI( - array( - 'action' => 'compare', - )); - - $curtain->addAction( - id(new PhabricatorActionView()) - ->setName(pht('Compare Against...')) - ->setIcon('fa-code-fork') - ->setWorkflow(true) - ->setHref($compare_uri)); - } - $head_uri = $drequest->generateURI( array( 'commit' => '', 'action' => 'browse', )); - $curtain->addAction( - id(new PhabricatorActionView()) - ->setName(pht('Jump to HEAD')) + + if ($repository->supportsBranchComparison()) { + $compare_uri = $drequest->generateURI(array('action' => 'compare')); + $compare = id(new PHUIButtonView()) + ->setText(pht('Compare')) + ->setIcon('fa-code-fork') + ->setWorkflow(true) + ->setTag('a') + ->setHref($compare_uri) + ->setColor(PHUIButtonView::GREY); + } + + $head = null; + if ($behind_head) { + $head = id(new PHUIButtonView()) + ->setText(pht('Back to HEAD')) ->setHref($head_uri) ->setIcon('fa-home') - ->setDisabled(!$behind_head)); + ->setColor(PHUIButtonView::GREY); + } - return $curtain; + $history = id(new PHUIButtonView()) + ->setText(pht('History')) + ->setHref($history_uri) + ->setTag('a') + ->setIcon('fa-history') + ->setColor(PHUIButtonView::GREY); + + return array($history, $compare, $head); } protected function buildPropertyView( @@ -1902,9 +1901,11 @@ final class DiffusionBrowseController extends DiffusionController { // show the user an error if we can't, rather than making them click // through to hit an error. - $header = id(new PHUIHeaderView()) - ->setHeader(basename($this->getDiffusionRequest()->getPath())) - ->setHeaderIcon('fa-archive'); + $title = basename($this->getDiffusionRequest()->getPath()); + $icon = 'fa-archive'; + $drequest = $this->getDiffusionRequest(); + $actions = $this->getActions($drequest); + $header = $this->buildPanelHeaderView($title, $icon, $actions); $severity = PHUIInfoView::SEVERITY_NOTICE; diff --git a/src/applications/diffusion/controller/DiffusionController.php b/src/applications/diffusion/controller/DiffusionController.php index abebbace90..a73285d111 100644 --- a/src/applications/diffusion/controller/DiffusionController.php +++ b/src/applications/diffusion/controller/DiffusionController.php @@ -44,6 +44,7 @@ abstract class DiffusionController extends PhabricatorController { private function loadContext(array $options) { $request = $this->getRequest(); $viewer = $this->getViewer(); + require_celerity_resource('diffusion-repository-css'); $identifier = $this->getRepositoryIdentifierFromRequest($request); diff --git a/src/applications/diffusion/view/DiffusionReadmeView.php b/src/applications/diffusion/view/DiffusionReadmeView.php index b475fa88ac..88e2e84115 100644 --- a/src/applications/diffusion/view/DiffusionReadmeView.php +++ b/src/applications/diffusion/view/DiffusionReadmeView.php @@ -98,8 +98,12 @@ final class DiffusionReadmeView extends DiffusionView { ->setFluid(true) ->appendChild($readme_content); + $header = id(new PHUIHeaderView()) + ->setHeader($readme_name) + ->addClass('diffusion-panel-header-view'); + return id(new PHUIObjectBoxView()) - ->setHeaderText($readme_name) + ->setHeader($header) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->appendChild($document) ->addClass('diffusion-readme-view'); diff --git a/src/view/layout/PhabricatorActionView.php b/src/view/layout/PhabricatorActionView.php index 85b9d3abfe..f6de8eca5b 100644 --- a/src/view/layout/PhabricatorActionView.php +++ b/src/view/layout/PhabricatorActionView.php @@ -119,6 +119,11 @@ final class PhabricatorActionView extends AphrontView { return $this->openInNewWindow; } + public function setID($id) { + $this->id = $id; + return $this; + } + public function getID() { if (!$this->id) { $this->id = celerity_generate_unique_node_id(); diff --git a/webroot/rsrc/css/application/diffusion/diffusion-repository.css b/webroot/rsrc/css/application/diffusion/diffusion-repository.css new file mode 100644 index 0000000000..99ddd72940 --- /dev/null +++ b/webroot/rsrc/css/application/diffusion/diffusion-repository.css @@ -0,0 +1,13 @@ +/** + * @provides diffusion-repository-css + */ + +.diffusion-page-header-view a.phui-header-action-link { + display: block; + float: none; +} + +.phui-box.phui-object-box.phui-box-blue-property + .diffusion-panel-header-view.phui-header-shell { + padding: 8px 4px 8px 16px; +} From 3536fe2877294e0bed5489b0b67edcf30f247454 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sun, 2 Jul 2017 14:25:10 +0000 Subject: [PATCH 2/7] Update Diffusion conduit text Summary: Fixes T12888 Test Plan: Verify text is there. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T12888 Differential Revision: https://secure.phabricator.com/D18178 --- .../repository/conduit/RepositoryQueryConduitAPIMethod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/repository/conduit/RepositoryQueryConduitAPIMethod.php b/src/applications/repository/conduit/RepositoryQueryConduitAPIMethod.php index 61435e2a1b..8b5005d8ec 100644 --- a/src/applications/repository/conduit/RepositoryQueryConduitAPIMethod.php +++ b/src/applications/repository/conduit/RepositoryQueryConduitAPIMethod.php @@ -14,7 +14,7 @@ final class RepositoryQueryConduitAPIMethod public function getMethodStatusDescription() { return pht( 'This method is frozen and will eventually be deprecated. New code '. - 'should use "diffusion.repository.query" instead.'); + 'should use "diffusion.repository.search" instead.'); } public function getMethodDescription() { From a6f018210466a1c7af08602fc91273090f63bc93 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 3 Jul 2017 07:21:27 -0700 Subject: [PATCH 3/7] Fix an issue where repositories with hyphens could sort improperly in typeaheads Summary: Fixes T12894. See that task for discussion. Test Plan: - Created repositories `abcdef`, then `abcdef-a` through `abcdef-f`. - Before patch, awkward sort order. - After patch, query for `abcdef` hits `abcdef` first. - See T12894 for details and screenshots. Reviewers: chad, amckinley Reviewed By: chad Maniphest Tasks: T12894 Differential Revision: https://secure.phabricator.com/D18179 --- .../diffusion/typeahead/DiffusionRepositoryDatasource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php b/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php index 0b3f191563..e0662b1e1a 100644 --- a/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php +++ b/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php @@ -54,7 +54,7 @@ final class DiffusionRepositoryDatasource $parts[] = $monogram; } - $name = implode(' ', $parts); + $name = implode("\n", $parts); $vcs = $repository->getVersionControlSystem(); $vcs_type = PhabricatorRepositoryType::getNameForRepositoryType($vcs); From 7b6b3d722ad7109a768104ddb875df228318cf87 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 3 Jul 2017 10:25:37 -0700 Subject: [PATCH 4/7] Document the need to restart Phabricator after performing a restore Summary: Depending on how you perform a restore, APC (or, e.g., running daemon processes) might be poisoned with out-of-date caches. Add a note to advise installs to restart after restoring data. See also lengthy fishing expedition support thread. Test Plan: Read the text. Reviewers: chad, amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D18180 --- src/docs/user/configuration/configuring_backups.diviner | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/docs/user/configuration/configuring_backups.diviner b/src/docs/user/configuration/configuring_backups.diviner index 1f13e0e17f..9776448216 100644 --- a/src/docs/user/configuration/configuring_backups.diviner +++ b/src/docs/user/configuration/configuring_backups.diviner @@ -24,6 +24,12 @@ same steps you would if you were creating a backup and then restoring it, you will just backup the old machine and then restore the data onto the new machine. +WARNING: You need to restart Phabricator after restoring data. + +Restarting Phabricator after performing a restore makes sure that caches are +flushed properly. For complete instructions, see +@{article:Restarting Phabricator}. + Backup: MySQL Databases ======================= From e516358d54d2e7f15da2e2ddf474c8d88ae7ab55 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Wed, 5 Jul 2017 22:09:12 +0100 Subject: [PATCH 5/7] 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 --- .../DiffusionBranchTableController.php | 3 + .../controller/DiffusionController.php | 80 ++++++- .../controller/DiffusionGraphController.php | 27 +-- .../controller/DiffusionHistoryController.php | 29 +-- .../DiffusionRepositoryController.php | 218 +----------------- .../controller/DiffusionTagListController.php | 3 + 6 files changed, 112 insertions(+), 248 deletions(-) diff --git a/src/applications/diffusion/controller/DiffusionBranchTableController.php b/src/applications/diffusion/controller/DiffusionBranchTableController.php index 7f8ae11f57..04d00f0306 100644 --- a/src/applications/diffusion/controller/DiffusionBranchTableController.php +++ b/src/applications/diffusion/controller/DiffusionBranchTableController.php @@ -71,8 +71,11 @@ final class DiffusionBranchTableController extends DiffusionController { ->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 index a73285d111..8de17c03a2 100644 --- a/src/applications/diffusion/controller/DiffusionController.php +++ b/src/applications/diffusion/controller/DiffusionController.php @@ -123,10 +123,10 @@ abstract class DiffusionController extends PhabricatorController { 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 @@ abstract class DiffusionController extends PhabricatorController { 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 @@ abstract class DiffusionController extends PhabricatorController { ->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 index 8428a8152d..8ec909139a 100644 --- a/src/applications/diffusion/controller/DiffusionGraphController.php +++ b/src/applications/diffusion/controller/DiffusionGraphController.php @@ -68,8 +68,11 @@ final class DiffusionGraphController extends DiffusionController { ->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 @@ final class DiffusionGraphController extends DiffusionController { 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 index c2f718f11e..fde35133cc 100644 --- a/src/applications/diffusion/controller/DiffusionHistoryController.php +++ b/src/applications/diffusion/controller/DiffusionHistoryController.php @@ -59,8 +59,11 @@ final class DiffusionHistoryController extends DiffusionController { ->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 @@ final class DiffusionHistoryController extends DiffusionController { 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 index 362f78bd3f..d8451db2db 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryController.php @@ -84,9 +84,12 @@ final class DiffusionRepositoryController extends DiffusionController { ->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 @@ final class DiffusionRepositoryController extends DiffusionController { '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 @@ final class DiffusionRepositoryController extends DiffusionController { $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 @@ final class DiffusionRepositoryController extends DiffusionController { $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 @@ final class DiffusionRepositoryController extends DiffusionController { 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 @@ final class DiffusionRepositoryController extends DiffusionController { $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 @@ final class DiffusionRepositoryController extends DiffusionController { ->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 index 5e765ddcb6..f7cd032e1a 100644 --- a/src/applications/diffusion/controller/DiffusionTagListController.php +++ b/src/applications/diffusion/controller/DiffusionTagListController.php @@ -88,8 +88,11 @@ final class DiffusionTagListController extends DiffusionController { )); $crumbs->setBorder(true); + $tabs = $this->buildTabsView('tags'); + $view = id(new PHUITwoColumnView()) ->setHeader($header) + ->setTabs($tabs) ->setFooter($content); return $this->newPage() From 8d11e127ff15fbf133c33f97c994bcbc6400803c Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 5 Jul 2017 09:35:59 -0700 Subject: [PATCH 6/7] Fix several pieces of UI language describing "draft/archive" rules in Phame Summary: Ref T12900. We implement one rule, but tell users a different (older) rule. See T12900 for discussion and history. Test Plan: - Verified draft/archived posts can't be seen by users who don't have permission to edit the blog. - Drafted, archived, and published posts and read the related text. - Looked through the changes I dug up in T12900#228748 for other strings I might have missed. {F5033860} Reviewers: chad Reviewed By: chad Maniphest Tasks: T12900 Differential Revision: https://secure.phabricator.com/D18182 --- .../controller/post/PhamePostArchiveController.php | 5 +++-- .../controller/post/PhamePostViewController.php | 12 ++++++++---- src/applications/phame/storage/PhamePost.php | 5 +++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/applications/phame/controller/post/PhamePostArchiveController.php b/src/applications/phame/controller/post/PhamePostArchiveController.php index b8647121ef..093e7019bf 100644 --- a/src/applications/phame/controller/post/PhamePostArchiveController.php +++ b/src/applications/phame/controller/post/PhamePostArchiveController.php @@ -42,8 +42,9 @@ final class PhamePostArchiveController extends PhamePostController { $title = pht('Archive Post'); $body = pht( - 'This post will revert to archived status and no longer be visible '. - 'to other users or members of this blog.'); + 'If you archive this post, it will only be visible to users who can '. + 'edit %s.', + $viewer->renderHandle($post->getBlogPHID())); $button = pht('Archive Post'); return $this->newDialog() diff --git a/src/applications/phame/controller/post/PhamePostViewController.php b/src/applications/phame/controller/post/PhamePostViewController.php index a73876a197..63adedb7ae 100644 --- a/src/applications/phame/controller/post/PhamePostViewController.php +++ b/src/applications/phame/controller/post/PhamePostViewController.php @@ -46,8 +46,10 @@ final class PhamePostViewController ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) ->setTitle(pht('Draft Post')) ->appendChild( - pht('Only you can see this draft until you publish it. '. - 'Use "Publish" to publish this post.'))); + pht( + 'This is a draft, and is only visible to you and other users '. + 'who can edit %s. Use "Publish" to publish this post.', + $viewer->renderHandle($post->getBlogPHID())))); } if ($post->isArchived()) { @@ -56,8 +58,10 @@ final class PhamePostViewController ->setSeverity(PHUIInfoView::SEVERITY_ERROR) ->setTitle(pht('Archived Post')) ->appendChild( - pht('Only you can see this archived post until you publish it. '. - 'Use "Publish" to publish this post.'))); + pht( + 'This post has been archived, and is only visible to you and '. + 'other users who can edit %s.', + $viewer->renderHandle($post->getBlogPHID())))); } if (!$post->getBlog()) { diff --git a/src/applications/phame/storage/PhamePost.php b/src/applications/phame/storage/PhamePost.php index f87a37e7a4..a9525e0be7 100644 --- a/src/applications/phame/storage/PhamePost.php +++ b/src/applications/phame/storage/PhamePost.php @@ -200,8 +200,9 @@ final class PhamePost extends PhameDAO } public function getPolicy($capability) { - // Draft posts are visible only to the author. Published posts are visible - // to whoever the blog is visible to. + // Draft and archived posts are visible only to the author and other + // users who can edit the blog. Published posts are visible to whoever + // the blog is visible to. switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: From 301750f6e692ac1549ebd61135f9d32b041cfc49 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 7 Jul 2017 16:33:45 -0700 Subject: [PATCH 7/7] Add an after-purchase hook to subscriptions in Phortune Summary: Ref T12681. We need this to update the "paid until" window on support pacts. (Instance billing doesn't use this because everything just checks if you have unpaid invoices, nothing actually happens when you pay them.) Test Plan: See D18187. Reviewers: chad, amckinley Reviewed By: chad Maniphest Tasks: T12681 Differential Revision: https://secure.phabricator.com/D18188 --- .../phortune/product/PhortuneSubscriptionProduct.php | 5 +++-- .../phortune/storage/PhortuneSubscription.php | 9 +++++++++ .../subscription/PhortuneSubscriptionImplementation.php | 8 ++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/applications/phortune/product/PhortuneSubscriptionProduct.php b/src/applications/phortune/product/PhortuneSubscriptionProduct.php index b63cc7c21c..85eb2999c7 100644 --- a/src/applications/phortune/product/PhortuneSubscriptionProduct.php +++ b/src/applications/phortune/product/PhortuneSubscriptionProduct.php @@ -50,8 +50,9 @@ final class PhortuneSubscriptionProduct public function didPurchaseProduct( PhortuneProduct $product, PhortunePurchase $purchase) { - // TODO: Callback the subscription. - return; + return $this->getSubscription()->didPurchaseProduct( + $product, + $purchase); } public function didRefundProduct( diff --git a/src/applications/phortune/storage/PhortuneSubscription.php b/src/applications/phortune/storage/PhortuneSubscription.php index cc839adbea..a996dbf5d2 100644 --- a/src/applications/phortune/storage/PhortuneSubscription.php +++ b/src/applications/phortune/storage/PhortuneSubscription.php @@ -232,6 +232,15 @@ final class PhortuneSubscription extends PhortuneDAO $purchase); } + public function didPurchaseProduct( + PhortuneProduct $product, + PhortunePurchase $purchase) { + return $this->getImplementation()->didPurchaseProduct( + $this, + $product, + $purchase); + } + /* -( PhabricatorPolicyInterface )----------------------------------------- */ diff --git a/src/applications/phortune/subscription/PhortuneSubscriptionImplementation.php b/src/applications/phortune/subscription/PhortuneSubscriptionImplementation.php index f8cbc21155..a337551c8d 100644 --- a/src/applications/phortune/subscription/PhortuneSubscriptionImplementation.php +++ b/src/applications/phortune/subscription/PhortuneSubscriptionImplementation.php @@ -48,4 +48,12 @@ abstract class PhortuneSubscriptionImplementation extends Phobject { PhortunePurchase $purchase) { return null; } + + public function didPurchaseProduct( + PhortuneSubscription $subscription, + PhortuneProduct $product, + PhortunePurchase $purchase) { + return null; + } + }