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

Issue #3025252 by Xiaohua Guan, yas: Use a link to a resource in Security Group

parent 66e1d7b1
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,7 @@ use Drupal\Core\Field\BaseFieldDefinition;
* id = "aws_cloud_security_group",
* label = @Translation("AWS Cloud Security Group"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "view_builder" = "Drupal\aws_cloud\Entity\Ec2\SecurityGroupViewBuilder",
* "list_builder" = "Drupal\aws_cloud\Controller\Ec2\SecurityGroupListBuilder",
* "views_data" = "Drupal\aws_cloud\Entity\Ec2\SecurityGroupViewsData",
* "form" = {
......@@ -162,7 +162,7 @@ class SecurityGroup extends CloudContentEntityBase implements SecurityGroupInter
]);
$fields['group_id'] = BaseFieldDefinition::create('string')
->setLabel(t('Group ID'))
->setLabel(t('ID'))
->setDescription(t('The ID of your security group.'))
->setDisplayOptions('view', [
'label' => 'inline',
......@@ -172,7 +172,7 @@ class SecurityGroup extends CloudContentEntityBase implements SecurityGroupInter
->setReadOnly(TRUE);
$fields['group_name'] = BaseFieldDefinition::create('string')
->setLabel(t('Group Name'))
->setLabel(t('Security Group Name'))
->setDescription(t('The name given to your security group.'))
->setDisplayOptions('view', [
'label' => 'inline',
......@@ -182,7 +182,7 @@ class SecurityGroup extends CloudContentEntityBase implements SecurityGroupInter
->setReadOnly(TRUE);
$fields['group_description'] = BaseFieldDefinition::create('string')
->setLabel(t('Group Description'))
->setLabel(t('Description'))
->setDescription(t('The description of your security group.'))
->setDisplayOptions('view', [
'label' => 'inline',
......
<?php
namespace Drupal\aws_cloud\Entity\Ec2;
/**
* Provides the security group view builders.
*/
class SecurityGroupViewBuilder extends Ec2BaseViewBuilder {
/**
* {@inheritdoc}
*/
protected function getFieldsetDefs() {
return [
[
'name' => 'security_group',
'title' => t('Security Group'),
'open' => TRUE,
'fields' => [
'group_id',
'group_name',
'description',
'vpc_id',
],
],
[
'name' => 'others',
'title' => t('Others'),
'open' => FALSE,
'fields' => ['user_id'],
],
];
}
}
......@@ -5,7 +5,6 @@
// Created by yas 2016/05/30.
namespace Drupal\aws_cloud\Form\Ec2;
use Drupal\cloud\Form\CloudContentForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\Language;
......@@ -14,7 +13,7 @@ use Drupal\Core\Language\Language;
*
* @ingroup aws_cloud
*/
class SecurityGroupEditForm extends CloudContentForm {
class SecurityGroupEditForm extends AwsCloudContentForm {
/**
* Overrides Drupal\Core\Entity\EntityFormController::buildForm().
......@@ -25,62 +24,71 @@ class SecurityGroupEditForm extends CloudContentForm {
$entity = $this->entity;
$form['cloud_context'] = [
'#type' => 'textfield',
'#title' => $this->t('Cloud ID'),
'#maxlength' => 255,
'#size' => 60,
'#default_value' => !$entity->isNew()
? $entity->getCloudContext()
: $cloud_context,
'#required' => FALSE,
'#weight' => -5,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$weight = -50;
$form['security_group'] = [
'#type' => 'details',
'#title' => $this->t('Security Group'),
'#open' => TRUE,
'#weight' => $weight++,
];
$form['name'] = [
$form['security_group']['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Name'),
'#maxlength' => 255,
'#size' => 60,
'#default_value' => $entity->label(),
'#required' => TRUE,
'#weight' => -5,
];
$form['group_name'] = [
'#type' => 'textfield',
'#title' => $this->t('Security Group Name'),
'#size' => 60,
'#default_value' => $entity->getGroupName(),
'#weight' => -5,
'#required' => FALSE,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$form['security_group']['group_name'] = [
'#type' => 'item',
'#title' => $this->t('Security Group Name: '),
'#markup' => $entity->getGroupName(),
];
$form['description'] = [
'#type' => 'textarea',
'#title' => $this->t('Description'),
'#maxlength' => 255,
'#cols' => 60,
'#rows' => 3,
'#default_value' => $entity->getDescription(),
'#weight' => -5,
'#required' => FALSE,
$form['security_group']['description'] = [
'#type' => 'item',
'#title' => $this->t('Description: '),
'#markup' => $entity->getDescription(),
];
$form['security_group']['vpc_id'] = [
'#type' => 'item',
'#title' => $this->t('VPC ID: '),
'#markup' => $entity->getVpcId(),
];
$form['others'] = [
'#type' => 'details',
'#title' => $this->t('Others'),
'#open' => FALSE,
'#weight' => $weight++,
];
$form['langcode'] = [
$form['others']['cloud_context'] = [
'#type' => 'item',
'#title' => $this->t('Cloud ID: '),
'#markup' => !$entity->isNew()
? $entity->getCloudContext()
: $cloud_context,
];
$form['others']['langcode'] = [
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $entity->getUntranslated()->language()->getId(),
'#languages' => Language::STATE_ALL,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
'#disabled' => FALSE,
];
$form['others']['user_id'] = $form['user_id'];
unset($form['user_id']);
$form['actions'] = $this->actions($form, $form_state, $cloud_context);
$form['actions']['#weight'] = $weight++;
return $form;
}
......
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