Commit faf5cd69 authored by Yas Naoi's avatar Yas Naoi Committed by Yas Naoi
Browse files

Issue #3179587 by yas, baldwinlouie: Fix descriptions of each cloud service...

Issue #3179587 by yas, baldwinlouie: Fix descriptions of each cloud service provider access permission
parent 7fd62d39
Loading
Loading
Loading
Loading
+1 −1
Changes for cloud.permissions.yml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ access dashboard:

view all cloud service providers:
  title: 'Access all cloud service providers'
  description: 'Allows access to all cloud service providers. Entity permissions such as <em>List AWS Instances</em> and <em>View own AWS Cloud Instance</em> (or <em>View any AWS Cloud Instance</em>) need to be granted in conjunction. Otherwise, no cloud service provider will be shown to the user.'
  description: 'Allows access to all cloud service providers. Entity permissions such as e.g. <em>List AWS Cloud &lt;entity name&gt;</em> and <em>View own AWS Cloud &lt;entity name&gt;</em> (or <em>View any AWS Cloud &lt;entity name&gt;</em>) need to be granted in conjunction. Otherwise, no cloud service provider will be shown to the user.'

view cloud service provider admin list:
  title: 'View cloud service provider administration list'
+22 −6
Changes for src/Entity/CloudPermissions.php: 22 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Drupal\cloud\Entity;

use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

@@ -21,14 +22,24 @@ class CloudPermissions implements ContainerInjectionInterface {
   */
  protected $entityTypeManager;

  /**
   * The module handler service.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * Constructs new CloudPermissions object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   The entity type manager.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
   *   The module handler service.
   */
  public function __construct(EntityTypeManagerInterface $entityTypeManager) {
  public function __construct(EntityTypeManagerInterface $entityTypeManager, ModuleHandlerInterface $moduleHandler) {
    $this->entityTypeManager = $entityTypeManager;
    $this->moduleHandler = $moduleHandler;
  }

  /**
@@ -36,7 +47,8 @@ class CloudPermissions implements ContainerInjectionInterface {
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('entity_type.manager')
      $container->get('entity_type.manager'),
      $container->get('module_handler')
    );
  }

@@ -46,10 +58,14 @@ class CloudPermissions implements ContainerInjectionInterface {
  public function configPermissions() {
    $permissions = [];
    $cloud_configs = $this->entityTypeManager->getStorage('cloud_config')->loadMultiple();
    foreach ($cloud_configs ?: [] as $cloud) {
      $permissions['view ' . $cloud->getCloudContext()] = [
        'title' => $this->t('Access %entity', ['%entity' => $cloud->get('name')->value]),
        'description' => $this->t('Allows access to entities in %entity. Entity permissions such as <em>List AWS Instances</em> and <em>View own AWS Cloud Instance</em> (or <em>View any AWS Cloud Instance</em>) need to be granted in conjunction. Otherwise, no entities will be shown to the user.', ['%entity' => $cloud->get('name')->value]),
    foreach ($cloud_configs ?: [] as $cloud_config) {
      $label = $cloud_config->label();
      $permissions['view ' . $cloud_config->getCloudContext()] = [
        'title' => $this->t('Access %label', ['%label' => $label]),
        'description' => $this->t('Allows access to entities in %label. Entity permissions such as e.g. <em>List %module_name &lt;entity name&gt;</em> and <em>View own %module_name &lt;entity name&gt;</em> (or <em>View any %module_name &lt;entity name&gt;</em>) need to be granted in conjunction. Otherwise, no entities will be shown to the user.', [
          '%module_name' => $this->moduleHandler->getName($cloud_config->bundle()),
          '%label' => $label,
        ]),
      ];
    }
    return $permissions;