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

Issue #3486614 by eiriksm: Expose PR instructions in team settings

parent f63dc3c4
No related branches found
No related tags found
1 merge request!72Fix up code
Pipeline #334775 passed with warnings
......@@ -144,6 +144,18 @@ final class TeamSettingsForm extends FormBase {
'#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['pr_instructions'] = [
'#type' => 'details',
'#title' => $this->t('Pull request instructions'),
'#open' => TRUE,
];
$form['pr_instructions']['pr_instructions'] = [
'#type' => 'textarea',
'#title' => $this->t('Pull request instructions'),
'#default_value' => $team->getPullRequestInstructions() ?: '',
'#description' => $this->t('Specify a message to use on pull requests across projects.<br><br>
If you specify a value here, this will be used for all pull requests for all of your projects. This message can be overridden per project.'),
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
......@@ -191,6 +203,7 @@ final class TeamSettingsForm extends FormBase {
->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'))
->set(TeamNode::PR_INSTRUCTIONS_FIELD, $form_state->getValue('pr_instructions'))
->save();
}
......
......@@ -25,6 +25,7 @@ class TeamNode extends Node {
const BILLING_ENABLED_FIELD = 'field_send_receipts';
const BILLING_EMAIL_FIELD = 'field_billing_email';
const ENVIRONMENT_VARIABLES_FIELD = 'field_environment_variables';
const PR_INSTRUCTIONS_FIELD = 'field_pull_request_template';
/**
* Helper to return if the team has access or not.
......@@ -308,10 +309,10 @@ class TeamNode extends Node {
* Getter for this field.
*/
public function getPullRequestInstructions() : ?string {
if (!$this->hasField('field_pull_request_template') || $this->get('field_pull_request_template')->isEmpty()) {
if (!$this->hasField(self::PR_INSTRUCTIONS_FIELD) || $this->get(self::PR_INSTRUCTIONS_FIELD)->isEmpty()) {
return FALSE;
}
return $this->get('field_pull_request_template')->first()->getString();
return $this->get(self::PR_INSTRUCTIONS_FIELD)->first()->getString();
}
/**
......
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