Skip to content

Commit 8ec987d

Browse files
Nick Pellegrinoepriestley
authored andcommitted
Button to ignore setup issues + refractoring
Summary: T2381 Test Plan: Click on the ignore link in /config/issue/ and respond to the dialog box. Also, test uninstalling and reinstalling an application in the web UI (to verify that refractoring didn't break anything). Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2381 Differential Revision: https://secure.phabricator.com/D5234
1 parent 457b91f commit 8ec987d

File tree

7 files changed

+122
-41
lines changed

7 files changed

+122
-41
lines changed

src/__phutil_library_map__.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@
791791
'PhabricatorConfigEntryDAO' => 'applications/config/storage/PhabricatorConfigEntryDAO.php',
792792
'PhabricatorConfigFileSource' => 'infrastructure/env/PhabricatorConfigFileSource.php',
793793
'PhabricatorConfigGroupController' => 'applications/config/controller/PhabricatorConfigGroupController.php',
794+
'PhabricatorConfigIgnoreController' => 'applications/config/controller/PhabricatorConfigIgnoreController.php',
794795
'PhabricatorConfigIssueListController' => 'applications/config/controller/PhabricatorConfigIssueListController.php',
795796
'PhabricatorConfigIssueViewController' => 'applications/config/controller/PhabricatorConfigIssueViewController.php',
796797
'PhabricatorConfigJSON' => 'applications/config/json/PhabricatorConfigJSON.php',
@@ -2305,6 +2306,7 @@
23052306
'PhabricatorConfigEntryDAO' => 'PhabricatorLiskDAO',
23062307
'PhabricatorConfigFileSource' => 'PhabricatorConfigProxySource',
23072308
'PhabricatorConfigGroupController' => 'PhabricatorConfigController',
2309+
'PhabricatorConfigIgnoreController' => 'PhabricatorApplicationsController',
23082310
'PhabricatorConfigIssueListController' => 'PhabricatorConfigController',
23092311
'PhabricatorConfigIssueViewController' => 'PhabricatorConfigController',
23102312
'PhabricatorConfigListController' => 'PhabricatorConfigController',

src/applications/config/application/PhabricatorApplicationConfig.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public function getRoutes() {
2929
'all/' => 'PhabricatorConfigAllController',
3030
'edit/(?P<key>[\w\.\-]+)/' => 'PhabricatorConfigEditController',
3131
'group/(?P<key>[^/]+)/' => 'PhabricatorConfigGroupController',
32+
'(?P<verb>ignore|unignore)/(?P<key>[^/]+)/'
33+
=> 'PhabricatorConfigIgnoreController',
3234
'issue/' => array(
3335
'' => 'PhabricatorConfigIssueListController',
3436
'(?P<key>[^/]+)/' => 'PhabricatorConfigIssueViewController',
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
final class PhabricatorConfigIgnoreController
4+
extends PhabricatorApplicationsController {
5+
6+
private $verb;
7+
private $issue;
8+
9+
public function willProcessRequest(array $data) {
10+
$this->verb = $data['verb'];
11+
$this->issue = $data['key'];
12+
}
13+
14+
public function processRequest() {
15+
$request = $this->getRequest();
16+
$issue_uri = $this->getApplicationURI('issue');
17+
18+
if ($request->isDialogFormPost()) {
19+
$this->manageApplication();
20+
return id(new AphrontRedirectResponse())->setURI($issue_uri);
21+
}
22+
23+
// User just clicked the link, so show them the dialog.
24+
if ($this->verb == 'ignore') {
25+
$title = pht('Really ignore this setup issue?');
26+
$submit_title = pht('Ignore');
27+
} else if ($this->verb == 'unignore') {
28+
$title = pht('Really unignore this setup issue?');
29+
$submit_title = pht('Unignore');
30+
} else {
31+
throw new Exception('Unrecognized verb: ' . $this->verb);
32+
}
33+
$dialog = new AphrontDialogView();
34+
$dialog->setTitle($title)
35+
->setUser($request->getUser())
36+
->addSubmitButton($submit_title)
37+
->addCancelButton($issue_uri);
38+
39+
return id(new AphrontDialogResponse())->setDialog($dialog);
40+
}
41+
42+
public function manageApplication() {
43+
$key = 'config.ignore-issues';
44+
$config_entry = PhabricatorConfigEntry::loadConfigEntry($key);
45+
$list = $config_entry->getValue();
46+
47+
if (isset($list[$this->issue])) {
48+
unset($list[$this->issue]);
49+
} else {
50+
$list[$this->issue] = true;
51+
}
52+
53+
PhabricatorConfigEditor::storeNewValue(
54+
$config_entry, $list, $this->getRequest());
55+
}
56+
57+
}

src/applications/config/controller/PhabricatorConfigIssueListController.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,21 @@ private function buildIssueList(array $issues) {
6060
->addAttribute($issue->getSummary());
6161
if (!$issue->getIsIgnored()) {
6262
$item->addIcon('warning', pht('Setup Warning'));
63+
$link = javelin_tag(
64+
'a',
65+
array('href' => '/config/ignore/'.$issue->getIssueKey().'/',
66+
'sigil' => 'workflow'),
67+
pht('Ignore'));
68+
$item->addAttribute($link);
6369
$list->addItem($item);
6470
} else {
6571
$item->addIcon('none', pht('Ignored'));
72+
$link = javelin_tag(
73+
'a',
74+
array('href' => '/config/unignore/'.$issue->getIssueKey().'/',
75+
'sigil' => 'workflow'),
76+
pht('Unignore'));
77+
$item->addAttribute($link);
6678
$ignored_items[] = $item;
6779
}
6880
}

src/applications/config/editor/PhabricatorConfigEditor.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,28 @@ protected function didApplyTransactions(array $xactions) {
104104
PhabricatorSetupCheck::deleteSetupCheckCache();
105105
}
106106

107+
public static function storeNewValue(
108+
PhabricatorConfigEntry $config_entry, $value, AphrontRequest $request) {
109+
$xaction = id(new PhabricatorConfigTransaction())
110+
->setTransactionType(PhabricatorConfigTransaction::TYPE_EDIT)
111+
->setNewValue(
112+
array(
113+
'deleted' => false,
114+
'value' => $value
115+
));
116+
117+
$editor = id(new PhabricatorConfigEditor())
118+
->setActor($request->getUser())
119+
->setContinueOnNoEffect(true)
120+
->setContentSource(
121+
PhabricatorContentSource::newForSource(
122+
PhabricatorContentSource::SOURCE_WEB,
123+
array(
124+
'ip' => $request->getRemoteAddr(),
125+
)));
126+
127+
128+
$editor->applyTransactions($config_entry, array($xaction));
129+
}
130+
107131
}

src/applications/config/storage/PhabricatorConfigEntry.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,20 @@ public function generatePHID() {
2323
PhabricatorPHIDConstants::PHID_TYPE_CONF);
2424
}
2525

26+
public static function loadConfigEntry($key) {
27+
$config_entry = id(new PhabricatorConfigEntry())
28+
->loadOneWhere(
29+
'configKey = %s AND namespace = %s',
30+
$key,
31+
'default');
32+
33+
if (!$config_entry) {
34+
$config_entry = id(new PhabricatorConfigEntry())
35+
->setConfigKey($key)
36+
->setNamespace('default');
37+
}
38+
39+
return $config_entry;
40+
}
41+
2642
}

