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

Disabled Uninstall state for essential applications

Summary: Disabled Uninstall state for essential applications of Phabricator. Information provided why they cannot uninstall these applications. Also take care of users trying to install an application which cannot be uninstalled by editing the URI.

Test Plan: Manually tested

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4743
This commit is contained in:
Afaque Hussain 2013-01-30 13:32:32 -08:00 committed by epriestley
parent 363f292fd8
commit 2703a2e997
2 changed files with 54 additions and 36 deletions

View file

@ -64,12 +64,12 @@ final class PhabricatorApplicationDetailViewController
private function buildActionView( private function buildActionView(
PhabricatorUser $user, PhabricatorApplication $selected) { PhabricatorUser $user, PhabricatorApplication $selected) {
$view = id(new PhabricatorActionListView())
->setUser($user);
if ($selected->canUninstall()) { if ($selected->canUninstall()) {
if ($selected->isInstalled()) { if ($selected->isInstalled()) {
$view->addAction(
return id(new PhabricatorActionListView())
->setUser($user)
->addAction(
id(new PhabricatorActionView()) id(new PhabricatorActionView())
->setName(pht('Uninstall')) ->setName(pht('Uninstall'))
->setIcon('delete') ->setIcon('delete')
@ -77,9 +77,7 @@ final class PhabricatorApplicationDetailViewController
$this->getApplicationURI(get_class($selected).'/uninstall/')) $this->getApplicationURI(get_class($selected).'/uninstall/'))
); );
} else { } else {
return id(new PhabricatorActionListView()) $view->addAction(
->setUser($user)
->addAction(
id(new PhabricatorActionView()) id(new PhabricatorActionView())
->setName(pht('Install')) ->setName(pht('Install'))
->setIcon('new') ->setIcon('new')
@ -87,7 +85,17 @@ final class PhabricatorApplicationDetailViewController
$this->getApplicationURI(get_class($selected).'/install/')) $this->getApplicationURI(get_class($selected).'/install/'))
); );
} }
} else {
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Uninstall'))
->setIcon('delete')
->setDisabled(true)
->setHref(
$this->getApplicationURI(get_class($selected).'/uninstall/'))
);
} }
return $view;
} }
} }

View file

@ -17,7 +17,7 @@ final class PhabricatorApplicationUninstallController
$selected = PhabricatorApplication::getByClass($this->application); $selected = PhabricatorApplication::getByClass($this->application);
if (!$selected || !$selected->canUninstall()) { if (!$selected) {
return new Aphront404Response(); return new Aphront404Response();
} }
@ -26,27 +26,37 @@ final class PhabricatorApplicationUninstallController
return id(new AphrontRedirectResponse())->setURI('/applications/'); return id(new AphrontRedirectResponse())->setURI('/applications/');
} }
if ($this->action == 'install') {
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
->setUser($user) ->setUser($user)
->setTitle('Confirmation') ->addCancelButton('/applications/view/'.$this->application);
if ($this->action == 'install') {
if ($selected->canUninstall()) {
$dialog->setTitle('Confirmation')
->appendChild( ->appendChild(
'Install '. $selected->getName(). ' application ?' 'Install '. $selected->getName(). ' application ?'
) )
->addSubmitButton('Install') ->addSubmitButton('Install');
->addCancelButton('/applications/view/'.$this->application);
} else { } else {
$dialog = id(new AphrontDialogView()) $dialog->setTitle('Information')
->setUser($user) ->appendChild('You cannot install a installed application.');
->setTitle('Confirmation') }
} else {
if ($selected->canUninstall()) {
$dialog->setTitle('Confirmation')
->appendChild( ->appendChild(
'Really Uninstall '. $selected->getName(). ' application ?' 'Really Uninstall '. $selected->getName(). ' application ?'
) )
->addSubmitButton('Uninstall') ->addSubmitButton('Uninstall');
->addCancelButton('/applications/view/'.$this->application); } else {
$dialog->setTitle('Information')
->appendChild(
'This application cannot be uninstalled,
because it is required for Phabricator to work.'
);
}
} }
return id(new AphrontDialogResponse())->setDialog($dialog); return id(new AphrontDialogResponse())->setDialog($dialog);
} }