Allow configuration options to be locked

Summary: Some config shouldn't reasonably be edited from the web interface because it immediately torpedoes the install if you make a mistake. Block edits to "locked" config.

Test Plan: Tried to edit locked config, got denied. Viewed locked config on edit and list screens.

Reviewers: codeblock, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2255

Differential Revision: https://secure.phabricator.com/D4320
This commit is contained in:
epriestley
2013-01-02 14:02:43 -08:00
parent db21319b39
commit 9cef013def
4 changed files with 40 additions and 8 deletions

View File

@@ -59,7 +59,7 @@ final class PhabricatorConfigEditController
$e_value = null;
$errors = array();
if ($request->isFormPost()) {
if ($request->isFormPost() && !$option->getLocked()) {
$result = $this->readRequest(
$option,
@@ -100,6 +100,15 @@ final class PhabricatorConfigEditController
$error_view = id(new AphrontErrorView())
->setTitle(pht('You broke everything!'))
->setErrors($errors);
} else if ($option->getLocked()) {
$msg = pht(
"This configuration is locked and can not be edited from the web ".
"interface.");
$error_view = id(new AphrontErrorView())
->setTitle(pht('Configuration Locked'))
->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
->appendChild('<p>'.phutil_escape_html($msg).'</p>');
}
$control = $this->renderControl(
@@ -124,11 +133,15 @@ final class PhabricatorConfigEditController
id(new AphrontFormMarkupControl())
->setLabel(pht('Description'))
->setValue($description))
->appendChild($control)
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($done_uri)
->setValue(pht('Save Config Entry')));
->appendChild($control);
if (!$option->getLocked()) {
$form
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($done_uri)
->setValue(pht('Save Config Entry')));
}
$examples = $this->renderExamples($option);
if ($examples) {
@@ -329,6 +342,10 @@ final class PhabricatorConfigEditController
->setValue($display_value)
->setName('value');
if ($option->getLocked()) {
$control->setDisabled(true);
}
return $control;
}