Commit 759a0502 authored by xiaohua guan's avatar xiaohua guan Committed by Yas Naoi
Browse files

Issue #3308279 by Xiaohua Guan, yas, kumikoono: Fix to display the operation...

Issue #3308279 by Xiaohua Guan, yas, kumikoono: Fix to display the operation menu "Create Snapshot" only when the status of the volume is "available"
parent fad30ba5
Loading
Loading
Loading
Loading
+27 −14
Original line number Diff line number Diff line
@@ -1483,6 +1483,7 @@ function openstack_entity_operation(EntityInterface $entity): array {
  $operations = [];
  $account = \Drupal::currentUser();

  // OpenStack volume.
  if ($entity->getEntityTypeId() === 'openstack_volume') {
    if ($account->hasPermission('edit any openstack volume')
    || ($account->hasPermission('edit own openstack volume')
@@ -1505,6 +1506,7 @@ function openstack_entity_operation(EntityInterface $entity): array {
    }

    if ($account->hasPermission('add openstack snapshot')) {
      if ($entity->getState() === 'available') {
        $operations['create_snapshot'] = [
          'title' => t('Create Snapshot'),
          'url' => Url::fromRoute(
@@ -1518,7 +1520,11 @@ function openstack_entity_operation(EntityInterface $entity): array {
        ];
      }
    }
  elseif ($entity->getEntityTypeId() === 'openstack_floating_ip') {
    return $operations;
  }

  // OpenStack floating IP.
  if ($entity->getEntityTypeId() === 'openstack_floating_ip') {
    if ($account->hasPermission('edit any openstack floating ip')
    || ($account->hasPermission('edit own openstack floating ip')
    && !empty($entity->getOwner())
@@ -1536,8 +1542,11 @@ function openstack_entity_operation(EntityInterface $entity): array {
        ];
      }
    }
    return $operations;
  }
  elseif ($entity->getEntityTypeId() === 'openstack_snapshot') {

  // OpenStack snapshot.
  if ($entity->getEntityTypeId() === 'openstack_snapshot') {
    if ($account->hasPermission('add openstack volume')) {
      $operations['create_volume'] = [
        'title' => t('Create Volume'),
@@ -1551,8 +1560,11 @@ function openstack_entity_operation(EntityInterface $entity): array {
        'weight' => 20,
      ];
    }
    return $operations;
  }
  elseif ($entity->getEntityTypeId() === 'openstack_instance') {

  // OpenStack instance.
  if ($entity->getEntityTypeId() === 'openstack_instance') {
    if ($account->hasPermission('edit any openstack instance')
    || ($account->hasPermission('edit own openstack instance')
    && !empty($entity->getOwner())
@@ -1577,6 +1589,7 @@ function openstack_entity_operation(EntityInterface $entity): array {
        ];
      }
    }
    return $operations;
  }

  return $operations;
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ CreateVolume:
  VolumeId: {{volume_id}}
  VolumeType: {{volume_type}}
  CreateTime: '{{create_time}}'
  State: creating
  State: available
  Tags:
    - Key: 'aws_cloud_volume_{{uid_tag_key}}'
      Value: '{{uid}}'