Verified Commit afdee270 authored by Dave Long's avatar Dave Long
Browse files

Issue #2502637 by bnjmnm, shumer, smustgrave, cilefen, Wim Leers, legolasbo,...

Issue #2502637 by bnjmnm, shumer, smustgrave, cilefen, Wim Leers, legolasbo, quietone, Xano, nikitagupta, DanielVeza, vegantriathlete, gaurav-mathur, priyanka.sahni, alexpott, dww, rkoller, dqd, swentel, eltermann, Alan D., ZenDoodles, David_Rothstein, sun, welly, pameeela: Disabled text formats can't be seen in the GUI
parent 1c218641
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -45,3 +45,11 @@ entity.filter_format.disable:
    _title: 'Disable text format'
  requirements:
    _entity_access: 'filter_format.disable'

entity.filter_format.enable:
  path: '/admin/config/content/formats/manage/{filter_format}/enable'
  defaults:
    _entity_form: 'filter_format.enable'
    _title: 'Enable text format'
  requirements:
    _entity_access: 'filter_format.enable'
+5 −0
Original line number Diff line number Diff line
@@ -85,6 +85,11 @@ public static function preRenderText($element) {
      $message = !$format ? 'Missing text format: %format.' : 'Disabled text format: %format.';
      static::logger('filter')->alert($message, ['%format' => $format_id]);
      $element['#markup'] = '';
      // Associate the disabled text format's cache tag, to ensure re-enabling
      // the text format invalidates the appropriate render cache items.
      if ($format !== NULL) {
        $element['#cache']['tags'] = Cache::mergeTags($element['#cache']['tags'] ?? [], $format->getCacheTags());
      }
      return $element;
    }

+5 −2
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\filter\Entity;

use Drupal\Component\Plugin\PluginInspectionInterface;

use Drupal\Core\Config\Action\Attribute\ActionMethod;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Entity\EntityWithPluginCollectionInterface;
@@ -30,7 +31,8 @@
 *     "form" = {
 *       "add" = "Drupal\filter\FilterFormatAddForm",
 *       "edit" = "Drupal\filter\FilterFormatEditForm",
 *       "disable" = "Drupal\filter\Form\FilterDisableForm"
 *       "disable" = "Drupal\filter\Form\FilterDisableForm",
 *       "enable" = "Drupal\filter\Form\FilterEnableForm",
 *     },
 *     "list_builder" = "Drupal\filter\FilterFormatListBuilder",
 *     "access" = "Drupal\filter\FilterFormatAccessControlHandler",
@@ -45,7 +47,8 @@
 *   },
 *   links = {
 *     "edit-form" = "/admin/config/content/formats/manage/{filter_format}",
 *     "disable" = "/admin/config/content/formats/manage/{filter_format}/disable"
 *     "disable" = "/admin/config/content/formats/manage/{filter_format}/disable",
 *     "enable" = "/admin/config/content/formats/manage/{filter_format}/enable",
 *   },
 *   config_export = {
 *     "name",
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ protected function checkAccess(EntityInterface $filter_format, $operation, Accou
      return AccessResult::forbidden();
    }

    if (in_array($operation, ['disable', 'update', 'view'])) {
    if (in_array($operation, ['disable', 'update', 'view', 'enable'])) {
      return parent::checkAccess($filter_format, $operation, $account);
    }

+18 −11
Original line number Diff line number Diff line
@@ -75,22 +75,13 @@ public function getFormId() {
    return 'filter_admin_overview';
  }

  /**
   * {@inheritdoc}
   */
  public function load() {
    // Only list enabled filters.
    return array_filter(parent::load(), function ($entity) {
      return $entity->status();
    });
  }

  /**
   * {@inheritdoc}
   */
  public function buildHeader() {
    $header['label'] = $this->t('Name');
    $header['roles'] = $this->t('Roles');
    $header['status'] = $this->t('Status');
    return $header + parent::buildHeader();
  }

@@ -124,7 +115,13 @@ public function buildRow(EntityInterface $entity) {
        '#context' => ['list_style' => 'comma-list'],
      ];
    }

    if ($entity->status()) {
      $status = $this->t('Enabled');
    }
    else {
      $status = $this->t('Disabled');
    }
    $row['status']['#markup'] = $status;
    return $row + parent::buildRow($entity);
  }

@@ -143,6 +140,16 @@ public function getDefaultOperations(EntityInterface $entity) {
      unset($operations['disable']);
    }

    // Remove disable and edit operations for disabled formats.
    if (!$entity->status()) {
      if (isset($operations['disable'])) {
        unset($operations['disable']);
      }
      if (isset($operations['edit'])) {
        unset($operations['edit']);
      }
    }

    return $operations;
  }

Loading