1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52: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,30 +64,38 @@ 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(
id(new PhabricatorActionView())
->setName(pht('Uninstall'))
->setIcon('delete')
->setHref(
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Uninstall'))
->setIcon('delete')
->setHref(
$this->getApplicationURI(get_class($selected).'/uninstall/'))
);
);
} else {
return id(new PhabricatorActionListView())
->setUser($user)
->addAction(
id(new PhabricatorActionView())
->setName(pht('Install'))
->setIcon('new')
->setHref(
$this->getApplicationURI(get_class($selected).'/install/'))
);
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Install'))
->setIcon('new')
->setHref(
$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/');
}
$dialog = id(new AphrontDialogView())
->setUser($user)
->addCancelButton('/applications/view/'.$this->application);
if ($this->action == 'install') {
if ($selected->canUninstall()) {
$dialog->setTitle('Confirmation')
->appendChild(
'Install '. $selected->getName(). ' application ?'
)
->addSubmitButton('Install');
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle('Confirmation')
->appendChild(
'Install '. $selected->getName(). ' application ?'
)
->addSubmitButton('Install')
->addCancelButton('/applications/view/'.$this->application);
} else {
$dialog->setTitle('Information')
->appendChild('You cannot install a installed application.');
}
} else {
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle('Confirmation')
->appendChild(
'Really Uninstall '. $selected->getName(). ' application ?'
)
->addSubmitButton('Uninstall')
->addCancelButton('/applications/view/'.$this->application);
if ($selected->canUninstall()) {
$dialog->setTitle('Confirmation')
->appendChild(
'Really Uninstall '. $selected->getName(). ' 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);
}