1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-25 22:18:19 +01:00

Update Config app for handleRequest

Summary: Update all found callsites in Config.

Test Plan: Check setup issues, databases, edit a value, remove a warning, everything I could click on.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8628

Differential Revision: https://secure.phabricator.com/D13727
This commit is contained in:
Chad Little 2015-07-27 09:06:26 -07:00
parent 6fb43305be
commit 564aa2c4ba
11 changed files with 58 additions and 90 deletions

View file

@ -3,9 +3,8 @@
final class PhabricatorConfigAllController final class PhabricatorConfigAllController
extends PhabricatorConfigController { extends PhabricatorConfigController {
public function processRequest() { public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest(); $viewer = $request->getViewer();
$user = $request->getUser();
$db_values = id(new PhabricatorConfigEntry()) $db_values = id(new PhabricatorConfigEntry())
->loadAllWhere('namespace = %s', 'default'); ->loadAllWhere('namespace = %s', 'default');

View file

@ -3,9 +3,8 @@
final class PhabricatorConfigDatabaseIssueController final class PhabricatorConfigDatabaseIssueController
extends PhabricatorConfigDatabaseController { extends PhabricatorConfigDatabaseController {
public function processRequest() { public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest(); $viewer = $request->getViewer();
$viewer = $request->getUser();
$query = $this->buildSchemaQuery(); $query = $this->buildSchemaQuery();

View file

@ -8,16 +8,12 @@ final class PhabricatorConfigDatabaseStatusController
private $column; private $column;
private $key; private $key;
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->database = idx($data, 'database'); $viewer = $request->getViewer();
$this->table = idx($data, 'table'); $this->database = $request->getURIData('database');
$this->column = idx($data, 'column'); $this->table = $request->getURIData('table');
$this->key = idx($data, 'key'); $this->column = $request->getURIData('column');
} $this->key = $request->getURIData('key');
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$query = $this->buildSchemaQuery(); $query = $this->buildSchemaQuery();

View file

@ -3,25 +3,19 @@
final class PhabricatorConfigEditController final class PhabricatorConfigEditController
extends PhabricatorConfigController { extends PhabricatorConfigController {
private $key; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { $key = $request->getURIData('key');
$this->key = $data['key'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$options = PhabricatorApplicationConfigOptions::loadAllOptions(); $options = PhabricatorApplicationConfigOptions::loadAllOptions();
if (empty($options[$this->key])) { if (empty($options[$key])) {
$ancient = PhabricatorExtraConfigSetupCheck::getAncientConfig(); $ancient = PhabricatorExtraConfigSetupCheck::getAncientConfig();
if (isset($ancient[$this->key])) { if (isset($ancient[$key])) {
$desc = pht( $desc = pht(
"This configuration has been removed. You can safely delete ". "This configuration has been removed. You can safely delete ".
"it.\n\n%s", "it.\n\n%s",
$ancient[$this->key]); $ancient[$key]);
} else { } else {
$desc = pht( $desc = pht(
'This configuration option is unknown. It may be misspelled, '. 'This configuration option is unknown. It may be misspelled, '.
@ -32,14 +26,14 @@ final class PhabricatorConfigEditController
// longer exists. Allow it to be edited so it can be reviewed and // longer exists. Allow it to be edited so it can be reviewed and
// deleted. // deleted.
$option = id(new PhabricatorConfigOption()) $option = id(new PhabricatorConfigOption())
->setKey($this->key) ->setKey($key)
->setType('wild') ->setType('wild')
->setDefault(null) ->setDefault(null)
->setDescription($desc); ->setDescription($desc);
$group = null; $group = null;
$group_uri = $this->getApplicationURI(); $group_uri = $this->getApplicationURI();
} else { } else {
$option = $options[$this->key]; $option = $options[$key];
$group = $option->getGroup(); $group = $option->getGroup();
$group_uri = $this->getApplicationURI('group/'.$group->getKey().'/'); $group_uri = $this->getApplicationURI('group/'.$group->getKey().'/');
} }
@ -57,11 +51,11 @@ final class PhabricatorConfigEditController
$config_entry = id(new PhabricatorConfigEntry()) $config_entry = id(new PhabricatorConfigEntry())
->loadOneWhere( ->loadOneWhere(
'configKey = %s AND namespace = %s', 'configKey = %s AND namespace = %s',
$this->key, $key,
'default'); 'default');
if (!$config_entry) { if (!$config_entry) {
$config_entry = id(new PhabricatorConfigEntry()) $config_entry = id(new PhabricatorConfigEntry())
->setConfigKey($this->key) ->setConfigKey($key)
->setNamespace('default') ->setNamespace('default')
->setIsDeleted(true); ->setIsDeleted(true);
$config_entry->setPHID($config_entry->generatePHID()); $config_entry->setPHID($config_entry->generatePHID());
@ -81,7 +75,7 @@ final class PhabricatorConfigEditController
if (!$errors) { if (!$errors) {
$editor = id(new PhabricatorConfigEditor()) $editor = id(new PhabricatorConfigEditor())
->setActor($user) ->setActor($viewer)
->setContinueOnNoEffect(true) ->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request); ->setContentSourceFromRequest($request);
@ -138,7 +132,7 @@ final class PhabricatorConfigEditController
} }
$engine = new PhabricatorMarkupEngine(); $engine = new PhabricatorMarkupEngine();
$engine->setViewer($user); $engine->setViewer($viewer);
$engine->addObject($option, 'description'); $engine->addObject($option, 'description');
$engine->process(); $engine->process();
$description = phutil_tag( $description = phutil_tag(
@ -149,7 +143,7 @@ final class PhabricatorConfigEditController
$engine->getOutput($option, 'description')); $engine->getOutput($option, 'description'));
$form $form
->setUser($user) ->setUser($viewer)
->addHiddenInput('issue', $request->getStr('issue')) ->addHiddenInput('issue', $request->getStr('issue'))
->appendChild( ->appendChild(
id(new AphrontFormMarkupControl()) id(new AphrontFormMarkupControl())
@ -194,7 +188,7 @@ final class PhabricatorConfigEditController
->setValue($this->renderDefaults($option, $config_entry))); ->setValue($this->renderDefaults($option, $config_entry)));
} }
$title = pht('Edit %s', $this->key); $title = pht('Edit %s', $key);
$short = pht('Edit'); $short = pht('Edit');
$form_box = id(new PHUIObjectBoxView()) $form_box = id(new PHUIObjectBoxView())
@ -212,7 +206,7 @@ final class PhabricatorConfigEditController
$crumbs->addTextCrumb($group->getName(), $group_uri); $crumbs->addTextCrumb($group->getName(), $group_uri);
} }
$crumbs->addTextCrumb($this->key, '/config/edit/'.$this->key); $crumbs->addTextCrumb($key, '/config/edit/'.$key);
$timeline = $this->buildTransactionTimeline( $timeline = $this->buildTransactionTimeline(
$config_entry, $config_entry,

View file

@ -3,18 +3,12 @@
final class PhabricatorConfigGroupController final class PhabricatorConfigGroupController
extends PhabricatorConfigController { extends PhabricatorConfigController {
private $groupKey; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { $group_key = $request->getURIData('key');
$this->groupKey = $data['key'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$groups = PhabricatorApplicationConfigOptions::loadAll(); $groups = PhabricatorApplicationConfigOptions::loadAll();
$options = idx($groups, $this->groupKey); $options = idx($groups, $group_key);
if (!$options) { if (!$options) {
return new Aphront404Response(); return new Aphront404Response();
} }

View file

@ -3,12 +3,12 @@
final class PhabricatorConfigHistoryController final class PhabricatorConfigHistoryController
extends PhabricatorConfigController { extends PhabricatorConfigController {
public function processRequest() { public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest(); $viewer = $request->getViewer();
$user = $request->getUser(); $id = $request->getURIData('id');
$xactions = id(new PhabricatorConfigTransactionQuery()) $xactions = id(new PhabricatorConfigTransactionQuery())
->setViewer($user) ->setViewer($viewer)
->needComments(true) ->needComments(true)
->execute(); ->execute();
@ -19,7 +19,7 @@ final class PhabricatorConfigHistoryController
$view = $xaction->getApplicationTransactionViewObject(); $view = $xaction->getApplicationTransactionViewObject();
$timeline = $view $timeline = $view
->setUser($user) ->setUser($viewer)
->setTransactions($xactions) ->setTransactions($xactions)
->setRenderAsFeed(true) ->setRenderAsFeed(true)
->setObjectPHID(PhabricatorPHIDConstants::PHID_VOID); ->setObjectPHID(PhabricatorPHIDConstants::PHID_VOID);

View file

@ -3,38 +3,33 @@
final class PhabricatorConfigIgnoreController final class PhabricatorConfigIgnoreController
extends PhabricatorConfigController { extends PhabricatorConfigController {
private $verb; public function handleRequest(AphrontRequest $request) {
private $issue; $viewer = $request->getViewer();
$issue = $request->getURIData('key');
$verb = $request->getURIData('verb');
public function willProcessRequest(array $data) { $issue_uri = $this->getApplicationURI('issue/'.$issue.'/');
$this->verb = $data['verb'];
$this->issue = $data['key'];
}
public function processRequest() {
$request = $this->getRequest();
$issue_uri = $this->getApplicationURI('issue/'.$this->issue.'/');
if ($request->isDialogFormPost()) { if ($request->isDialogFormPost()) {
$this->manageApplication(); $this->manageApplication($issue);
return id(new AphrontRedirectResponse())->setURI($issue_uri); return id(new AphrontRedirectResponse())->setURI($issue_uri);
} }
if ($this->verb == 'ignore') { if ($verb == 'ignore') {
$title = pht('Really ignore this setup issue?'); $title = pht('Really ignore this setup issue?');
$submit_title = pht('Ignore'); $submit_title = pht('Ignore');
$body = pht( $body = pht(
"You can ignore an issue if you don't want to fix it, or plan to ". "You can ignore an issue if you don't want to fix it, or plan to ".
"fix it later. Ignored issues won't appear on every page but will ". "fix it later. Ignored issues won't appear on every page but will ".
"still be shown in the list of open issues."); "still be shown in the list of open issues.");
} else if ($this->verb == 'unignore') { } else if ($verb == 'unignore') {
$title = pht('Unignore this setup issue?'); $title = pht('Unignore this setup issue?');
$submit_title = pht('Unignore'); $submit_title = pht('Unignore');
$body = pht( $body = pht(
'This issue will no longer be suppressed, and will return to its '. 'This issue will no longer be suppressed, and will return to its '.
'rightful place as a global setup warning.'); 'rightful place as a global setup warning.');
} else { } else {
throw new Exception(pht('Unrecognized verb: %s', $this->verb)); throw new Exception(pht('Unrecognized verb: %s', $verb));
} }
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
@ -47,15 +42,15 @@ final class PhabricatorConfigIgnoreController
return id(new AphrontDialogResponse())->setDialog($dialog); return id(new AphrontDialogResponse())->setDialog($dialog);
} }
public function manageApplication() { public function manageApplication($issue) {
$key = 'config.ignore-issues'; $key = 'config.ignore-issues';
$config_entry = PhabricatorConfigEntry::loadConfigEntry($key); $config_entry = PhabricatorConfigEntry::loadConfigEntry($key);
$list = $config_entry->getValue(); $list = $config_entry->getValue();
if (isset($list[$this->issue])) { if (isset($list[$issue])) {
unset($list[$this->issue]); unset($list[$issue]);
} else { } else {
$list[$this->issue] = true; $list[$issue] = true;
} }
PhabricatorConfigEditor::storeNewValue( PhabricatorConfigEditor::storeNewValue(

View file

@ -3,9 +3,8 @@
final class PhabricatorConfigIssueListController final class PhabricatorConfigIssueListController
extends PhabricatorConfigController { extends PhabricatorConfigController {
public function processRequest() { public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest(); $viewer = $request->getViewer();
$user = $request->getUser();
$nav = $this->buildSideNavView(); $nav = $this->buildSideNavView();
$nav->selectFilter('issue/'); $nav->selectFilter('issue/');

View file

@ -3,21 +3,15 @@
final class PhabricatorConfigIssueViewController final class PhabricatorConfigIssueViewController
extends PhabricatorConfigController { extends PhabricatorConfigController {
private $issueKey; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { $issue_key = $request->getURIData('key');
$this->issueKey = $data['key'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$issues = PhabricatorSetupCheck::runAllChecks(); $issues = PhabricatorSetupCheck::runAllChecks();
PhabricatorSetupCheck::setOpenSetupIssueKeys( PhabricatorSetupCheck::setOpenSetupIssueKeys(
PhabricatorSetupCheck::getUnignoredIssueKeys($issues)); PhabricatorSetupCheck::getUnignoredIssueKeys($issues));
if (empty($issues[$this->issueKey])) { if (empty($issues[$issue_key])) {
$content = id(new PHUIInfoView()) $content = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NOTICE) ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
->setTitle(pht('Issue Resolved')) ->setTitle(pht('Issue Resolved'))
@ -31,7 +25,7 @@ final class PhabricatorConfigIssueViewController
pht('Return to Open Issue List'))); pht('Return to Open Issue List')));
$title = pht('Resolved Issue'); $title = pht('Resolved Issue');
} else { } else {
$issue = $issues[$this->issueKey]; $issue = $issues[$issue_key];
$content = $this->renderIssue($issue); $content = $this->renderIssue($issue);
$title = $issue->getShortName(); $title = $issue->getShortName();
} }

View file

@ -3,9 +3,8 @@
final class PhabricatorConfigListController final class PhabricatorConfigListController
extends PhabricatorConfigController { extends PhabricatorConfigController {
public function processRequest() { public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest(); $viewer = $request->getViewer();
$user = $request->getUser();
$nav = $this->buildSideNavView(); $nav = $this->buildSideNavView();
$nav->selectFilter('/'); $nav->selectFilter('/');

View file

@ -3,9 +3,8 @@
final class PhabricatorConfigWelcomeController final class PhabricatorConfigWelcomeController
extends PhabricatorConfigController { extends PhabricatorConfigController {
public function processRequest() { public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest(); $viewer = $request->getViewer();
$viewer = $request->getUser();
$nav = $this->buildSideNavView(); $nav = $this->buildSideNavView();
$nav->selectFilter('welcome/'); $nav->selectFilter('welcome/');