1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-09 16:32: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:
Nick Pellegrino 2013-03-06 14:14:09 -08:00 committed by epriestley
parent 457b91f6cb
commit 8ec987dd2f
7 changed files with 122 additions and 41 deletions

View file

@ -791,6 +791,7 @@ phutil_register_library_map(array(
'PhabricatorConfigEntryDAO' => 'applications/config/storage/PhabricatorConfigEntryDAO.php',
'PhabricatorConfigFileSource' => 'infrastructure/env/PhabricatorConfigFileSource.php',
'PhabricatorConfigGroupController' => 'applications/config/controller/PhabricatorConfigGroupController.php',
'PhabricatorConfigIgnoreController' => 'applications/config/controller/PhabricatorConfigIgnoreController.php',
'PhabricatorConfigIssueListController' => 'applications/config/controller/PhabricatorConfigIssueListController.php',
'PhabricatorConfigIssueViewController' => 'applications/config/controller/PhabricatorConfigIssueViewController.php',
'PhabricatorConfigJSON' => 'applications/config/json/PhabricatorConfigJSON.php',
@ -2305,6 +2306,7 @@ phutil_register_library_map(array(
'PhabricatorConfigEntryDAO' => 'PhabricatorLiskDAO',
'PhabricatorConfigFileSource' => 'PhabricatorConfigProxySource',
'PhabricatorConfigGroupController' => 'PhabricatorConfigController',
'PhabricatorConfigIgnoreController' => 'PhabricatorApplicationsController',
'PhabricatorConfigIssueListController' => 'PhabricatorConfigController',
'PhabricatorConfigIssueViewController' => 'PhabricatorConfigController',
'PhabricatorConfigListController' => 'PhabricatorConfigController',

View file

@ -29,6 +29,8 @@ final class PhabricatorApplicationConfig extends PhabricatorApplication {
'all/' => 'PhabricatorConfigAllController',
'edit/(?P<key>[\w\.\-]+)/' => 'PhabricatorConfigEditController',
'group/(?P<key>[^/]+)/' => 'PhabricatorConfigGroupController',
'(?P<verb>ignore|unignore)/(?P<key>[^/]+)/'
=> 'PhabricatorConfigIgnoreController',
'issue/' => array(
'' => 'PhabricatorConfigIssueListController',
'(?P<key>[^/]+)/' => 'PhabricatorConfigIssueViewController',

View file

@ -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());
}
}

View file

@ -60,9 +60,21 @@ final class PhabricatorConfigIssueListController
->addAttribute($issue->getSummary());
if (!$issue->getIsIgnored()) {
$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);
} else {
$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;
}
}

View file

@ -104,4 +104,28 @@ final class PhabricatorConfigEditor
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));
}
}

View file

@ -23,4 +23,20 @@ final class PhabricatorConfigEntry extends PhabricatorConfigEntryDAO {
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;
}
}

View file

@ -61,50 +61,18 @@ final class PhabricatorApplicationUninstallController
public function manageApplication() {
$key = 'phabricator.uninstalled-applications';
$config_entry = PhabricatorConfigEntry::loadConfigEntry($key);
$list = $config_entry->getValue();
$uninstalled = PhabricatorEnv::getEnvConfig($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();
$uninstalled = PhabricatorEnv::getEnvConfig($key);
if ($uninstalled[$this->application]) {
unset($list[$this->application]);
} else {
if ($uninstalled[$this->application]) {
unset($list[$this->application]);
} else {
$list[$this->application] = true;
}
$xaction = id(new PhabricatorConfigTransaction())
->setTransactionType(PhabricatorConfigTransaction::TYPE_EDIT)
->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));
}
PhabricatorConfigEditor::storeNewValue(
$config_entry, $list, $this->getRequest());
}
}