Differential D14054 Diff 33982 src/applications/config/controller/PhabricatorConfigEditController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/controller/PhabricatorConfigEditController.php
| Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | if ($errors) { | ||||
| $msg = $option->getLockedMessage(); | $msg = $option->getLockedMessage(); | ||||
| $error_view = id(new PHUIInfoView()) | $error_view = id(new PHUIInfoView()) | ||||
| ->setTitle(pht('Configuration Locked')) | ->setTitle(pht('Configuration Locked')) | ||||
| ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) | ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) | ||||
| ->appendChild(phutil_tag('p', array(), $msg)); | ->appendChild(phutil_tag('p', array(), $msg)); | ||||
| } | } | ||||
| if ($option->getHidden()) { | if ($option->getHidden() || $option->getLocked()) { | ||||
| $control = null; | $control = null; | ||||
| } else { | } else { | ||||
| $control = $this->renderControl( | $control = $this->renderControl( | ||||
| $option, | $option, | ||||
| $display_value, | $display_value, | ||||
| $e_value); | $e_value); | ||||
| } | } | ||||
| Show All 25 Lines | if ($group) { | ||||
| id(new AphrontFormMarkupControl()) | id(new AphrontFormMarkupControl()) | ||||
| ->setValue($extra)); | ->setValue($extra)); | ||||
| } | } | ||||
| } | } | ||||
| $form | $form | ||||
| ->appendChild($control); | ->appendChild($control); | ||||
| $submit_control = id(new AphrontFormSubmitControl()) | |||||
| ->addCancelButton($done_uri); | |||||
| if (!$option->getLocked()) { | if (!$option->getLocked()) { | ||||
| $submit_control->setValue(pht('Save Config Entry')); | $form->appendChild( | ||||
| id(new AphrontFormSubmitControl()) | |||||
| ->addCancelButton($done_uri) | |||||
| ->setValue(pht('Save Config Entry'))); | |||||
| } | } | ||||
| $form->appendChild($submit_control); | if (!$option->getHidden()) { | ||||
| $form->appendChild( | |||||
| id(new AphrontFormMarkupControl()) | |||||
| ->setLabel(pht('Current Configuration')) | |||||
| ->setValue($this->renderDefaults($option, $config_entry))); | |||||
| } | |||||
| $examples = $this->renderExamples($option); | $examples = $this->renderExamples($option); | ||||
| if ($examples) { | if ($examples) { | ||||
| $form->appendChild( | $form->appendChild( | ||||
| id(new AphrontFormMarkupControl()) | id(new AphrontFormMarkupControl()) | ||||
| ->setLabel(pht('Examples')) | ->setLabel(pht('Examples')) | ||||
| ->setValue($examples)); | ->setValue($examples)); | ||||
| } | } | ||||
| if (!$option->getHidden()) { | |||||
| $form->appendChild( | |||||
| id(new AphrontFormMarkupControl()) | |||||
| ->setLabel(pht('Default')) | |||||
| ->setValue($this->renderDefaults($option, $config_entry))); | |||||
| } | |||||
| $title = pht('Edit %s', $key); | $title = pht('Edit %s', $key); | ||||
| $short = pht('Edit'); | $short = pht('Edit'); | ||||
| $form_box = id(new PHUIObjectBoxView()) | $form_box = id(new PHUIObjectBoxView()) | ||||
| ->setHeaderText($title) | ->setHeaderText($title) | ||||
| ->setForm($form); | ->setForm($form); | ||||
| if ($error_view) { | if ($error_view) { | ||||
| ▲ Show 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | if ($option->isCustomType()) { | ||||
| $control = id(new AphrontFormTextAreaControl()) | $control = id(new AphrontFormTextAreaControl()) | ||||
| ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) | ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) | ||||
| ->setCustomClass('PhabricatorMonospaced') | ->setCustomClass('PhabricatorMonospaced') | ||||
| ->setCaption(pht('Enter value in JSON.')); | ->setCaption(pht('Enter value in JSON.')); | ||||
| break; | break; | ||||
| } | } | ||||
| $control | $control | ||||
| ->setLabel(pht('Value')) | ->setLabel(pht('Database Value')) | ||||
| ->setError($e_value) | ->setError($e_value) | ||||
| ->setValue($display_value) | ->setValue($display_value) | ||||
| ->setName('value'); | ->setName('value'); | ||||
| } | } | ||||
| if ($option->getLocked()) { | |||||
| $control->setDisabled(true); | |||||
| } | |||||
| return $control; | return $control; | ||||
| } | } | ||||
| private function renderExamples(PhabricatorConfigOption $option) { | private function renderExamples(PhabricatorConfigOption $option) { | ||||
| $examples = $option->getExamples(); | $examples = $option->getExamples(); | ||||
| if (!$examples) { | if (!$examples) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| Show All 37 Lines | private function renderDefaults( | ||||
| $stack = PhabricatorEnv::getConfigSourceStack(); | $stack = PhabricatorEnv::getConfigSourceStack(); | ||||
| $stack = $stack->getStack(); | $stack = $stack->getStack(); | ||||
| $table = array(); | $table = array(); | ||||
| $table[] = phutil_tag('tr', array('class' => 'column-labels'), array( | $table[] = phutil_tag('tr', array('class' => 'column-labels'), array( | ||||
| phutil_tag('th', array(), pht('Source')), | phutil_tag('th', array(), pht('Source')), | ||||
| phutil_tag('th', array(), pht('Value')), | phutil_tag('th', array(), pht('Value')), | ||||
| )); | )); | ||||
| $is_effective_value = true; | |||||
| foreach ($stack as $key => $source) { | foreach ($stack as $key => $source) { | ||||
| $row_classes = array( | |||||
| 'column-labels', | |||||
| ); | |||||
| $value = $source->getKeys( | $value = $source->getKeys( | ||||
| array( | array( | ||||
| $option->getKey(), | $option->getKey(), | ||||
| )); | )); | ||||
| if (!array_key_exists($option->getKey(), $value)) { | if (!array_key_exists($option->getKey(), $value)) { | ||||
| $value = phutil_tag('em', array(), pht('(empty)')); | $value = phutil_tag('em', array(), pht('(No Value Configured)')); | ||||
| } else { | } else { | ||||
| $value = $this->getDisplayValue( | $value = $this->getDisplayValue( | ||||
| $option, | $option, | ||||
| $entry, | $entry, | ||||
| $value[$option->getKey()]); | $value[$option->getKey()]); | ||||
| if ($is_effective_value) { | |||||
| $is_effective_value = false; | |||||
| $row_classes[] = 'config-options-effective-value'; | |||||
| } | |||||
| } | } | ||||
| $table[] = phutil_tag('tr', array('class' => 'column-labels'), array( | $table[] = phutil_tag( | ||||
| 'tr', | |||||
| array( | |||||
| 'class' => implode(' ', $row_classes), | |||||
| ), | |||||
| array( | |||||
| phutil_tag('th', array(), $source->getName()), | phutil_tag('th', array(), $source->getName()), | ||||
| phutil_tag('td', array(), $value), | phutil_tag('td', array(), $value), | ||||
| )); | )); | ||||
| } | } | ||||
| require_celerity_resource('config-options-css'); | require_celerity_resource('config-options-css'); | ||||
| return phutil_tag( | return phutil_tag( | ||||
| 'table', | 'table', | ||||
| array( | array( | ||||
| 'class' => 'config-option-table', | 'class' => 'config-option-table', | ||||
| ), | ), | ||||
| $table); | $table); | ||||
| } | } | ||||
| } | } | ||||