Skip to content
Snippets Groups Projects
Commit bb825e42 authored by Eirik Morland's avatar Eirik Morland
Browse files

Issue #3468161: Expose option to edit environment variables

parent 48396f88
No related branches found
No related tags found
1 merge request!69add field to form
Pipeline #254616 failed
......@@ -133,6 +133,17 @@ final class TeamSettingsForm extends FormBase {
],
],
];
$form['environment_vars'] = [
'#type' => 'details',
'#title' => $this->t('Environment variables'),
'#open' => TRUE,
];
$form['environment_vars']['environment_vars'] = [
'#type' => 'textarea',
'#title' => $this->t('Environment variables'),
'#default_value' => $team->getEnvironmentVariables() ? $team->get(TeamNode::ENVIRONMENT_VARIABLES_FIELD)->first()->getString() : '',
'#description' => $this->t('Please enter a list of environment variables that should be used when running updates.<br><br>If you use project specific variables, these will be merged and the project specific variables will take precedence.<br><br>Enter one variable per line in the format <code>VARIABLE=value</code>.'),
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
......@@ -179,6 +190,7 @@ final class TeamSettingsForm extends FormBase {
->set(TeamNode::NOTIFICATION_EMAILS_FIELD, $form_state->getValue('notification_emails'))
->set(TeamNode::NOTIFICATION_MAX_CONCURRENT_ENABLED_FIELD, $form_state->getValue('enable_email_notifications_concurrent'))
->set(TeamNode::NOTIFICATION_MAX_CONCURRENT_EMAILS_FIELD, $form_state->getValue('notification_emails_concurrent'))
->set(TeamNode::ENVIRONMENT_VARIABLES_FIELD, $form_state->getValue('environment_vars'))
->save();
}
......
......@@ -24,6 +24,7 @@ class TeamNode extends Node {
const NOTIFICATION_MAX_CONCURRENT_EMAILS_FIELD = 'field_max_concurrent_emails';
const BILLING_ENABLED_FIELD = 'field_send_receipts';
const BILLING_EMAIL_FIELD = 'field_billing_email';
const ENVIRONMENT_VARIABLES_FIELD = 'field_environment_variables';
/**
* Helper to return if the team has access or not.
......@@ -50,10 +51,10 @@ class TeamNode extends Node {
*/
public function getEnvironmentVariables() : array {
$variables = [];
if (!$this->hasField('field_environment_variables') || $this->get('field_environment_variables')->isEmpty()) {
if (!$this->hasField(self::ENVIRONMENT_VARIABLES_FIELD) || $this->get(self::ENVIRONMENT_VARIABLES_FIELD)->isEmpty()) {
return $variables;
}
$variables_string = $this->get('field_environment_variables')->first()->getString();
$variables_string = $this->get(self::ENVIRONMENT_VARIABLES_FIELD)->first()->getString();
$variables_string = trim($variables_string);
if (!$variables_string) {
return $variables;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment