diff --git a/core/themes/seven/css/components/system-status-report.css b/core/themes/seven/css/components/system-status-report.css index 2bab073..a14bc1e 100644 --- a/core/themes/seven/css/components/system-status-report.css +++ b/core/themes/seven/css/components/system-status-report.css @@ -59,10 +59,15 @@ display: inline-block; max-width: 80%; padding-left: 10px; + position: relative; } .system-status-general-info__item-details h3 { margin-bottom: 0; } +.system-status-general-info__run-cron { + position: inherit; + margin-top: .5em; +} @media screen and (min-width: 48em) { .system-status-general-info__items { display: flex; @@ -82,6 +87,15 @@ .system-status-general-info__item:nth-child(5) { border-left: 1px solid #ccc; } + .system-status-general-info__run-cron { + position: absolute; + top: 1em; + right: 1em; + margin-top: 0; + } + [dir="rtl"] .system-status-general-info__run-cron { + left: 1em; + } } @media screen and (min-width: 60em) { .system-status-general-info__item-icon { diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index 751ea68..b97ebc6 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -148,6 +148,9 @@ function seven_preprocess_maintenance_page(&$variables) { * Implements hook_preprocess_status_report(). */ function seven_preprocess_status_report(&$variables) { + + $variables = _seven_alter_cron_description($variables); + $severities = [ REQUIREMENT_INFO => [ 'title' => t('Info'), @@ -158,11 +161,11 @@ function seven_preprocess_status_report(&$variables) { 'status' => 'ok', ], REQUIREMENT_WARNING => [ - 'title' => t('Warning'), + 'title' => t('Warnings Found'), 'status' => 'warning', ], REQUIREMENT_ERROR => [ - 'title' => t('Error'), + 'title' => t('Errors Found'), 'status' => 'error', ], ]; @@ -289,3 +292,44 @@ function seven_form_node_form_alter(&$form, FormStateInterface $form_state) { $form['revision_information']['#type'] = 'container'; $form['revision_information']['#group'] = 'meta'; } + +/** + * Remove the cron button from the cron.description render array + * and add it as separate variable. + * + * @todo Only one sanity check is performed. Might be prudent to also + * return unchanged if either index has a count > 1 + */ +function _seven_alter_cron_description($variables) { + // find the Cron element + $cron = array_filter($variables['requirements'], function($requirement) { + return _seven_get_variable_index_by_title_string($requirement, 'title', 'Cron maintenance tasks'); + }); + $cron_index = current(array_keys($cron)); + + // Within Cron element, find the Run Cron link + $existing_run_cron_link = array_filter($variables['requirements'][$cron_index]['description'][0], function($render_element) { + return _seven_get_variable_index_by_title_string($render_element, '#title', 'Run cron'); + }); + $run_cron_index = current(array_keys($existing_run_cron_link)); + + // For sanity: if we don't have successful indexes return $variables unchanged + if (FALSE === $cron_index || FALSE === $run_cron_index) { + return $variables; + } + + // Remove the existing link that is nested in description and provide a new element + $new_link = $variables['requirements'][$cron_index]['description'][0][$run_cron_index]; + unset($variables['requirements'][$cron_index]['description'][0][$run_cron_index]); + $variables['requirements'][$cron_index]['run_cron'] = $new_link; + + return $variables; +} + +function _seven_get_variable_index_by_title_string($var, $key, $string) { + if (!array_key_exists($key, $var) || !method_exists($var[$key], 'getUntranslatedString')) { + return FALSE; + } + + return $var[$key]->getUntranslatedString() == $string; +} diff --git a/core/themes/seven/templates/status-report.html.twig b/core/themes/seven/templates/status-report.html.twig index e1797e1..7452c53 100644 --- a/core/themes/seven/templates/status-report.html.twig +++ b/core/themes/seven/templates/status-report.html.twig @@ -48,7 +48,7 @@ {% trans %} {{ warning }} Warning - {% plural error %} + {% plural warning %} {{ warning }} Warnings {% endtrans %}
@@ -86,6 +86,9 @@

Last Cron Run

{{ cron.value }} + {% if cron.run_cron %} +
{{ cron.run_cron }}
+ {% endif %} {% if cron.description %}
{{ cron.description }}
{% endif %}