Provide a block for running cron from a dashboard

Created on 17 December 2022, about 1 year ago
Updated 15 February 2024, 10 days ago

Problem/Motivation

As part of the Dashboard initiative 🌱 Enhance user experience with customizable dashboards Active one of the needs detected was the ability to run cron from the dashboard for admin users.

Would be great to have a block in the admin dashboard for running cron to make it more simple and intuitive for admin users..

Proposed resolution

As the dashboard concept is developed, provide the ability to run cron from a block in the dashboard.

Remaining tasks

  • Patch
  • Tests

User interface changes

  • New block available.

API changes

None.

Data model changes

None.

✨ Feature request
Status

RTBC

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated 1 minute ago

Created by

πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates : some issue and comment data are missing.

  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

    The block itself might need tests.

    1. +++ b/core/modules/system/src/Plugin/Block/CronStatusBlock.php
      @@ -0,0 +1,159 @@
      + * Provides a block to display 'Site branding' elements.
      

      Fix comment.

    2. +++ b/core/modules/system/src/Plugin/Block/CronStatusBlock.php
      @@ -0,0 +1,159 @@
      + *   forms = {
      + *     "settings_tray" = "Drupal\system\Form\SystemBrandingOffCanvasForm",
      + *   },
      

      This needs to be removed.

    3. +++ b/core/modules/system/src/Plugin/Block/CronStatusBlock.php
      @@ -0,0 +1,159 @@
      +    $cron_last = \Drupal::state()->get('system.cron_last');
      ...
      +      $cron_last = \Drupal::state()->get('install_time', 0);
      

      Inject state?

    4. +++ b/core/modules/system/src/Plugin/Block/CronStatusBlock.php
      @@ -0,0 +1,159 @@
      +    $request_time = \Drupal::time()->getRequestTime();
      

      Inject time()?

    5. +++ b/core/modules/system/src/Plugin/Block/CronStatusBlock.php
      @@ -0,0 +1,159 @@
      +    $summary = t('Last run @time ago', ['@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)]);
      

      Inject date.formatter?

    6. +++ b/core/modules/system/src/Plugin/Block/CronStatusBlock.php
      @@ -0,0 +1,159 @@
      +    $x['cron'] = [
      

      This needs to be $data, or to be removed.

    7. +++ b/core/modules/system/src/Plugin/Block/CronStatusBlock.php
      @@ -0,0 +1,159 @@
      +        '#title' => t('more information'),
      ...
      +        '#title' => t('Run cron'),
      

      We need StringTranslationTrait and $this->t()

    8. +++ b/core/modules/system/src/Plugin/Block/CronStatusBlock.php
      @@ -0,0 +1,159 @@
      +    return Cache::mergeTags(
      +      parent::getCacheTags(),
      +      $this->configFactory->get('system.cron')->getCacheTags()
      +    );
      

      We need CacheableMetadata->createFrom() to ensure we don't leave anything behind.

  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

    Discussed with @lauriii. Splitting the big status report template into smaller pieces it's useful no matter what happens with dashboards. They eventually might become sdc components. So it makes sense to propose that change in core already.

  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

    On second thoughts, we agreed that it's not that important atm, and we can avoid that for now. Probably by the time we plan to integrate this that might have been converted to SDC already.

  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid
  • Pipeline finished with Failed
    13 days ago
    Total: 186s
    #92929
  • Pipeline finished with Failed
    13 days ago
    Total: 1078s
    #92934
  • Pipeline finished with Failed
    13 days ago
    Total: 2939s
    #92951
  • Pipeline finished with Canceled
    13 days ago
    Total: 262s
    #93016
  • Pipeline finished with Running
    13 days ago
    #93021
  • Pipeline finished with Success
    13 days ago
    Total: 559s
    #93034
  • Status changed to Needs review 13 days ago
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    Update status.

  • Status changed to RTBC 12 days ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Tested this out by manually verifying the block appears in the block layout list
    Placed the block at the top of the content region.
    Verified it worked as expect

    CR reads well.

  • πŸ‡¬πŸ‡§United Kingdom catch

    Double checked in CronForm whether it includes the cron status/last stufff, and it does. This looks good to me.

Production build https://api.contrib.social 0.61.6-2-g546bc20