@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+40 -8
+23 -6
src/applications/config/controller/PhabricatorConfigEditController.php
··· 59 59 60 60 $e_value = null; 61 61 $errors = array(); 62 - if ($request->isFormPost()) { 62 + if ($request->isFormPost() && !$option->getLocked()) { 63 63 64 64 $result = $this->readRequest( 65 65 $option, ··· 100 100 $error_view = id(new AphrontErrorView()) 101 101 ->setTitle(pht('You broke everything!')) 102 102 ->setErrors($errors); 103 + } else if ($option->getLocked()) { 104 + $msg = pht( 105 + "This configuration is locked and can not be edited from the web ". 106 + "interface."); 107 + 108 + $error_view = id(new AphrontErrorView()) 109 + ->setTitle(pht('Configuration Locked')) 110 + ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) 111 + ->appendChild('<p>'.phutil_escape_html($msg).'</p>'); 103 112 } 104 113 105 114 $control = $this->renderControl( ··· 124 133 id(new AphrontFormMarkupControl()) 125 134 ->setLabel(pht('Description')) 126 135 ->setValue($description)) 127 - ->appendChild($control) 128 - ->appendChild( 129 - id(new AphrontFormSubmitControl()) 130 - ->addCancelButton($done_uri) 131 - ->setValue(pht('Save Config Entry'))); 136 + ->appendChild($control); 137 + 138 + if (!$option->getLocked()) { 139 + $form 140 + ->appendChild( 141 + id(new AphrontFormSubmitControl()) 142 + ->addCancelButton($done_uri) 143 + ->setValue(pht('Save Config Entry'))); 144 + } 132 145 133 146 $examples = $this->renderExamples($option); 134 147 if ($examples) { ··· 328 341 ->setError($e_value) 329 342 ->setValue($display_value) 330 343 ->setName('value'); 344 + 345 + if ($option->getLocked()) { 346 + $control->setDisabled(true); 347 + } 331 348 332 349 return $control; 333 350 }
+4
src/applications/config/controller/PhabricatorConfigGroupController.php
··· 91 91 $item->addIcon('edit-grey', pht('Default')); 92 92 } 93 93 94 + if ($option->getLocked()) { 95 + $item->addIcon('lock', pht('Locked')); 96 + } 97 + 94 98 $list->addItem($item); 95 99 } 96 100
+10
src/applications/config/option/PhabricatorConfigOption.php
··· 12 12 private $options; 13 13 private $group; 14 14 private $examples; 15 + private $locked; 16 + 17 + public function setLocked($locked) { 18 + $this->locked = $locked; 19 + return $this; 20 + } 21 + 22 + public function getLocked() { 23 + return $this->locked; 24 + } 15 25 16 26 public function addExample($value, $description) { 17 27 $this->examples[] = array($value, $description);
+3 -2
src/applications/config/option/PhabricatorCoreConfigOptions.php
··· 66 66 "traditional UI strings like 'Submit', you can set this flag to ". 67 67 "disable most of the jokes and easter eggs.")), 68 68 $this->newOption('storage.default-namespace', 'string', 'phabricator') 69 + // NOTE: Lock this, since editing it from the web torpedoes an install. 70 + ->setLocked(true) 69 71 ->setSummary( 70 72 pht("The namespace that Phabricator databases should use.")) 71 73 ->setDescription( ··· 75 77 "named 'phabricator_differential' by default. You can change ". 76 78 "this namespace if you want. Normally, you should not do this ". 77 79 "unless you are developing Phabricator and using namespaces to ". 78 - "separate multiple sandbox datasets.")) 79 - ->addExample('phabricator', 'Valid Setting'), 80 + "separate multiple sandbox datasets.")), 80 81 $this->newOption('environment.append-paths', 'list<string>', null) 81 82 ->setSummary( 82 83 pht("These paths get appended to your \$PATH envrionment variable."))