src/applications/meta/controller/PhabricatorApplicationUninstallController.php

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -61,50 +61,18 @@ public function processRequest() {
6161

6262
public function manageApplication() {
6363
$key = 'phabricator.uninstalled-applications';
64+
$config_entry = PhabricatorConfigEntry::loadConfigEntry($key);
65+
$list = $config_entry->getValue();
66+
$uninstalled = PhabricatorEnv::getEnvConfig($key);
6467

65-
$config_entry = id(new PhabricatorConfigEntry())
66-
->loadOneWhere(
67-
'configKey = %s AND namespace = %s',
68-
$key,
69-
'default');
70-
71-
if (!$config_entry) {
72-
$config_entry = id(new PhabricatorConfigEntry())
73-
->setConfigKey($key)
74-
->setNamespace('default');
75-
}
76-
77-
$list = $config_entry->getValue();
78-
79-
$uninstalled = PhabricatorEnv::getEnvConfig($key);
80-
81-
if ($uninstalled[$this->application]) {
82-
unset($list[$this->application]);
83-
} else {
68+
if ($uninstalled[$this->application]) {
69+
unset($list[$this->application]);
70+
} else {
8471
$list[$this->application] = true;
85-
}
86-
87-
$xaction = id(new PhabricatorConfigTransaction())
88-
->setTransactionType(PhabricatorConfigTransaction::TYPE_EDIT)
89-
->setNewValue(
90-
array(
91-
'deleted' => false,
92-
'value' => $list
93-
));
94-
95-
$editor = id(new PhabricatorConfigEditor())
96-
->setActor($this->getRequest()->getUser())
97-
->setContinueOnNoEffect(true)
98-
->setContentSource(
99-
PhabricatorContentSource::newForSource(
100-
PhabricatorContentSource::SOURCE_WEB,
101-
array(
102-
'ip' => $this->getRequest()->getRemoteAddr(),
103-
)));
104-
105-
106-
$editor->applyTransactions($config_entry, array($xaction));
72+
}
10773

74+
PhabricatorConfigEditor::storeNewValue(
75+
$config_entry, $list, $this->getRequest());
10876
}
10977

11078
}

0 commit comments

Comments
 (0)