From 9bbce8de42ae6e59d476d9771232f6c45734f627 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 10 Apr 2013 14:52:20 -0700 Subject: [PATCH] Fix some beta/install Application issues Summary: Currently, we give you an "Install" button for Beta apps even when "phabricator.show-beta-applications" is disabled. This is unclear. Instead, disable the button and tell the user about the config when it is clicked. Arguably, we should restructure this so you can selectively install "Beta" apps without setting the config, but almost all the beta apps are terrible so just make things consistent for now. Test Plan: Tried to install a beta app without beta apps enabled. Reviewers: btrahan, chad Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D5652 --- ...ricatorApplicationDetailViewController.php | 23 ++++++++------ ...bricatorApplicationUninstallController.php | 30 ++++++++++++++----- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/applications/meta/controller/PhabricatorApplicationDetailViewController.php b/src/applications/meta/controller/PhabricatorApplicationDetailViewController.php index ef72d41f80..2e4d1cb3a2 100644 --- a/src/applications/meta/controller/PhabricatorApplicationDetailViewController.php +++ b/src/applications/meta/controller/PhabricatorApplicationDetailViewController.php @@ -36,7 +36,6 @@ final class PhabricatorApplicationDetailViewController if ($selected->isInstalled()) { $status_tag->setName(pht('Installed')); $status_tag->setBackgroundColor(PhabricatorTagView::COLOR_GREEN); - } else { $status_tag->setName(pht('Uninstalled')); $status_tag->setBackgroundColor(PhabricatorTagView::COLOR_RED); @@ -50,7 +49,6 @@ final class PhabricatorApplicationDetailViewController $header->addTag($beta_tag); } - $header->addTag($status_tag); $properties = $this->buildPropertyView($selected); @@ -93,13 +91,20 @@ final class PhabricatorApplicationDetailViewController ->setHref( $this->getApplicationURI(get_class($selected).'/uninstall/'))); } else { - $view->addAction( - id(new PhabricatorActionView()) - ->setName(pht('Install')) - ->setIcon('new') - ->setWorkflow(true) - ->setHref( - $this->getApplicationURI(get_class($selected).'/install/'))); + $action = id(new PhabricatorActionView()) + ->setName(pht('Install')) + ->setIcon('new') + ->setWorkflow(true) + ->setHref( + $this->getApplicationURI(get_class($selected).'/install/')); + + $beta_enabled = PhabricatorEnv::getEnvConfig( + 'phabricator.show-beta-applications'); + if ($selected->isBeta() && !$beta_enabled) { + $action->setDisabled(true); + } + + $view->addAction($action); } } else { $view->addAction( diff --git a/src/applications/meta/controller/PhabricatorApplicationUninstallController.php b/src/applications/meta/controller/PhabricatorApplicationUninstallController.php index 2bee35714b..7c480ad81e 100644 --- a/src/applications/meta/controller/PhabricatorApplicationUninstallController.php +++ b/src/applications/meta/controller/PhabricatorApplicationUninstallController.php @@ -23,31 +23,45 @@ final class PhabricatorApplicationUninstallController $view_uri = $this->getApplicationURI('view/'.$this->application); - if ($request->isDialogFormPost()) { - $this->manageApplication(); - return id(new AphrontRedirectResponse())->setURI($view_uri); - } + $beta_enabled = PhabricatorEnv::getEnvConfig( + 'phabricator.show-beta-applications'); $dialog = id(new AphrontDialogView()) ->setUser($user) ->addCancelButton($view_uri); + if ($selected->isBeta() && !$beta_enabled) { + $dialog + ->setTitle(pht('Beta Applications Not Enabled')) + ->appendChild( + pht( + 'To manage beta applications, enable them by setting %s in your '. + 'Phabricator configuration.', + phutil_tag('tt', array(), 'phabricator.show-beta-applications'))); + return id(new AphrontDialogResponse())->setDialog($dialog); + } + + if ($request->isDialogFormPost()) { + $this->manageApplication(); + return id(new AphrontRedirectResponse())->setURI($view_uri); + } + if ($this->action == 'install') { if ($selected->canUninstall()) { $dialog->setTitle('Confirmation') ->appendChild( - 'Install '. $selected->getName(). ' application ?') + 'Install '. $selected->getName(). ' application?') ->addSubmitButton('Install'); } else { $dialog->setTitle('Information') - ->appendChild('You cannot install a installed application.'); + ->appendChild('You cannot install an installed application.'); } } else { if ($selected->canUninstall()) { $dialog->setTitle('Confirmation') ->appendChild( - 'Really Uninstall '. $selected->getName(). ' application ?') + 'Really Uninstall '. $selected->getName(). ' application?') ->addSubmitButton('Uninstall'); } else { $dialog->setTitle('Information') @@ -65,7 +79,7 @@ final class PhabricatorApplicationUninstallController $list = $config_entry->getValue(); $uninstalled = PhabricatorEnv::getEnvConfig($key); - if ($uninstalled[$this->application]) { + if (isset($uninstalled[$this->application])) { unset($list[$this->application]); } else { $list[$this->application] = true;