Skip to content
Snippets Groups Projects
Commit 322ce68f authored by baldwinlouie's avatar baldwinlouie Committed by Yas Naoi
Browse files

Issue #3049523 by baldwinlouie, yas: Modify "Design" and "Cloud Service Provider" views

parent 768b44d3
No related branches found
No related tags found
No related merge requests found
......@@ -67,7 +67,6 @@ function cloud_update_8103() {
}
}
/**
* Update cloud_listing view.
*/
......@@ -162,6 +161,16 @@ function cloud_update_8111() {
\Drupal::service('module_installer')->uninstall(['cloud_server_template']);
}
/**
* Update the server template and cloud listing views.
*/
function cloud_update_8112() {
cloud_update_yml_definitions([
'views.view.cloud_listing.yml',
'views.view.server_template_listing.yml',
]);
}
/**
* Yml files to update for server template move.
*
......@@ -217,4 +226,3 @@ function get_server_template_yml_to_update() {
'field.storage.cloud_server_template.field_vpc.yml',
];
}
......@@ -100,12 +100,9 @@ display:
type: fields
fields:
name:
id: name
table: cloud_config_field_data
field: name
id: name
entity_type: null
entity_field: name
plugin_id: field
relationship: none
group_type: group
admin_label: ''
......@@ -151,7 +148,7 @@ display:
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
type: instance_link_formatter
settings: { }
group_column: value
group_columns: { }
......@@ -163,57 +160,9 @@ display:
multi_type: separator
separator: ', '
field_api_classes: false
list_instances_cloud_config:
id: list_instances_cloud_config
table: cloud_config
field: list_instances_cloud_config
relationship: none
group_type: group
admin_label: ''
label: Instances
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
text: view
entity_type: cloud_config
plugin_id: cloud_list_instances
entity_type: null
entity_field: name
plugin_id: field
pricing_internal_cloud_config:
id: pricing_internal_cloud_config
table: cloud_config
......@@ -221,7 +170,7 @@ display:
relationship: none
group_type: group
admin_label: ''
label: Instance Pricing
label: 'Instance Pricing'
exclude: false
alter:
alter_text: false
......
......@@ -92,12 +92,9 @@ display:
type: fields
fields:
name:
id: name
table: cloud_config_field_data
field: name
id: name
entity_type: null
entity_field: name
plugin_id: field
relationship: none
group_type: group
admin_label: ''
......@@ -143,7 +140,7 @@ display:
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
type: server_template_link_formatter
settings: { }
group_column: value
group_columns: { }
......@@ -155,6 +152,9 @@ display:
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: null
entity_field: name
plugin_id: field
cloud_context_1:
id: cloud_context_1
table: cloud_config_field_data
......@@ -162,7 +162,7 @@ display:
relationship: none
group_type: group
admin_label: ''
label: 'Cloud Provider Machine Name'
label: 'Cloud Provider ID'
exclude: false
alter:
alter_text: false
......@@ -220,57 +220,6 @@ display:
entity_type: cloud_config
entity_field: cloud_context
plugin_id: field
list_server_templates_cloud_config:
id: list_server_templates_cloud_config
table: cloud_config
field: list_server_templates_cloud_config
relationship: none
group_type: group
admin_label: ''
label: 'Server Templates'
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
text: view
entity_type: cloud_config
plugin_id: cloud_list_templates
filters: { }
sorts: { }
title: 'Server Templates'
......
<?php
namespace Drupal\cloud\Plugin\Field\FieldFormatter;
use Drupal\cloud\Plugin\CloudConfigPluginManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Plugin implementation of the 'instance_link_formatter' formatter.
*
* This formatter links a cloud config name to the list of server templates.
*
* @FieldFormatter(
* id = "instance_link_formatter",
* label = @Translation("Instance link"),
* field_types = {
* "string",
* "uri",
* }
* )
*/
class InstanceLinkFormatter extends FormatterBase implements ContainerFactoryPluginInterface {
/**
* CloudConfigPlugin.
*
* @var \Drupal\cloud\Plugin\CloudConfigPluginManagerInterface
*/
protected $cloudConfigPluginManager;
/**
* Constructs a StringFormatter instance.
*
* @param string $plugin_id
* The plugin_id for the formatter.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
* The definition of the field to which the formatter is associated.
* @param array $settings
* The formatter settings.
* @param string $label
* The formatter label display setting.
* @param string $view_mode
* The view mode.
* @param array $third_party_settings
* Any third party settings settings.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\cloud\Plugin\CloudConfigPluginManagerInterface $cloud_config_plugin_manager
* The cloud config plugin manager.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, EntityTypeManagerInterface $entity_type_manager, CloudConfigPluginManagerInterface $cloud_config_plugin_manager) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings, $entity_type_manager);
$this->cloudConfigPluginManager = $cloud_config_plugin_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$plugin_id,
$plugin_definition,
$configuration['field_definition'],
$configuration['settings'],
$configuration['label'],
$configuration['view_mode'],
$configuration['third_party_settings'],
$container->get('entity_type.manager'),
$container->get('plugin.manager.cloud_config_plugin')
);
}
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$entity = $items->getEntity();
foreach ($items as $delta => $item) {
if (!$item->isEmpty()) {
$this->cloudConfigPluginManager->setCloudContext($entity->getCloudContext());
$route = $this->cloudConfigPluginManager->getInstanceCollectionTemplateName();
$elements[$delta] = [
'#type' => 'link',
'#url' => Url::fromRoute($route, ['cloud_context' => $entity->getCloudContext()]),
'#title' => $item->value,
];
}
}
return $elements;
}
}
<?php
namespace Drupal\cloud\Plugin\Field\FieldFormatter;
use Drupal\cloud\Plugin\CloudConfigPluginManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Plugin implementation of the 'server_template_link_formatter' formatter.
*
* This formatter links a cloud config name to the list of server templates.
*
* @FieldFormatter(
* id = "server_template_link_formatter",
* label = @Translation("Server template link"),
* field_types = {
* "string",
* "uri",
* }
* )
*/
class ServerTemplateLinkFormatter extends FormatterBase implements ContainerFactoryPluginInterface {
/**
* CloudConfigPlugin.
*
* @var \Drupal\cloud\Plugin\CloudConfigPluginManagerInterface
*/
protected $cloudConfigPluginManager;
/**
* Constructs a StringFormatter instance.
*
* @param string $plugin_id
* The plugin_id for the formatter.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
* The definition of the field to which the formatter is associated.
* @param array $settings
* The formatter settings.
* @param string $label
* The formatter label display setting.
* @param string $view_mode
* The view mode.
* @param array $third_party_settings
* Any third party settings settings.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\cloud\Plugin\CloudConfigPluginManagerInterface $cloud_config_plugin_manager
* The cloud config plugin manager.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, EntityTypeManagerInterface $entity_type_manager, CloudConfigPluginManagerInterface $cloud_config_plugin_manager) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings, $entity_type_manager);
$this->cloudConfigPluginManager = $cloud_config_plugin_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$plugin_id,
$plugin_definition,
$configuration['field_definition'],
$configuration['settings'],
$configuration['label'],
$configuration['view_mode'],
$configuration['third_party_settings'],
$container->get('entity_type.manager'),
$container->get('plugin.manager.cloud_config_plugin')
);
}
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$entity = $items->getEntity();
foreach ($items as $delta => $item) {
if (!$item->isEmpty()) {
$this->cloudConfigPluginManager->setCloudContext($entity->getCloudContext());
$route = $this->cloudConfigPluginManager->getServerTemplateCollectionName();
$elements[$delta] = [
'#type' => 'link',
'#url' => Url::fromRoute($route, ['cloud_context' => $entity->getCloudContext()]),
'#title' => $item->value,
];
}
}
return $elements;
}
}
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