1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +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(
PhabricatorUser $user, PhabricatorApplication $selected) {
$view = id(new PhabricatorActionListView())
->setUser($user);
if ($selected->canUninstall()) {
if ($selected->isInstalled()) {
return id(new PhabricatorActionListView())
->setUser($user)
->addAction(
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Uninstall'))
->setIcon('delete')
@ -77,9 +77,7 @@ final class PhabricatorApplicationDetailViewController
$this->getApplicationURI(get_class($selected).'/uninstall/'))
);
} else {
return id(new PhabricatorActionListView())
->setUser($user)
->addAction(
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Install'))
->setIcon('new')
@ -87,7 +85,17 @@ final class PhabricatorApplicationDetailViewController
$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);
if (!$selected || !$selected->canUninstall()) {
if (!$selected) {
return new Aphront404Response();
}
@ -26,27 +26,37 @@ final class PhabricatorApplicationUninstallController
return id(new AphrontRedirectResponse())->setURI('/applications/');
}
if ($this->action == 'install') {
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle('Confirmation')
->addCancelButton('/applications/view/'.$this->application);
if ($this->action == 'install') {
if ($selected->canUninstall()) {
$dialog->setTitle('Confirmation')
->appendChild(
'Install '. $selected->getName(). ' application ?'
)
->addSubmitButton('Install')
->addCancelButton('/applications/view/'.$this->application);
->addSubmitButton('Install');
} else {
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle('Confirmation')
$dialog->setTitle('Information')
->appendChild('You cannot install a installed application.');
}
} else {
if ($selected->canUninstall()) {
$dialog->setTitle('Confirmation')
->appendChild(
'Really Uninstall '. $selected->getName(). ' application ?'
)
->addSubmitButton('Uninstall')
->addCancelButton('/applications/view/'.$this->application);
->addSubmitButton('Uninstall');
} else {
$dialog->setTitle('Information')
->appendChild(
'This application cannot be uninstalled,
because it is required for Phabricator to work.'
);
}
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}