Commit 5ba33931 authored by Ryo Yamashita's avatar Ryo Yamashita Committed by Yas Naoi
Browse files

Issue #3306990 by Ryo Yamashita, yas: Add the function to edit AWS Cloud Security Group in the SPA

parent 0352c7a9
Loading
Loading
Loading
Loading
+27 −0
Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/security_group.ts: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -21,6 +21,33 @@ const AWS_CLOUD_SECURITY_GROUP_TEMPLATE: EntityFormTemplate[] = [
      }
    ]
  },
  {
    cloudServiceProvider: 'aws_cloud',
    entityName: 'security_group',
    actionType: 'edit',
    entityRecords: [
      {
        type: 'panel',
        panelName: 'Security group',
        keyValueRecords: [
          { labelName: 'Name', name: 'group_name', type: 'default', defaultValue: '', required: true },
          { labelName: 'Security group name', name: 'group_name', type: 'default', defaultValue: '', readOnly: true },
          { labelName: 'ID', name: 'group_id', type: 'default', defaultValue: '', readOnly: true },
          { labelName: 'Description', name: 'description', type: 'default', defaultValue: '', readOnly: true },
          { type: 'default', labelName: 'VPC ID', name: 'vpc_id', defaultValue: '', readOnly: true },
          { labelName: 'Created', name: 'created', type: 'datetime', defaultValue: 0, readOnly: true },
        ]
      },
      {
        type: 'panel',
        panelName: 'Rules',
        keyValueRecords: [
          { labelName: 'Inbound Rules', name: 'ip_permission', type: 'sg_permission', defaultValue: [] },
          { labelName: 'Outbound Rules', name: 'outbound_permission', type: 'sg_permission', defaultValue: [] },
        ]
      }
    ],
  },
  {
    cloudServiceProvider: 'aws_cloud',
    entityName: 'security_group',
+14 −0
Changes for modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -1254,6 +1254,20 @@ entity.aws_cloud_security_group.create:
  requirements:
    _permission: 'add aws cloud security group'

entity.aws_cloud_security_group.edit:
  path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_security_group/{entity_id}/edit'
  defaults:
    _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateEntity'
    entity_type_id: aws_cloud_security_group
    command: edit
  methods: [POST]
  requirements:
    # Use custom access that will check for cloud_context and the desired permission.
    # Desired permission is passed as an option in the "perm" variable
    _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access'
  options:
      perm: 'edit any aws cloud security group+edit own aws cloud security group'

entity.aws_cloud_security_group.revoke:
  path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_security_group/{entity_id}/revoke'
  defaults:
+8 −0
Changes for modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -961,6 +961,14 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
          $method_name = 'editNetworkInterface';
          break;

        case 'edit_aws_cloud_security_group':
          /** @var \Drupal\aws_cloud\Entity\Ec2\SecurityGroupInterface $entity */
          $entity->setGroupName($request->get('group_name', ''));
          $entity->set('ip_permission', json_decode($request->get('ip_permission', '[]'), TRUE));
          $entity->set('outbound_permission', json_decode($request->get('outbound_permission', '[]'), TRUE));
          $method_name = 'editSecurityGroup';
          break;

        case 'import_aws_cloud_key_pair':
          /** @var \Drupal\aws_cloud\Entity\Ec2\KeyPairInterface $entity */
          $entity->set('key_pair_name', $request->get('key_pair_name', ''));