Comments

amit.drupal created an issue. See original summary.

amit.drupal’s picture

Status: Active » Needs review
StatusFileSize
new2.63 KB
amit.drupal’s picture

Assigned: ishani.addweb » amit.drupal
yoftahe.addweb’s picture

yas’s picture

Status: Needs review » Needs work

@nileshaddweb

Thank you for the refactoring.

+++ b/modules/cloud_service_providers/aws_cloud/src/Form/Ec2/ElasticIpAssociateForm.php
@@ -202,13 +203,27 @@ class ElasticIpAssociateForm extends AwsDeleteForm {

+        $instance->getName() !== $instance->getInstanceId() ? $this->t('@instance_name (@instance_id)', [
+          '@instance_name' => $instance->getName(),
+          '@instance_id' => $instance_id,
+        ]) : $instance_id

Can you refactor the code style like this?

        $instance->getName() !== $instance->getInstanceId()
          ? $this->t('@instance_name (@instance_id)', [
            '@instance_name' => $instance->getName(),
            '@instance_id' => $instance_id,
          ])
          : $instance_id
        );

* Please check the coding standard.


+++ b/modules/cloud_service_providers/aws_cloud/src/Form/Ec2/ElasticIpAssociateForm.php
@@ -222,11 +237,13 @@ class ElasticIpAssociateForm extends AwsDeleteForm {

+            $message = $this->t('Elastic IP @ip_address associated with @private_ip for instance: @instance_id', [
               '@ip_address' => $this->entity->getPublicIp(),
               '@instance' => !empty($instance) ? $instance->getName() : 'N/A',
               '@private_ip' => $private_ip,
+              '@instance_id' => Markup::create($instance_link['#markup']),
             ]);

I guess we don't need '@instance' any longer?

yas’s picture

yoftahe.addweb’s picture

Status: Needs work » Needs review
StatusFileSize
new1.4 KB
new2.66 KB
yas’s picture

Status: Needs review » Reviewed & tested by the community

@nileshaddweb

Thank you for the update. Interdiff is helpful to find out your fixes. I'll merge the patch to 8.x-1.x and 8.x-2.x and close this issue as Fixed.

  • yas committed a86a3b7 on 8.x-1.x authored by nilesh.addweb
    Issue #3119979 by nilesh.addweb, amit.drupal, yas: Refactor to add a...

  • yas committed 36a6443 on 8.x-2.x authored by nilesh.addweb
    Issue #3119979 by nilesh.addweb, amit.drupal, yas: Refactor to add a...
yas’s picture

Status: Reviewed & tested by the community » Fixed
yas’s picture

Status: Fixed » Needs work

@nileshaddweb

  • I found some issues in the following code so re-opening this issue:
    1. The variable $entity is unused
    2. $instance_id is undefined
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->ec2Service->setCloudContext($this->entity->getCloudContext());
    $entity = $this->entity;

    // Determine if elastic_ip is attaching to instance or network_interface.
    if ($form_state->getValue('resource_type') === 'instance') {
      $get_instance_id = $form_state->getValue('instance_id');
      $private_ip = $form_state->getValue('instance_private_ip');

      if ($instance_id !== -1) {
        $instance = Instance::load($get_instance_id);
        $instance_id = $instance->getInstanceId();

Please fix the issues, create and test a patch.

yoftahe.addweb’s picture

Status: Needs work » Needs review
StatusFileSize
new1.09 KB

@yas I updated patch as per your comment. Please check.

yas’s picture

Status: Needs review » Needs work

@nileshaddweb

Do we really need to introduce a new variable $get_instance_id?

      $get_instance_id = $form_state->getValue('instance_id');
      $private_ip = $form_state->getValue('instance_private_ip');

      if ($get_instance_id !== -1) {
        $instance = Instance::load($get_instance_id);
        $instance_id = $instance->getInstanceId();

        $instance_link = $this->entityLinkRenderer->renderViewElement(

Can we write like this?

      $instance_id = $form_state->getValue('instance_id');
      $private_ip = $form_state->getValue('instance_private_ip');

      if ($instance_id !== -1) {
        $instance = Instance::load($get_instance_id);

        $instance_link = $this->entityLinkRenderer->renderViewElement(
yas’s picture

@nileshaddweb

Let's change like this:

FROM:

      $get_instance_id = $form_state->getValue('instance_id');
      $private_ip = $form_state->getValue('instance_private_ip');

      if ($get_instance_id !== -1) {
        $instance = Instance::load($get_instance_id);
        $instance_id = $instance->getInstanceId();

        $instance_link = $this->entityLinkRenderer->renderViewElement(

TO:

      $entity_id = $form_state->getValue('instance_id');
      $private_ip = $form_state->getValue('instance_private_ip');

      if ($entity_id !== -1) {
        $instance = Instance::load($entity_id);
        $instance_id = $instance->getInstanceId();

        $instance_link = $this->entityLinkRenderer->renderViewElement(
yoftahe.addweb’s picture

Status: Needs work » Needs review
StatusFileSize
new1012 bytes
new1.26 KB

@yas I updated patch as per your comment. Please check.

yas’s picture

Status: Needs review » Reviewed & tested by the community

@nileshaddweb

Thank you for the update. I tested the patch and looks good to me now. I'll merge the patch to 8.x-1.x and 8.x-2.x and close this issue as Fixed.

  • yas committed ff8923f on 8.x-1.x authored by nilesh.addweb
    Issue #3119979 by nilesh.addweb, yas: Hotfix - Refactor to add a link to...

  • yas committed c613d6b on 8.x-2.x authored by nilesh.addweb
    Issue #3119979 by nilesh.addweb, yas: Hotfix - Refactor to add a link to...
yas’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.