Skip to content

Commit 2703a2e

Browse files
Afaque Hussainepriestley
Afaque Hussain
authored and
epriestley
committed
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
1 parent 363f292 commit 2703a2e

File tree

2 files changed

+55
-37
lines changed

2 files changed

+55
-37
lines changed

src/applications/meta/controller/PhabricatorApplicationDetailViewController.php

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,38 @@ private function buildPropertyView(PhabricatorApplication $selected) {
6464
private function buildActionView(
6565
PhabricatorUser $user, PhabricatorApplication $selected) {
6666

67+
$view = id(new PhabricatorActionListView())
68+
->setUser($user);
69+
6770
if ($selected->canUninstall()) {
6871
if ($selected->isInstalled()) {
69-
70-
return id(new PhabricatorActionListView())
71-
->setUser($user)
72-
->addAction(
73-
id(new PhabricatorActionView())
74-
->setName(pht('Uninstall'))
75-
->setIcon('delete')
76-
->setHref(
72+
$view->addAction(
73+
id(new PhabricatorActionView())
74+
->setName(pht('Uninstall'))
75+
->setIcon('delete')
76+
->setHref(
7777
$this->getApplicationURI(get_class($selected).'/uninstall/'))
78-
);
78+
);
7979
} else {
80-
return id(new PhabricatorActionListView())
81-
->setUser($user)
82-
->addAction(
83-
id(new PhabricatorActionView())
84-
->setName(pht('Install'))
85-
->setIcon('new')
86-
->setHref(
87-
$this->getApplicationURI(get_class($selected).'/install/'))
88-
);
80+
$view->addAction(
81+
id(new PhabricatorActionView())
82+
->setName(pht('Install'))
83+
->setIcon('new')
84+
->setHref(
85+
$this->getApplicationURI(get_class($selected).'/install/'))
86+
);
8987
}
88+
} else {
89+
$view->addAction(
90+
id(new PhabricatorActionView())
91+
->setName(pht('Uninstall'))
92+
->setIcon('delete')
93+
->setDisabled(true)
94+
->setHref(
95+
$this->getApplicationURI(get_class($selected).'/uninstall/'))
96+
);
9097
}
98+
return $view;
9199
}
92100

93101
}

src/applications/meta/controller/PhabricatorApplicationUninstallController.php

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function processRequest() {
1717

1818
$selected = PhabricatorApplication::getByClass($this->application);
1919

20-
if (!$selected || !$selected->canUninstall()) {
20+
if (!$selected) {
2121
return new Aphront404Response();
2222
}
2323

@@ -26,27 +26,37 @@ public function processRequest() {
2626
return id(new AphrontRedirectResponse())->setURI('/applications/');
2727
}
2828

29-
if ($this->action == 'install') {
29+
$dialog = id(new AphrontDialogView())
30+
->setUser($user)
31+
->addCancelButton('/applications/view/'.$this->application);
3032

31-
$dialog = id(new AphrontDialogView())
32-
->setUser($user)
33-
->setTitle('Confirmation')
34-
->appendChild(
35-
'Install '. $selected->getName(). ' application ?'
36-
)
37-
->addSubmitButton('Install')
38-
->addCancelButton('/applications/view/'.$this->application);
33+
if ($this->action == 'install') {
34+
if ($selected->canUninstall()) {
35+
$dialog->setTitle('Confirmation')
36+
->appendChild(
37+
'Install '. $selected->getName(). ' application ?'
38+
)
39+
->addSubmitButton('Install');
40+
41+
} else {
42+
$dialog->setTitle('Information')
43+
->appendChild('You cannot install a installed application.');
44+
}
3945
} else {
40-
$dialog = id(new AphrontDialogView())
41-
->setUser($user)
42-
->setTitle('Confirmation')
43-
->appendChild(
44-
'Really Uninstall '. $selected->getName(). ' application ?'
45-
)
46-
->addSubmitButton('Uninstall')
47-
->addCancelButton('/applications/view/'.$this->application);
46+
if ($selected->canUninstall()) {
47+
$dialog->setTitle('Confirmation')
48+
->appendChild(
49+
'Really Uninstall '. $selected->getName(). ' application ?'
50+
)
51+
->addSubmitButton('Uninstall');
52+
} else {
53+
$dialog->setTitle('Information')
54+
->appendChild(
55+
'This application cannot be uninstalled,
56+
because it is required for Phabricator to work.'
57+
);
58+
}
4859
}
49-
5060
return id(new AphrontDialogResponse())->setDialog($dialog);
5161
}
5262

0 commit comments

Comments
 (0)