Skip to content
Snippets Groups Projects
Commit d9b4f5cc authored by Norman Kämper-Leymann's avatar Norman Kämper-Leymann Committed by Fran Garcia-Linares
Browse files

Issue #3489204 by leymannx: Make stuck migrations message configurable

parent 079f3a52
No related branches found
Tags 8.x-1.1-beta2
1 merge request!5#3489204 Make stuck migrations message configurable
......@@ -62,7 +62,7 @@ function migration_notify_cron() {
}
}
$message = t('There are migrations stuck on the site.');
$message = $config->get('stuck_message') ?? t('There are migrations stuck on the site.');
$sent = 0;
if ($config->get('slack')) {
......
......@@ -112,7 +112,7 @@ class MigrationNotifySettingsForm extends ConfigFormBase {
$stuck = $this->helper->checkStuck();
if ($stuck) {
$message = $this->t('There are stuck migrations.');
$message = $config->get('stuck_message') ?? $this->t('There are migrations stuck on the site.');
$this->messenger->addMessage($message, 'warning');
}
else {
......@@ -202,6 +202,18 @@ class MigrationNotifySettingsForm extends ConfigFormBase {
];
}
$form['notification_messages'] = [
'#markup' => '<hr /><h3>' . $this->t('Notification messages') . '</h3>',
];
$form['stuck_message'] = [
'#type' => 'textfield',
'#required' => TRUE,
'#title' => $this->t('Stuck message'),
'#description' => $this->t('The message to be sent when there are stuck migrations.'),
'#default_value' => $config->get('stuck_message') ?? $this->t('There are migrations stuck on the site.'),
];
$form['actions']['#type'] = 'actions';
if ($stuck) {
$form['actions']['notify_now'] = [
......@@ -275,9 +287,10 @@ class MigrationNotifySettingsForm extends ConfigFormBase {
$this->helper->saveState($stuck);
$message = $this->t('There are migrations stuck on the site.');
$config = $this->config('migration_notify.settings');
$message = $config->get('stuck_message') ?? $this->t('There are migrations stuck on the site.');
if ($config->get('slack')) {
if ($this->notifier->notifySlack($message)) {
$this->messenger->addMessage($this->t('Slack: Message was successfully sent.'));
......@@ -316,6 +329,7 @@ class MigrationNotifySettingsForm extends ConfigFormBase {
$email = $form_state->getValue('email');
$email_to = $form_state->getValue('email_to');
$slack = $form_state->getValue('slack');
$message = $form_state->getValue('stuck_message');
$this->config('migration_notify.settings')
->set('cron', $cron)
......@@ -323,6 +337,7 @@ class MigrationNotifySettingsForm extends ConfigFormBase {
->set('slack', $slack)
->set('email', $email)
->set('email_to', $email_to)
->set('stuck_message', $message)
->save();
}
......
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