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

Issue #3038492 by Xiaohua Guan, yas, Masami, baldwinlouie: Categorize (add...

Issue #3038492 by Xiaohua Guan, yas, Masami, baldwinlouie: Categorize (add fieldset) the items in each Edit view
parent 31bab0e6
No related branches found
No related tags found
No related merge requests found
Showing
with 252 additions and 521 deletions
--- a/modules/cloud_service_providers/aws_cloud/src/Aws/Ec2/NetworkInterfaceInterface.php
+++ b/modules/cloud_service_providers/aws_cloud/src/Aws/Ec2/NetworkInterfaceInterface.php
@@ -205,7 +205,7 @@
public function setAssociationId($association_id);
/**
- * {inheritdoc}
+ * {inheritdoc}.
*/
public function setPublicIps($public_ips);
--- a/modules/cloud_service_providers/aws_cloud/src/Entity/Ec2/NetworkInterface.php
+++ b/modules/cloud_service_providers/aws_cloud/src/Entity/Ec2/NetworkInterface.php
@@ -266,7 +266,7 @@
/**
* {@inheritdoc}
*/
- public function setPrimaryPrivateIp ($private_ip) {
+ public function setPrimaryPrivateIp($private_ip) {
return $this->set('primary_private_ip', $private_ip);
}
--- a/modules/cloud_service_providers/aws_cloud/src/Form/Ec2/AwsCloudContentForm.php
+++ b/modules/cloud_service_providers/aws_cloud/src/Form/Ec2/AwsCloudContentForm.php
@@ -91,6 +91,9 @@
parent::save($form, $form_state);
}
+ /**
+ *
+ */
protected function copyFormItemValues(array $form) {
$original_entity = $this->manager
->getStorage($this->entity->getEntityTypeId())
--- a/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/ElasticIpTest.php
+++ b/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/ElasticIpTest.php
@@ -5,7 +5,6 @@
use Drupal\Tests\aws_cloud\Functional\Utils;
use Drupal\Component\Serialization\Yaml;
-
// Updated by yas 2016/06/23
// Updated by yas 2016/06/02
// Updated by yas 2016/05/31
@@ -90,7 +89,7 @@
$this->assertNoText(t('Notice'), t('Add | View | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Add | View | Make sure w/o Warnings'));
- // Make sure domain is updated
+ // Make sure domain is updated.
$this->assertText($domain, t('Add | View | Make sure domain: @domain', ['@domain' => $domain]));
// Make sure listing.
@@ -166,8 +165,8 @@
]),
t('Confirm Message') . ': '
. t('Delete | The AWS Cloud Elastic IP "@name" has been deleted.', [
- '@name' => $edit[$i]['name'],
- ])
+ '@name' => $edit[$i]['name'],
+ ])
);
// Make sure listing.
@@ -179,8 +178,8 @@
for ($j = 0; $j < $i + 1; $j++) {
$this->assertNoText($edit[$j]['name'],
t('Delete | List | Make sure w/ Listing: @name', [
- '@name' => $edit[$j]['name'],
- ]));
+ '@name' => $edit[$j]['name'],
+ ]));
}
}
}
@@ -267,4 +266,5 @@
$mock_data['DescribeInstances']['Reservations'][0]['Instances'][] = $instance_mock_data;
$this->updateMockDataToConfig($mock_data);
}
+
}
--- a/modules/cloud_service_providers/aws_cloud/src/Aws/Ec2/NetworkInterfaceInterface.php
+++ b/modules/cloud_service_providers/aws_cloud/src/Aws/Ec2/NetworkInterfaceInterface.php
@@ -205,7 +205,7 @@
public function setAssociationId($association_id);
/**
- * {inheritdoc}
+ * {inheritdoc}.
*/
public function setPublicIps($public_ips);
--- a/modules/cloud_service_providers/aws_cloud/src/Entity/Ec2/NetworkInterface.php
+++ b/modules/cloud_service_providers/aws_cloud/src/Entity/Ec2/NetworkInterface.php
@@ -266,7 +266,7 @@
/**
* {@inheritdoc}
*/
- public function setPrimaryPrivateIp ($private_ip) {
+ public function setPrimaryPrivateIp($private_ip) {
return $this->set('primary_private_ip', $private_ip);
}
--- a/modules/cloud_service_providers/aws_cloud/src/Form/Ec2/AwsCloudContentForm.php
+++ b/modules/cloud_service_providers/aws_cloud/src/Form/Ec2/AwsCloudContentForm.php
@@ -91,6 +91,9 @@
parent::save($form, $form_state);
}
+ /**
+ *
+ */
protected function copyFormItemValues(array $form) {
$original_entity = $this->manager
->getStorage($this->entity->getEntityTypeId())
--- a/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/ElasticIpTest.php
+++ PHP_CodeSniffer
@@ -5,7 +5,6 @@
use Drupal\Tests\aws_cloud\Functional\Utils;
use Drupal\Component\Serialization\Yaml;
-
// Updated by yas 2016/06/23
// Updated by yas 2016/06/02
// Updated by yas 2016/05/31
@@ -90,7 +89,7 @@
$this->assertNoText(t('Notice'), t('Add | View | Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Add | View | Make sure w/o Warnings'));
- // Make sure domain is updated
+ // Make sure domain is updated.
$this->assertText($domain, t('Add | View | Make sure domain: @domain', ['@domain' => $domain]));
// Make sure listing.
@@ -166,8 +165,8 @@
]),
t('Confirm Message') . ': '
. t('Delete | The AWS Cloud Elastic IP "@name" has been deleted.', [
- '@name' => $edit[$i]['name'],
- ])
+ '@name' => $edit[$i]['name'],
+ ])
);
// Make sure listing.
@@ -179,8 +178,8 @@
for ($j = 0; $j < $i + 1; $j++) {
$this->assertNoText($edit[$j]['name'],
t('Delete | List | Make sure w/ Listing: @name', [
- '@name' => $edit[$j]['name'],
- ]));
+ '@name' => $edit[$j]['name'],
+ ]));
}
}
}
@@ -267,4 +266,5 @@
$mock_data['DescribeInstances']['Reservations'][0]['Instances'][] = $instance_mock_data;
$this->updateMockDataToConfig($mock_data);
}
+
}
......@@ -352,15 +352,17 @@ function aws_cloud_entity_type_alter(array &$entity_types) {
*/
function aws_cloud_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
if ($entity->getEntityTypeId() == 'aws_cloud_key_pair' && $view_mode == 'full') {
$keypair = \Drupal::entityTypeManager()->getStorage('aws_cloud_key_pair')->load($entity->id());
// If the key is on the server, prompt user to download it.
if ($keypair->getKeyFileLocation() != FALSE) {
$url = Url::fromRoute('entity.aws_cloud_key_pair.download', ['cloud_context' => $keypair->getCloudContext(), 'aws_cloud_key_pair' => $keypair->id()])->toString();
$messenger = \Drupal::messenger();
$messenger->addWarning(t('<a href="@download_link">Download private key</a>. Once downloaded, the key will be deleted from the server.',
['@download_link' => $url]
));
if ($entity->id() != NULL) {
$keypair = \Drupal::entityTypeManager()->getStorage('aws_cloud_key_pair')->load($entity->id());
// If the key is on the server, prompt user to download it.
if ($keypair->getKeyFileLocation() != FALSE) {
$url = Url::fromRoute('entity.aws_cloud_key_pair.download', ['cloud_context' => $keypair->getCloudContext(), 'aws_cloud_key_pair' => $keypair->id()])->toString();
$messenger = \Drupal::messenger();
$messenger->addWarning(t('<a href="@download_link">Download private key</a>. Once downloaded, the key will be deleted from the server.',
['@download_link' => $url]
));
}
}
}
}
......
......@@ -451,7 +451,7 @@ entity.aws_cloud_key_pair.import_form:
perm: 'add aws cloud key pair'
entity.aws_cloud_key_pair.edit_form:
path: '/clouds/aws_cloud/{cloud_context}/key_pair/{aws_cloud_key_pair}'
path: '/clouds/aws_cloud/{cloud_context}/key_pair/{aws_cloud_key_pair}/edit'
defaults:
_entity_form: 'aws_cloud_key_pair.edit'
_title: 'Edit AWS Cloud Key Pair'
......
......@@ -28,9 +28,8 @@ use Drupal\Core\Field\BaseFieldDefinition;
* id = "aws_cloud_key_pair",
* label = @Translation("AWS Cloud Key Pair"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder" ,
* "view_builder" = "Drupal\aws_cloud\Entity\Ec2\KeyPairViewBuilder" ,
* "list_builder" = "Drupal\aws_cloud\Controller\Ec2\KeyPairListBuilder",
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "views_data" = "Drupal\aws_cloud\Entity\Ec2\KeyPairViewsData" ,
* "form" = {
* "default" = "Drupal\aws_cloud\Form\Ec2\KeyPairEditForm" ,
......
<?php
namespace Drupal\aws_cloud\Entity\Ec2;
/**
* Provides the key pair view builders.
*/
class KeyPairViewBuilder extends Ec2BaseViewBuilder {
/**
* {@inheritdoc}
*/
protected function getFieldsetDefs() {
return [
[
'name' => 'key_pair',
'title' => t('Key Pair'),
'open' => TRUE,
'fields' => [
'key_fingerprint',
'key_material',
],
],
[
'name' => 'others',
'title' => t('Others'),
'open' => FALSE,
'fields' => ['user_id'],
],
];
}
}
......@@ -2,8 +2,6 @@
namespace Drupal\aws_cloud\Form\Ec2;
use Drupal\aws_cloud\Service\AwsEc2ServiceInterface;
use Drupal\cloud\Form\CloudContentForm;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Messenger\Messenger;
......@@ -12,6 +10,10 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Plugin\CachedDiscoveryClearerInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\aws_cloud\Service\AwsEc2ServiceInterface;
use Drupal\cloud\Form\CloudContentForm;
use Drupal\cloud\Plugin\CloudConfigPluginManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -185,4 +187,54 @@ class AwsCloudContentForm extends CloudContentForm {
$this->cacheRender->invalidateAll();
}
/**
* Add the build array of fieldset others.
*
* @param array &$form
* The form array.
* @param int $weight
* The weight of the fieldset.
*/
protected function addOthersFieldset(array &$form, $weight) {
$form['others'] = [
'#type' => 'details',
'#title' => $this->t('Others'),
'#open' => FALSE,
'#weight' => $weight,
];
$form['others']['cloud_context'] = [
'#type' => 'item',
'#title' => $this->getItemTitle($this->t('Cloud ID')),
'#markup' => !$this->entity->isNew()
? $this->entity->getCloudContext()
: $cloud_context,
];
$form['others']['langcode'] = [
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $this->entity->getUntranslated()->language()->getId(),
'#languages' => Language::STATE_ALL,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => FALSE,
];
$form['others']['user_id'] = $form['user_id'];
unset($form['user_id']);
}
/**
* Helper function to get title translatable string of a item.
*
* @param \Drupal\Core\StringTranslation\TranslatableMarkup $t
* The translatable string.
*
* @return string
* The string of title.
*/
protected function getItemTitle(TranslatableMarkup $t) {
return $t->render() . ': ';
}
}
......@@ -20,75 +20,57 @@ class ElasticIpEditForm extends AwsCloudContentForm {
$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['ip_address'] = [
'#type' => 'details',
'#title' => $this->t('IP Address'),
'#open' => TRUE,
'#weight' => $weight++,
];
$form['name'] = [
$form['ip_address']['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Name'),
'#maxlength' => 255,
'#size' => 60,
'#default_value' => $entity->label(),
'#weight' => -5,
];
$form['public_ip'] = [
'#type' => 'textfield',
'#title' => $this->t('Elastic IP'),
'#maxlength' => 15,
'#size' => 60,
'#default_value' => $entity->getPublicIp(),
'#required' => FALSE,
'#weight' => -5,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$form['ip_address']['public_ip'] = [
'#type' => 'item',
'#title' => $this->getItemTitle($this->t('Elastic IP')),
'#markup' => $entity->getPublicIp(),
];
$form['domain'] = [
'#type' => 'textfield',
'#title' => $this->t('Domain (standard | vpc)'),
'#maxlength' => 64,
'#size' => 60,
'#default_value' => $entity->getDomain(),
'#required' => FALSE,
'#weight' => -5,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$form['assign'] = [
'#type' => 'details',
'#title' => $this->t('Assign'),
'#open' => TRUE,
'#weight' => $weight++,
];
$form['allocation_id'] = [
'#type' => 'textfield',
'#title' => $this->t('Allocation ID'),
'#maxlength' => 64,
'#size' => 60,
'#default_value' => $entity->getAllocationId(),
'#required' => FALSE,
'#weight' => -5,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$form['assign']['instance_id'] = $this->entityLinkRenderer->renderFormElements(
$entity->getInstanceId(),
'aws_cloud_instance',
'instance_id',
['#title' => $this->getItemTitle($this->t('Instance ID'))]
);
$form['assign']['allocation_id'] = [
'#type' => 'item',
'#title' => $this->getItemTitle($this->t('Allocation ID')),
'#markup' => $entity->getAllocationId(),
];
$form['instance_id'] = [
'#type' => 'textfield',
'#title' => $this->t('Instance ID'),
'#maxlength' => 64,
'#size' => 60,
'#default_value' => $entity->getInstanceId(),
'#required' => FALSE,
'#weight' => -5,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$form['assign']['domain'] = [
'#type' => 'item',
'#title' => $this->getItemTitle($this->t('Domain (standard | vpc)')),
'#markup' => $entity->getDomain(),
];
$this->addOthersFieldset($form, $weight++);
$form['actions'] = $this->actions($form, $form_state, $cloud_context);
$association_id = $this->entity->getAssociationId();
if (isset($association_id)) {
......
......@@ -53,146 +53,127 @@ class ImageEditForm extends AwsCloudContentForm {
$form['image']['ami_name'] = [
'#type' => 'item',
'#title' => $this->t('AMI Name: '),
'#title' => $this->getItemTitle($this->t('AMI Name')),
'#markup' => $entity->getAmiName(),
];
$form['image']['image_id'] = [
'#type' => 'item',
'#title' => $this->t('Image ID: '),
'#title' => $this->getItemTitle($this->t('Image ID')),
'#markup' => $entity->getImageId(),
];
$form['image']['account_id'] = [
'#type' => 'item',
'#title' => $this->t('Owner: '),
'#title' => $this->getItemTitle($this->t('Owner')),
'#markup' => $entity->getAccountId(),
];
$form['image']['source'] = [
'#type' => 'item',
'#title' => $this->t('Source: '),
'#title' => $this->getItemTitle($this->t('Source')),
'#markup' => $entity->getSource(),
];
$form['image']['status'] = [
'#type' => 'item',
'#title' => $this->t('Status: '),
'#markup' => $entity->getStatus(),
'#title' => $this->getItemTitle($this->t('Status')),
'#markup' => $entity->getStatus(),
];
$form['image']['state_reason'] = [
'#type' => 'item',
'#title' => $this->t('State Reason: '),
'#markup' => $entity->getStateReason(),
'#title' => $this->getItemTitle($this->t('State Reason')),
'#markup' => $entity->getStateReason(),
];
$form['type'] = [
'#type' => 'details',
'#title' => $this->t('Type: '),
'#title' => $this->getItemTitle($this->t('Type')),
'#open' => TRUE,
'#weight' => $weight++,
];
$form['type']['platform'] = [
'#type' => 'item',
'#title' => $this->t('Platform: '),
'#title' => $this->getItemTitle($this->t('Platform')),
'#markup' => $entity->getPlatform(),
];
$form['type']['architecture'] = [
'#type' => 'item',
'#title' => $this->t('Architecture: '),
'#title' => $this->getItemTitle($this->t('Architecture')),
'#markup' => $entity->getArchitecture(),
];
$form['type']['virtualization_type'] = [
'#type' => 'item',
'#title' => $this->t('Virtualization Type: '),
'#title' => $this->getItemTitle($this->t('Virtualization Type')),
'#markup' => $entity->getVirtualizationType(),
];
$form['type']['product_code'] = [
'#type' => 'item',
'#title' => $this->t('Product Code: '),
'#title' => $this->getItemTitle($this->t('Product Code')),
'#markup' => $entity->getProductCode(),
];
$form['type']['image_type'] = [
'#type' => 'item',
'#title' => $this->t('Image Type: '),
'#title' => $this->getItemTitle($this->t('Image Type')),
'#markup' => $entity->getImageType(),
];
$form['device'] = [
'#type' => 'details',
'#title' => $this->t('Device: '),
'#title' => $this->getItemTitle($this->t('Device')),
'#open' => TRUE,
'#weight' => $weight++,
];
$form['device']['root_device_name'] = [
'#type' => 'item',
'#title' => $this->t('Root Device Name: '),
'#title' => $this->getItemTitle($this->t('Root Device Name')),
'#markup' => $entity->getRootDeviceName(),
];
$form['device']['root_device_type'] = [
'#type' => 'item',
'#title' => $this->t('Root Device Type: '),
'#title' => $this->getItemTitle($this->t('Root Device Type')),
'#markup' => $entity->getRootDeviceType(),
];
$form['device']['kernel_id'] = [
'#type' => 'item',
'#title' => $this->t('Kernel ID: '),
'#title' => $this->getItemTitle($this->t('Kernel ID')),
'#markup' => $entity->getKernelId(),
];
$form['device']['ramdisk_id'] = [
'#type' => 'item',
'#title' => $this->t('Ramdisk ID: '),
'#title' => $this->getItemTitle($this->t('Ramdisk ID')),
'#markup' => $entity->getRamdiskId(),
];
$form['device']['block_devices'] = [
'#type' => 'item',
'#title' => $this->t('Block Devices: '),
'#title' => $this->getItemTitle($this->t('Block Devices')),
'#markup' => $entity->getBlockDevices(),
];
$form['others'] = [
'#type' => 'details',
'#title' => $this->t('Others'),
'#open' => FALSE,
'#weight' => $weight++,
];
$form['others']['cloud_context'] = [
'#type' => 'item',
'#title' => $this->t('Cloud ID: '),
'#markup' => !$entity->isNew()
? $entity->getCloudContext()
: $cloud_context,
];
$this->addOthersFieldset($form, $weight++);
// Customize others fieldset.
$old_others = $form['others'];
unset($form['others']['langcode']);
unset($form['others']['user_id']);
$form['others']['visibility'] = [
'#type' => 'item',
'#title' => $this->t('Visibility: '),
'#markup' => $entity->getVisibility(),
'#title' => $this->getItemTitle($this->t('Visibility')),
'#markup' => $entity->getVisibility(),
];
$form['others']['langcode'] = [
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $entity->getUntranslated()->language()->getId(),
'#languages' => Language::STATE_ALL,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => FALSE,
];
$form['others']['user_id'] = $form['user_id'];
unset($form['user_id']);
$form['others']['langcode'] = $old_others['langcode'];
$form['others']['user_id'] = $old_others['user_id'];
$form['actions'] = $this->actions($form, $form_state, $cloud_context);
$form['actions']['#weight'] = $weight++;
......
......@@ -46,7 +46,7 @@ class InstanceEditForm extends AwsCloudContentForm {
$form['instance']['instance_id'] = [
'#type' => 'item',
'#title' => $this->t('Instance ID: '),
'#title' => $this->getItemTitle($this->t('Instance ID')),
'#markup' => $entity->getInstanceId(),
];
......@@ -79,19 +79,19 @@ class InstanceEditForm extends AwsCloudContentForm {
$form['instance']['image_id'] = [
'#type' => 'item',
'#title' => $this->t('AMI Image: '),
'#title' => $this->getItemTitle($this->t('AMI Image')),
'#markup' => $entity->getImageId(),
];
$form['instance']['kernel_id'] = [
'#type' => 'item',
'#title' => $this->t('Kernel Image: '),
'#title' => $this->getItemTitle($this->t('Kernel Image')),
'#markup' => $entity->getKernelId(),
];
$form['instance']['ramdisk_id'] = [
'#type' => 'item',
'#title' => $this->t('Ramdisk Image: '),
'#title' => $this->getItemTitle($this->t('Ramdisk Image')),
'#markup' => $entity->getRamdiskId(),
];
......@@ -122,7 +122,7 @@ class InstanceEditForm extends AwsCloudContentForm {
$entity->getPublicIp(),
'aws_cloud_elastic_ip',
'public_ip',
['#title' => $this->t('Public IP: ')]
['#title' => $this->getItemTitle($this->t('Public IP'))]
);
}
else {
......@@ -157,7 +157,7 @@ class InstanceEditForm extends AwsCloudContentForm {
$form['network']['add_new_elastic_ip'] = [
'#type' => 'select',
'#title' => $this->t('Elastic IP: '),
'#title' => $this->getItemTitle($this->t('Elastic IP')),
'#options' => $available_elastic_ips,
'#default_value' => $current_elastic_ip != FALSE ? $current_elastic_ip->getAllocationId() : '',
];
......@@ -183,7 +183,7 @@ class InstanceEditForm extends AwsCloudContentForm {
'aws_cloud_elastic_ip',
'public_ip',
[
'#title' => $this->t('Elastic IP: '),
'#title' => $this->getItemTitle($this->t('Elastic IP')),
],
$current_elastic_ip->getName()
);
......@@ -195,12 +195,12 @@ class InstanceEditForm extends AwsCloudContentForm {
$entity->getKeyPairName(),
'aws_cloud_key_pair',
'key_pair_name',
['#title' => $this->t('Key Pair Name: ')]
['#title' => $this->getItemTitle($this->t('Key Pair Name'))]
);
$form['network']['availability_zone'] = [
'#type' => 'item',
'#title' => $this->t('Availability Zone: '),
'#title' => $this->getItemTitle($this->t('Availability Zone')),
'#markup' => $entity->getAvailabilityZone(),
];
......@@ -217,7 +217,7 @@ class InstanceEditForm extends AwsCloudContentForm {
if (count($interfaces)) {
$form['network']['network_interfaces'] = [
'#type' => 'item',
'#title' => $this->t('Network Interfaces: '),
'#title' => $this->getItemTitle($this->t('Network Interfaces')),
'#markup' => implode($interfaces),
];
}
......@@ -248,7 +248,7 @@ class InstanceEditForm extends AwsCloudContentForm {
$form['options']['is_monitoring'] = [
'#type' => 'item',
'#title' => $this->t('Monitoring Enabled: '),
'#title' => $this->getItemTitle($this->t('Monitoring Enabled')),
'#markup' => $entity->isMonitoring()
? $this->t('Enabled') : $this->t('Disabled'),
'#weight' => $weight++,
......@@ -278,7 +278,7 @@ class InstanceEditForm extends AwsCloudContentForm {
$form['options']['login_username'] = [
'#type' => 'item',
'#title' => $this->t('Login Username: '),
'#title' => $this->getItemTitle($this->t('Login Username')),
'#markup' => $entity->getLoginUsername() ?: 'ec2-user',
'#weight' => $weight++,
];
......@@ -296,32 +296,7 @@ class InstanceEditForm extends AwsCloudContentForm {
'#weight' => $weight++,
];
$form['others'] = [
'#type' => 'details',
'#title' => $this->t('Others'),
'#open' => FALSE,
'#weight' => $weight++,
];
$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' => FALSE,
];
$form['others']['user_id'] = $form['user_id'];
unset($form['user_id']);
$this->addOthersFieldset($form, $weight++);
$form['actions'] = $this->actions($form, $form_state, $cloud_context);
$form['actions']['#weight'] = $weight++;
......
<?php
// 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;
/**
* Form controller for the CloudScripting entity edit forms.
*
* @ingroup aws_cloud
*/
class KeyPairEditForm extends CloudContentForm {
class KeyPairEditForm extends AwsCloudContentForm {
/**
* Overrides Drupal\Core\Entity\EntityFormController::buildForm().
......@@ -23,53 +20,29 @@ class KeyPairEditForm 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['key_pair_name'] = [
'#type' => 'textfield',
'#title' => $this->t('Key Pair Name'),
'#maxlength' => 255,
'#size' => 60,
'#default_value' => $entity->getKeyPairName(),
'#required' => FALSE,
'#weight' => -5,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$form['key_pair'] = [
'#type' => 'details',
'#title' => $this->t('Key Pair'),
'#open' => TRUE,
'#weight' => $weight++,
];
$form['key_fingerprint'] = [
'#type' => 'textfield',
'#title' => $this->t('Fingerprint'),
'#maxlength' => 255,
'#size' => 60,
'#default_value' => $entity->getKeyFingerprint(),
'#required' => FALSE,
'#weight' => -5,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$form['key_pair']['key_pair_name'] = [
'#type' => 'item',
'#title' => $this->getItemTitle($this->t('Key Pair Name')),
'#markup' => $entity->getKeyPairName(),
];
$form['langcode'] = [
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $entity->getUntranslated()->language()->getId(),
'#languages' => Language::STATE_ALL,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$form['key_pair']['key_fingerprint'] = [
'#type' => 'item',
'#title' => $this->getItemTitle($this->t('Fingerprint')),
'#markup' => $entity->getKeyFingerprint(),
];
$this->addOthersFieldset($form, $weight);
$form['actions'] = $this->actions($form, $form_state, $cloud_context);
return $form;
......
......@@ -5,16 +5,14 @@
// 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;
/**
* Form controller for the CloudScripting entity edit forms.
*
* @ingroup aws_cloud
*/
class NetworkInterfaceEditForm extends CloudContentForm {
class NetworkInterfaceEditForm extends AwsCloudContentForm {
/**
* Overrides Drupal\Core\Entity\EntityFormController::buildForm().
......@@ -25,83 +23,62 @@ class NetworkInterfaceEditForm 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['network_interface'] = [
'#type' => 'details',
'#title' => $this->t('Network Interface'),
'#open' => TRUE,
'#weight' => $weight++,
];
$form['name'] = [
$form['network_interface']['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Name'),
'#maxlength' => 255,
'#size' => 60,
'#default_value' => $entity->label(),
'#required' => TRUE,
'#weight' => -5,
];
$form['description'] = [
$form['network_interface']['description'] = [
'#type' => 'textarea',
'#title' => $this->t('Description'),
'#maxlength' => 255,
'#cols' => 60,
'#rows' => 3,
'#default_value' => $entity->getDescription(),
'#weight' => -5,
'#required' => FALSE,
];
$form['subnet_id'] = [
'#type' => 'textfield',
'#title' => $this->t('Subnet'),
'#size' => 60,
'#default_value' => $entity->getSubnetId(),
'#weight' => -5,
'#required' => FALSE,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$form['network'] = [
'#type' => 'details',
'#title' => $this->t('Network'),
'#open' => TRUE,
'#weight' => $weight++,
];
$form['primary_private_ip'] = [
'#type' => 'textfield',
'#title' => $this->t('Private IP'),
'#size' => 60,
'#default_value' => $entity->getPrimaryPrivateIp(),
'#weight' => -5,
'#required' => FALSE,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
];
$form['network']['security_groups'] = $this->entityLinkRenderer->renderFormElements(
$entity->getSecurityGroups(),
'aws_cloud_security_group',
'group_name',
['#title' => $this->getItemTitle($this->t('Security Group'))]
);
$form['security_groups'] = [
'#type' => 'textfield',
'#title' => $this->t('Security Group'),
'#size' => 60,
'#default_value' => $entity->getSecurityGroups(),
'#weight' => -5,
'#required' => FALSE,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$form['network']['subnet_id'] = [
'#type' => 'item',
'#title' => $this->getItemTitle($this->t('Subnet')),
'#markup' => $entity->getSubnetId(),
];
$form['langcode'] = [
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $entity->getUntranslated()->language()->getId(),
'#languages' => Language::STATE_ALL,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$form['network']['primary_private_ip'] = [
'#type' => 'item',
'#title' => $this->getItemTitle($this->t('Private IP')),
'#markup' => $entity->getPrimaryPrivateIp(),
];
$this->addOthersFieldset($form, $weight++);
$form['actions'] = $this->actions($form, $form_state, $cloud_context);
return $form;
......
......@@ -47,19 +47,19 @@ class SecurityGroupEditForm extends AwsCloudContentForm {
$form['security_group']['group_name'] = [
'#type' => 'item',
'#title' => $this->t('Security Group Name: '),
'#title' => $this->getItemTitle($this->t('Security Group Name')),
'#markup' => $entity->getGroupName(),
];
$form['security_group']['description'] = [
'#type' => 'item',
'#title' => $this->t('Description: '),
'#title' => $this->getItemTitle($this->t('Description')),
'#markup' => $entity->getDescription(),
];
$form['security_group']['vpc_id'] = [
'#type' => 'item',
'#title' => $this->t('VPC ID: '),
'#title' => $this->getItemTitle($this->t('VPC ID')),
'#markup' => $entity->getVpcId(),
];
......@@ -80,32 +80,7 @@ class SecurityGroupEditForm extends AwsCloudContentForm {
unset($form['ip_permission']);
unset($form['outbound_permission']);
$form['others'] = [
'#type' => 'details',
'#title' => $this->t('Others'),
'#open' => FALSE,
'#weight' => $weight++,
];
$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' => FALSE,
];
$form['others']['user_id'] = $form['user_id'];
unset($form['user_id']);
$this->addOthersFieldset($form, $weight++);
$form['#attached']['library'][] = 'aws_cloud/aws_cloud_security_groups';
......
......@@ -56,24 +56,24 @@ class SnapshotEditForm extends AwsCloudContentForm {
$entity->getVolumeId(),
'aws_cloud_volume',
'volume_id',
['#title' => $this->t('Volume ID: ')]
['#title' => $this->getItemTitle($this->t('Volume ID'))]
);
$form['snapshot']['size'] = [
'#type' => 'item',
'#title' => $this->t('Size (GB): '),
'#title' => $this->getItemTitle($this->t('Size (GB)')),
'#markup' => $entity->getSize(),
];
$form['snapshot']['status'] = [
'#type' => 'item',
'#title' => $this->t('Status: '),
'#title' => $this->getItemTitle($this->t('Status')),
'#markup' => $entity->getStatus(),
];
$form['snapshot']['progress'] = [
'#type' => 'item',
'#title' => $this->t('Progress: '),
'#title' => $this->getItemTitle($this->t('Progress')),
'#markup' => $entity->getProgress(),
];
......@@ -84,32 +84,7 @@ class SnapshotEditForm extends AwsCloudContentForm {
'#required' => FALSE,
];
$form['others'] = [
'#type' => 'details',
'#title' => $this->t('Others'),
'#open' => FALSE,
'#weight' => $weight++,
];
$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' => FALSE,
];
$form['others']['user_id'] = $form['user_id'];
unset($form['user_id']);
$this->addOthersFieldset($form, $weight++);
$form['actions'] = $this->actions($form, $form_state, $cloud_context);
$form['actions']['#weight'] = $weight++;
......
......@@ -23,73 +23,44 @@ class VolumeEditForm extends AwsCloudContentForm {
$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['volume'] = [
'#type' => 'details',
'#title' => $this->t('Volume'),
'#open' => TRUE,
'#weight' => $weight++,
];
$form['name'] = [
$form['volume']['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Name'),
'#maxlength' => 255,
'#size' => 60,
'#default_value' => $entity->label(),
'#required' => TRUE,
'#weight' => -5,
];
$form['volume_id'] = [
'#type' => 'textfield',
'#title' => $this->t('Volume ID'),
'#maxlength' => 255,
'#size' => 60,
'#default_value' => $entity->getVolumeId(),
'#required' => FALSE,
'#weight' => -5,
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$form['volume']['volume_id'] = [
'#type' => 'item',
'#title' => $this->getItemTitle($this->t('Volume ID')),
'#markup' => $entity->getVolumeId(),
];
$form['snapshot_id'] = $this->entityLinkRenderer->renderFormElements(
$form['volume']['snapshot_id'] = $this->entityLinkRenderer->renderFormElements(
$entity->getSnapshotId(),
'aws_cloud_snapshot',
'snapshot_id',
[
'#title' => $this->t('Snapshot') . ': ',
'#weight' => -5,
]
['#title' => $this->getItemTitle($this->t('Snapshot'))]
);
$form['size'] = [
'#type' => 'textfield',
'#title' => $this->t('Size (GB)'),
'#size' => 60,
'#default_value' => $entity->getSize(),
'#weight' => -5,
'#required' => FALSE,
'#attributes' => ['readonly' => 'readonly'],
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
$form['volume']['size'] = [
'#type' => 'item',
'#title' => $this->getItemTitle($this->t('Size (GB)')),
'#markup' => $entity->getSize(),
];
$form['langcode'] = [
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $entity->getUntranslated()->language()->getId(),
'#languages' => Language::STATE_ALL,
'#attributes' => ['readonly' => 'readonly'],
'#attributes' => ['readonly' => 'readonly'],
'#disabled' => TRUE,
];
$this->addOthersFieldset($form, $weight++);
$form['actions'] = $this->actions($form, $form_state, $cloud_context);
......
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