mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-18 01:38:39 +01:00
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
This commit is contained in:
parent
457b91f6cb
commit
8ec987dd2f
7 changed files with 122 additions and 41 deletions
|
@ -791,6 +791,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorConfigEntryDAO' => 'applications/config/storage/PhabricatorConfigEntryDAO.php',
|
'PhabricatorConfigEntryDAO' => 'applications/config/storage/PhabricatorConfigEntryDAO.php',
|
||||||
'PhabricatorConfigFileSource' => 'infrastructure/env/PhabricatorConfigFileSource.php',
|
'PhabricatorConfigFileSource' => 'infrastructure/env/PhabricatorConfigFileSource.php',
|
||||||
'PhabricatorConfigGroupController' => 'applications/config/controller/PhabricatorConfigGroupController.php',
|
'PhabricatorConfigGroupController' => 'applications/config/controller/PhabricatorConfigGroupController.php',
|
||||||
|
'PhabricatorConfigIgnoreController' => 'applications/config/controller/PhabricatorConfigIgnoreController.php',
|
||||||
'PhabricatorConfigIssueListController' => 'applications/config/controller/PhabricatorConfigIssueListController.php',
|
'PhabricatorConfigIssueListController' => 'applications/config/controller/PhabricatorConfigIssueListController.php',
|
||||||
'PhabricatorConfigIssueViewController' => 'applications/config/controller/PhabricatorConfigIssueViewController.php',
|
'PhabricatorConfigIssueViewController' => 'applications/config/controller/PhabricatorConfigIssueViewController.php',
|
||||||
'PhabricatorConfigJSON' => 'applications/config/json/PhabricatorConfigJSON.php',
|
'PhabricatorConfigJSON' => 'applications/config/json/PhabricatorConfigJSON.php',
|
||||||
|
@ -2305,6 +2306,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorConfigEntryDAO' => 'PhabricatorLiskDAO',
|
'PhabricatorConfigEntryDAO' => 'PhabricatorLiskDAO',
|
||||||
'PhabricatorConfigFileSource' => 'PhabricatorConfigProxySource',
|
'PhabricatorConfigFileSource' => 'PhabricatorConfigProxySource',
|
||||||
'PhabricatorConfigGroupController' => 'PhabricatorConfigController',
|
'PhabricatorConfigGroupController' => 'PhabricatorConfigController',
|
||||||
|
'PhabricatorConfigIgnoreController' => 'PhabricatorApplicationsController',
|
||||||
'PhabricatorConfigIssueListController' => 'PhabricatorConfigController',
|
'PhabricatorConfigIssueListController' => 'PhabricatorConfigController',
|
||||||
'PhabricatorConfigIssueViewController' => 'PhabricatorConfigController',
|
'PhabricatorConfigIssueViewController' => 'PhabricatorConfigController',
|
||||||
'PhabricatorConfigListController' => 'PhabricatorConfigController',
|
'PhabricatorConfigListController' => 'PhabricatorConfigController',
|
||||||
|
|
|
@ -29,6 +29,8 @@ final class PhabricatorApplicationConfig extends PhabricatorApplication {
|
||||||
'all/' => 'PhabricatorConfigAllController',
|
'all/' => 'PhabricatorConfigAllController',
|
||||||
'edit/(?P<key>[\w\.\-]+)/' => 'PhabricatorConfigEditController',
|
'edit/(?P<key>[\w\.\-]+)/' => 'PhabricatorConfigEditController',
|
||||||
'group/(?P<key>[^/]+)/' => 'PhabricatorConfigGroupController',
|
'group/(?P<key>[^/]+)/' => 'PhabricatorConfigGroupController',
|
||||||
|
'(?P<verb>ignore|unignore)/(?P<key>[^/]+)/'
|
||||||
|
=> 'PhabricatorConfigIgnoreController',
|
||||||
'issue/' => array(
|
'issue/' => array(
|
||||||
'' => 'PhabricatorConfigIssueListController',
|
'' => 'PhabricatorConfigIssueListController',
|
||||||
'(?P<key>[^/]+)/' => 'PhabricatorConfigIssueViewController',
|
'(?P<key>[^/]+)/' => 'PhabricatorConfigIssueViewController',
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorConfigIgnoreController
|
||||||
|
extends PhabricatorApplicationsController {
|
||||||
|
|
||||||
|
private $verb;
|
||||||
|
private $issue;
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->verb = $data['verb'];
|
||||||
|
$this->issue = $data['key'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$issue_uri = $this->getApplicationURI('issue');
|
||||||
|
|
||||||
|
if ($request->isDialogFormPost()) {
|
||||||
|
$this->manageApplication();
|
||||||
|
return id(new AphrontRedirectResponse())->setURI($issue_uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
// User just clicked the link, so show them the dialog.
|
||||||
|
if ($this->verb == 'ignore') {
|
||||||
|
$title = pht('Really ignore this setup issue?');
|
||||||
|
$submit_title = pht('Ignore');
|
||||||
|
} else if ($this->verb == 'unignore') {
|
||||||
|
$title = pht('Really unignore this setup issue?');
|
||||||
|
$submit_title = pht('Unignore');
|
||||||
|
} else {
|
||||||
|
throw new Exception('Unrecognized verb: ' . $this->verb);
|
||||||
|
}
|
||||||
|
$dialog = new AphrontDialogView();
|
||||||
|
$dialog->setTitle($title)
|
||||||
|
->setUser($request->getUser())
|
||||||
|
->addSubmitButton($submit_title)
|
||||||
|
->addCancelButton($issue_uri);
|
||||||
|
|
||||||
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function manageApplication() {
|
||||||
|
$key = 'config.ignore-issues';
|
||||||
|
$config_entry = PhabricatorConfigEntry::loadConfigEntry($key);
|
||||||
|
$list = $config_entry->getValue();
|
||||||
|
|
||||||
|
if (isset($list[$this->issue])) {
|
||||||
|
unset($list[$this->issue]);
|
||||||
|
} else {
|
||||||
|
$list[$this->issue] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PhabricatorConfigEditor::storeNewValue(
|
||||||
|
$config_entry, $list, $this->getRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -60,9 +60,21 @@ final class PhabricatorConfigIssueListController
|
||||||
->addAttribute($issue->getSummary());
|
->addAttribute($issue->getSummary());
|
||||||
if (!$issue->getIsIgnored()) {
|
if (!$issue->getIsIgnored()) {
|
||||||
$item->addIcon('warning', pht('Setup Warning'));
|
$item->addIcon('warning', pht('Setup Warning'));
|
||||||
|
$link = javelin_tag(
|
||||||
|
'a',
|
||||||
|
array('href' => '/config/ignore/'.$issue->getIssueKey().'/',
|
||||||
|
'sigil' => 'workflow'),
|
||||||
|
pht('Ignore'));
|
||||||
|
$item->addAttribute($link);
|
||||||
$list->addItem($item);
|
$list->addItem($item);
|
||||||
} else {
|
} else {
|
||||||
$item->addIcon('none', pht('Ignored'));
|
$item->addIcon('none', pht('Ignored'));
|
||||||
|
$link = javelin_tag(
|
||||||
|
'a',
|
||||||
|
array('href' => '/config/unignore/'.$issue->getIssueKey().'/',
|
||||||
|
'sigil' => 'workflow'),
|
||||||
|
pht('Unignore'));
|
||||||
|
$item->addAttribute($link);
|
||||||
$ignored_items[] = $item;
|
$ignored_items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,4 +104,28 @@ final class PhabricatorConfigEditor
|
||||||
PhabricatorSetupCheck::deleteSetupCheckCache();
|
PhabricatorSetupCheck::deleteSetupCheckCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function storeNewValue(
|
||||||
|
PhabricatorConfigEntry $config_entry, $value, AphrontRequest $request) {
|
||||||
|
$xaction = id(new PhabricatorConfigTransaction())
|
||||||
|
->setTransactionType(PhabricatorConfigTransaction::TYPE_EDIT)
|
||||||
|
->setNewValue(
|
||||||
|
array(
|
||||||
|
'deleted' => false,
|
||||||
|
'value' => $value
|
||||||
|
));
|
||||||
|
|
||||||
|
$editor = id(new PhabricatorConfigEditor())
|
||||||
|
->setActor($request->getUser())
|
||||||
|
->setContinueOnNoEffect(true)
|
||||||
|
->setContentSource(
|
||||||
|
PhabricatorContentSource::newForSource(
|
||||||
|
PhabricatorContentSource::SOURCE_WEB,
|
||||||
|
array(
|
||||||
|
'ip' => $request->getRemoteAddr(),
|
||||||
|
)));
|
||||||
|
|
||||||
|
|
||||||
|
$editor->applyTransactions($config_entry, array($xaction));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,4 +23,20 @@ final class PhabricatorConfigEntry extends PhabricatorConfigEntryDAO {
|
||||||
PhabricatorPHIDConstants::PHID_TYPE_CONF);
|
PhabricatorPHIDConstants::PHID_TYPE_CONF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function loadConfigEntry($key) {
|
||||||
|
$config_entry = id(new PhabricatorConfigEntry())
|
||||||
|
->loadOneWhere(
|
||||||
|
'configKey = %s AND namespace = %s',
|
||||||
|
$key,
|
||||||
|
'default');
|
||||||
|
|
||||||
|
if (!$config_entry) {
|
||||||
|
$config_entry = id(new PhabricatorConfigEntry())
|
||||||
|
->setConfigKey($key)
|
||||||
|
->setNamespace('default');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $config_entry;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,21 +61,8 @@ final class PhabricatorApplicationUninstallController
|
||||||
|
|
||||||
public function manageApplication() {
|
public function manageApplication() {
|
||||||
$key = 'phabricator.uninstalled-applications';
|
$key = 'phabricator.uninstalled-applications';
|
||||||
|
$config_entry = PhabricatorConfigEntry::loadConfigEntry($key);
|
||||||
$config_entry = id(new PhabricatorConfigEntry())
|
|
||||||
->loadOneWhere(
|
|
||||||
'configKey = %s AND namespace = %s',
|
|
||||||
$key,
|
|
||||||
'default');
|
|
||||||
|
|
||||||
if (!$config_entry) {
|
|
||||||
$config_entry = id(new PhabricatorConfigEntry())
|
|
||||||
->setConfigKey($key)
|
|
||||||
->setNamespace('default');
|
|
||||||
}
|
|
||||||
|
|
||||||
$list = $config_entry->getValue();
|
$list = $config_entry->getValue();
|
||||||
|
|
||||||
$uninstalled = PhabricatorEnv::getEnvConfig($key);
|
$uninstalled = PhabricatorEnv::getEnvConfig($key);
|
||||||
|
|
||||||
if ($uninstalled[$this->application]) {
|
if ($uninstalled[$this->application]) {
|
||||||
|
@ -84,27 +71,8 @@ final class PhabricatorApplicationUninstallController
|
||||||
$list[$this->application] = true;
|
$list[$this->application] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$xaction = id(new PhabricatorConfigTransaction())
|
PhabricatorConfigEditor::storeNewValue(
|
||||||
->setTransactionType(PhabricatorConfigTransaction::TYPE_EDIT)
|
$config_entry, $list, $this->getRequest());
|
||||||
->setNewValue(
|
|
||||||
array(
|
|
||||||
'deleted' => false,
|
|
||||||
'value' => $list
|
|
||||||
));
|
|
||||||
|
|
||||||
$editor = id(new PhabricatorConfigEditor())
|
|
||||||
->setActor($this->getRequest()->getUser())
|
|
||||||
->setContinueOnNoEffect(true)
|
|
||||||
->setContentSource(
|
|
||||||
PhabricatorContentSource::newForSource(
|
|
||||||
PhabricatorContentSource::SOURCE_WEB,
|
|
||||||
array(
|
|
||||||
'ip' => $this->getRequest()->getRemoteAddr(),
|
|
||||||
)));
|
|
||||||
|
|
||||||
|
|
||||||
$editor->applyTransactions($config_entry, array($xaction));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue