Commit 54e87d4e authored by Tamaki Fujino's avatar Tamaki Fujino Committed by Yas Naoi
Browse files

Issue #3271743 by TamakiFujino, yas, kumikoono: Fix the UI wordings of AWS...

Issue #3271743 by TamakiFujino, yas, kumikoono: Fix the UI wordings of AWS Cloud Service creation form against Drupal User Interface Standards
parent 56f93cf6
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -149,15 +149,15 @@ Basic Setup (AWS)
   1. Instance credentials - If cloud module is running on an EC2 instance and
      the EC2 instance has an IAM role attached, you have the option to check
      `Use Instance Credentials`.  Doing so is secure and does not require
      `Access Key ID` and `Secret Access Key` to be entered into Drupal.
      `Access key ID` and `Secret access key` to be entered into Drupal.
      Please refer to this AWS tutorial about IAM role and EC2 Instance:

      https://aws.amazon.com/blogs/security/easily-replace-or-attach-an-iam-role-to-an-existing-ec2-instance-by-using-the-ec2-console/

   2. Simple access - Specify `Access Key ID` and `Secret Access Key` to access
   2. Simple access - Specify `Access key ID` and `Secret access key` to access
      a particular account's EC2 instances.
   3. Assume role - Specify `Access Key ID`, `Secret Access Key` and the
      `Assume Role` section.  With this combination, the `cloud` module can
   3. Assume role - Specify `Access key ID`, `Secret access key` and the
      `Assume role` section.  With this combination, the `cloud` module can
      assume the role of another AWS account and access their EC2 instances.
      To learn more about setting up assume role setup, please read this AWS
      tutorial:
+1 −1
Original line number Diff line number Diff line
@@ -436,7 +436,7 @@ function cloud_update_8124(): void {

  $field = BaseFieldDefinition::create('image')
    ->setLabel(t('Icon'))
    ->setDescription(t('Icon representing the cloud service provider.'))
    ->setDescription(t('Upload an icon representing the cloud service provider.'))
    ->setSettings([
      'file_directory' => 'IMAGE_FOLDER',
      'alt_field_required' => FALSE,
+5 −5
Original line number Diff line number Diff line
@@ -374,14 +374,14 @@ function aws_cloud_update_8122(): void {
  $config_factory = \Drupal::configFactory();

  $field = $config_factory->getEditable('field.field.cloud_config.aws_cloud.field_secret_key');
  $field->set('label', 'Secret Access Key');
  $field->set('description', 'e.g. 123ABC/defGHIjkl34+LMNopq567RSTuvwxYz89Z 16-32 Characters.  If <em>Assume Role</em> is selected, enter the secret access key of the child user.');
  $field->set('label', 'Secret access key');
  $field->set('description', 'e.g. 123ABC/defGHIjkl34+LMNopq567RSTuvwxYz89Z. Enter 16-32 Characters.  If <em>assume role</em> is selected, enter the secret access key of the child user.');
  $field->set('required', FALSE);
  $field->save(TRUE);

  $field = $config_factory->getEditable('field.field.cloud_config.aws_cloud.field_access_key');
  $field->set('label', 'Access Key ID');
  $field->set('description', '16-32 Characters, e.g. 12ABCDEFGHIJKVWXYZ89.  If <em>Assume Role</em> is selected, enter the access key ID of the child user.');
  $field->set('label', 'Access key ID');
  $field->set('description', 'Enter 16-32 Characters, e.g. 12ABCDEFGHIJKVWXYZ89.  If <em>assume role</em> is selected, enter the access key ID of the child user.');
  $field->set('required', FALSE);
  $field->save(TRUE);

@@ -821,7 +821,7 @@ function aws_cloud_update_8144(): void {
}

/**
 * Add the Switch Role fields.
 * Add the switch role fields.
 */
function aws_cloud_update_8145(): void {
  \Drupal::service('cloud')->addFields(
+23 −23
Original line number Diff line number Diff line
@@ -2635,7 +2635,7 @@ function aws_cloud_form_cloud_config_aws_cloud_add_form_alter(array &$form, Form
  }
  $max_region_code_length = CloudConfigInterface::MAX_NAME_LENGTH - ($max_region_name + 1);
  $max_name_length = CloudConfigInterface::MAX_NAME_LENGTH;
  $form['name']['widget'][0]['value']['#description'] = "The name of the cloud service provider. The region name will be automatically added. The maximum number of characters of the name including the region name is {$max_name_length}.";
  $form['name']['widget'][0]['value']['#description'] = "Enter the name of the cloud service provider. The region name will be automatically added. The maximum number of characters of the name including the region name is {$max_name_length}.";
  $form['name']['widget'][0]['value']['#maxlength'] = $max_region_code_length;

  aws_cloud_form_cloud_config_aws_cloud_form_common_alter($form, $form_state, $form_id);
@@ -2661,13 +2661,13 @@ function aws_cloud_form_cloud_config_aws_cloud_add_form_alter(array &$form, Form
  ];
  // Add radios asking user for iam validation preference.
  $form['profile']['common']['iam_validation_options'] = [
    '#title' => t('Validate IAM Permissions'),
    '#title' => t('Validate IAM permissions'),
    '#description' => t('Validate that the AWS account ID has all the necessary IAM permissions.'),
    '#type' => 'radios',
    '#options' => [
      Ec2ServiceInterface::IAM_VALIDATION_NO_CHECK => t('Do not validate IAM permissions.'),
      Ec2ServiceInterface::IAM_VALIDATION_ONE_REGION => t('Validate one region.'),
      Ec2ServiceInterface::IAM_VALIDATION_ALL_REGIONS => t('Validate all regions.'),
      Ec2ServiceInterface::IAM_VALIDATION_NO_CHECK => t('Do not validate IAM permissions'),
      Ec2ServiceInterface::IAM_VALIDATION_ONE_REGION => t('Validate one region'),
      Ec2ServiceInterface::IAM_VALIDATION_ALL_REGIONS => t('Validate all regions'),
    ],
    '#default_value' => Ec2ServiceInterface::IAM_VALIDATION_ONE_REGION,
    '#weight' => $form['profile']['common']['regions']['#weight'] + 1,
@@ -2769,7 +2769,7 @@ function aws_cloud_form_cloud_config_aws_cloud_add_form_validate(array &$form, F
  $cloud_contexts_intersected = array_intersect($cloud_contexts_selected, $cloud_contexts_exist);
  if (!empty($cloud_contexts_intersected)) {
    $form_state->setErrorByName('name',
      t('The cloud service provider(s) already exists as the same ID: @regions', [
      t('The AWS Cloud service provider(s) already exists as the same ID: @regions. Specify the different AWS Cloud service provider name since the AWS Cloud service provider ID must be unique.', [
        '@regions' => implode(', ', $cloud_contexts_intersected),
      ])
    );
@@ -3076,17 +3076,17 @@ function aws_cloud_form_cloud_config_aws_cloud_check_iam_permissions_validate(ar
    }

    if (!empty($unauthorized_apis['mandatory']) || !empty($unauthorized_apis['optional'])) {
      // Throw validation message if Switch Role or Assume Role has errors.
      // Throw validation message if switch role or assume role has errors.
      if (in_array('AssumeRoleDenied', $permissions_validated, TRUE)) {
        if (!empty($form_state->getValue('field_use_switch_role')['value'])) {
          // Prompt user to fix Switch Role configuration.
          $form_state->setErrorByName('field_use_switch_role', t('Unable to validate Switch Role.'));
          $form_state->setErrorByName('field_switch_role_account_id', t('Fix Switch Role Account ID.'));
          $form_state->setErrorByName('field_switch_role_iam_role', t('Fix Switch Role IAM role.'));
          // Prompt user to fix switch role configuration.
          $form_state->setErrorByName('field_use_switch_role', t('Unable to validate switch role.'));
          $form_state->setErrorByName('field_switch_role_account_id', t('Fix account ID for switch role.'));
          $form_state->setErrorByName('field_switch_role_iam_role', t('Fix IAM role for switch role.'));
        }
        else {
          // Prompt user to fix Assume Role.
          $form_state->setErrorByName('field_use_assume_role', t('Unable to validate Assume Role.'));
          // Prompt user to fix assume role.
          $form_state->setErrorByName('field_use_assume_role', t('Unable to validate assume role.'));
          $form_state->setErrorByName('field_iam_role', t('Fix IAM role.'));
        }
      }
@@ -3098,10 +3098,10 @@ function aws_cloud_form_cloud_config_aws_cloud_check_iam_permissions_validate(ar
        // Distinguish where the user needs to fix their permissions.
        $to_fix = t('credentials');
        if (!empty($form_state->getValue('field_use_switch_role')['value'])) {
          $to_fix = t('Switch Role credentials');
          $to_fix = t('Switch role credentials');
        }
        elseif (!empty($form_state->getValue('field_use_assume_role')['value'])) {
          $to_fix = t('Assume Role credentials');
          $to_fix = t('Assume role credentials');
        }
        elseif (!empty($form_state->getValue('field_use_instance_profile')['value'])) {
          $to_fix = t('Instance Profile credentials');
@@ -3174,8 +3174,8 @@ function aws_cloud_form_cloud_config_aws_cloud_check_iam_permissions_validate(ar
        ['@region' => implode(', ', $failed_regions)]
      )
    );
    $form_state->setErrorByName('field_access_key', t('Fix Access Key ID.'));
    $form_state->setErrorByName('field_secret_key', t('Fix Secret Access Key.'));
    $form_state->setErrorByName('field_access_key', t('Fix access key ID.'));
    $form_state->setErrorByName('field_secret_key', t('Fix secret access key.'));
  }

}
@@ -3324,7 +3324,7 @@ function aws_cloud_form_cloud_config_aws_cloud_credentials_validate(array &$form

  if (!empty($use_switch_role['value'])) {
    if (empty($use_assume_role['value'])) {
      $form_state->setErrorByName('field_use_assume_role', t('Assume Role must be enabled.'));
      $form_state->setErrorByName('field_use_assume_role', t('Assume role must be enabled.'));
    }
    if (empty($iam_role[0]['value'])) {
      $form_state->setErrorByName(
@@ -3377,13 +3377,13 @@ function _aws_cloud_get_credentials_for_validate($region, FormStateInterface $fo
    'use_assume_role' => $form_state->getValue('field_use_assume_role')['value'] ?? FALSE,
    'use_switch_role' => $form_state->getValue('field_use_switch_role')['value'] ?? FALSE,

    // Assume Role ARN.
    // Assume role ARN.
    'role_arn' => !empty($form_state->getValue('field_use_assume_role')['value'])
    ? sprintf('arn:aws:iam::%s:role/%s',
      trim($form_state->getValue('field_account_id')[0]['value']),
      trim($form_state->getValue('field_iam_role')[0]['value'])) : '',

    // Switch Role ARN.
    // Switch role ARN.
    'switch_role_arn' => !empty($form_state->getValue('field_use_switch_role')['value'])
    ? sprintf('arn:aws:iam::%s:role/%s',
      trim($form_state->getValue('field_switch_role_account_id')[0]['value']),
@@ -3640,7 +3640,7 @@ function aws_cloud_form_cloud_config_aws_cloud_form_common_alter(array &$form, F

  aws_cloud_cloud_config_fieldsets($form);

  // Hide Credential fields and Assume Role fieldset.
  // Hide credential fields and assume role fieldset.
  $hide_credential_fields = [
    'field_access_key',
    'field_secret_key',
@@ -5243,7 +5243,7 @@ function aws_cloud_cloud_config_fieldsets(array &$fields): void {
        ],
        [
          'name' => 'use_assume_role',
          'title' => t('Assume Role'),
          'title' => t('Assume role'),
          'open' => TRUE,
          'fields' => [
            'field_use_assume_role',
@@ -5252,7 +5252,7 @@ function aws_cloud_cloud_config_fieldsets(array &$fields): void {
          'subfieldsets' => [
            [
              'name' => 'use_switch_role',
              'title' => t('Switch Role'),
              'title' => t('Switch role'),
              'open' => TRUE,
              'fields' => [
                'field_use_switch_role',
+2 −2
Original line number Diff line number Diff line
@@ -8,8 +8,8 @@ id: cloud_config.aws_cloud.field_access_key
field_name: field_access_key
entity_type: cloud_config
bundle: aws_cloud
label: 'Access Key ID'
description: '16-32 Characters, e.g. 12ABCDEFGHIJKVWXYZ89 .  If <em>Assume Role</em> is selected, enter the access key ID of the child user.'
label: 'Access key ID'
description: 'Enter 16-32 Characters, e.g. <code>12ABCDEFGHIJKVWXYZ89</code> without hyphen(s) (<code>-</code>). If <em>assume role</em> is selected, enter the access key ID of the child user.'
required: false
translatable: false
default_value: {  }
Loading