Skip to content
Snippets Groups Projects
Commit f8e21a34 authored by xiaohua guan's avatar xiaohua guan Committed by Yas Naoi
Browse files

Issue #3068594 by Xiaohua Guan, yas, baldwinlouie: Add VPC entity link in Subnets

parent 4a9d7540
No related branches found
No related tags found
No related merge requests found
......@@ -1187,6 +1187,16 @@ function aws_cloud_update_8167() {
}
}
/**
* Update view aws_cloud_subnet.
*/
function aws_cloud_update_8168() {
$files = [
'views.view.aws_cloud_subnet.yml',
];
cloud_update_yml_definitions($files, 'aws_cloud');
}
/**
* Helper function to add fields to the entity type.
*
......
......@@ -337,9 +337,11 @@ display:
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
type: entity_link
settings:
link_to_entity: false
target_type: aws_cloud_vpc
field_name: vpc_id
html_generator_class: Drupal\cloud\Service\Util\EntityLinkWithShortNameHtmlGenerator
group_column: value
group_columns: { }
group_rows: true
......
......@@ -6,6 +6,7 @@ use Drupal\cloud\Entity\CloudContentEntityBase;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\cloud\Service\Util\EntityLinkWithNameHtmlGenerator;
/**
* Defines the Vpc entity.
......@@ -216,6 +217,16 @@ class Subnet extends CloudContentEntityBase implements SubnetInterface {
'type' => 'string',
'weight' => -5,
])
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'entity_link',
'settings' => [
'target_type' => 'aws_cloud_vpc',
'field_name' => 'vpc_id',
'html_generator_class' => EntityLinkWithNameHtmlGenerator::class,
],
'weight' => -5,
])
->setReadOnly(TRUE);
$fields['cidr_block'] = BaseFieldDefinition::create('string')
......
......@@ -3,6 +3,7 @@
namespace Drupal\aws_cloud\Form\Vpc;
use Drupal\Core\Form\FormStateInterface;
use Drupal\cloud\Service\Util\EntityLinkWithNameHtmlGenerator;
use Drupal\aws_cloud\Form\Ec2\AwsCloudContentForm;
/**
......@@ -44,11 +45,14 @@ class SubnetEditForm extends AwsCloudContentForm {
'#markup' => $entity->getSubnetId(),
];
$form['subnet']['vpc_id'] = [
'#type' => 'item',
'#title' => $this->getItemTitle($this->t('VPC ID')),
'#markup' => $entity->getVpcId(),
];
$form['subnet']['vpc_id'] = $this->entityLinkRenderer->renderFormElements(
$entity->getVpcId(),
'aws_cloud_vpc',
'vpc_id',
['#title' => $this->getItemTitle($this->t('VPC ID'))],
'',
EntityLinkWithNameHtmlGenerator::class
);
$form['vpc']['created'] = [
'#type' => 'item',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment