mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
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:
parent
db21319b39
commit
9cef013def
4 changed files with 40 additions and 8 deletions
|
@ -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($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;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,6 +91,10 @@ final class PhabricatorConfigGroupController
|
|||
$item->addIcon('edit-grey', pht('Default'));
|
||||
}
|
||||
|
||||
if ($option->getLocked()) {
|
||||
$item->addIcon('lock', pht('Locked'));
|
||||
}
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,16 @@ final class PhabricatorConfigOption
|
|||
private $options;
|
||||
private $group;
|
||||
private $examples;
|
||||
private $locked;
|
||||
|
||||
public function setLocked($locked) {
|
||||
$this->locked = $locked;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLocked() {
|
||||
return $this->locked;
|
||||
}
|
||||
|
||||
public function addExample($value, $description) {
|
||||
$this->examples[] = array($value, $description);
|
||||
|
|
|
@ -66,6 +66,8 @@ final class PhabricatorCoreConfigOptions
|
|||
"traditional UI strings like 'Submit', you can set this flag to ".
|
||||
"disable most of the jokes and easter eggs.")),
|
||||
$this->newOption('storage.default-namespace', 'string', 'phabricator')
|
||||
// NOTE: Lock this, since editing it from the web torpedoes an install.
|
||||
->setLocked(true)
|
||||
->setSummary(
|
||||
pht("The namespace that Phabricator databases should use."))
|
||||
->setDescription(
|
||||
|
@ -75,8 +77,7 @@ final class PhabricatorCoreConfigOptions
|
|||
"named 'phabricator_differential' by default. You can change ".
|
||||
"this namespace if you want. Normally, you should not do this ".
|
||||
"unless you are developing Phabricator and using namespaces to ".
|
||||
"separate multiple sandbox datasets."))
|
||||
->addExample('phabricator', 'Valid Setting'),
|
||||
"separate multiple sandbox datasets.")),
|
||||
$this->newOption('environment.append-paths', 'list<string>', null)
|
||||
->setSummary(
|
||||
pht("These paths get appended to your \$PATH envrionment variable."))
|
||||
|
|
Loading…
Reference in a new issue