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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user