Skip to content
Snippets Groups Projects
Commit 15353e18 authored by Florent Torregrosa's avatar Florent Torregrosa Committed by Pierre Dureau
Browse files

Issue #3336970 by christian.wiedemann, grimreaper, pdureau: Fix config schema

parent 5dc1727b
Branches
Tags
1 merge request!91Issue #3336970 by Grimreaper, pdureau: [2.0.0-alpha3] WIP: Fix config schema
Pipeline #397732 passed
Showing
with 341 additions and 16 deletions
ui_patterns_component:
type: mapping
label: 'Component configuration'
constraints:
FullyValidatable: ~
mapping:
component_id:
type: string
label: 'Component ID'
nullable: true
variant_id:
type: ui_patterns_prop
nullable: true
label: 'Variant ID'
# @todo make a mechanism that will check the props keys depending on the
# the component ID. And so maybe convert into mapping.
props:
type: sequence
label: 'Props'
sequence:
type: ui_patterns_prop
label: 'Prop'
# @todo make a mechanism that will check the slots keys depending on the
# the component ID. And so maybe convert into mapping.
slots:
type: sequence
label: 'Slots'
sequence:
type: ui_patterns_slot
label: 'Slot'
ui_patterns_prop:
type: mapping
label: 'Prop'
mapping:
source_id:
type: string
label: 'Prop source ID'
source:
type: ui_patterns_source.[%parent.source_id]
label: 'Prop source configuration'
ui_patterns_slot:
type: mapping
label: 'Slot'
mapping:
sources:
type: sequence
label: 'Slot sources'
sequence:
type: ui_patterns_slot_source
label: 'Slot source'
ui_patterns_slot_source:
type: mapping
label: 'Slot source'
mapping:
source_id:
type: string
label: 'Slot source ID'
source:
type: ui_patterns_source.[%parent.source_id]
label: 'Slot source configuration'
_weight:
type: string
label: 'Slot source weight'
ui_patterns_source.checkbox:
type: mapping
label: 'Source: checkbox'
mapping:
value:
type: boolean
label: 'Checkbox value'
ui_patterns_source.attribute:
type: mapping
label: 'Source: attribute'
mapping:
value:
type: boolean
label: 'Attribute value'
ui_patterns_source.path:
type: mapping
label: 'Source: Path'
mapping:
value:
type: path
label: 'Path value'
ui_patterns_source.url:
type: mapping
label: 'Source: URL'
mapping:
value:
type: uri
label: 'URL value'
ui_patterns_source.textfield:
type: mapping
label: 'Source: Textfield'
mapping:
value:
type: string
label: 'String value'
ui_patterns_source.select:
type: mapping
label: 'Source: Select'
mapping:
value:
type: string
label: 'Select value'
ui_patterns_source.selects:
type: mapping
label: 'Source: Selects'
mapping:
value:
type: sequence
label: 'Selects value'
sequence:
type: string
label: 'Values'
ui_patterns_source.attributes:
type: mapping
label: 'Source: Attributes'
mapping:
value:
type: string
label: 'Attribute value'
ui_patterns_source.attributes_class:
type: mapping
label: 'Source: Attributes Class'
mapping:
value:
type: string
label: 'Attributes Class value'
ui_patterns_source.list_textarea:
type: mapping
label: 'Source: List Text area'
mapping:
value:
type: string
label: 'Source List Text area values'
ui_patterns_source.number:
type: mapping
label: 'Source: Number'
mapping:
value:
type: string
label: 'Number value'
ui_patterns_source.wysiwyg:
type: mapping
label: 'Source: WYSIWYG'
mapping:
value:
type: text_format
label: 'WYSIWYG value'
ui_patterns_source.component:
type: mapping
label: 'Source: Component'
mapping:
component:
type: ui_patterns_component
ui_patterns_source.checkboxes:
type: mapping
label: 'Source: Checkboxes'
mapping:
value:
type: sequence
label: 'Selects value'
sequence:
type: string
label: 'Select Item Value'
ui_patterns_source.entity_link:
type: mapping
label: 'Source: Entity Link'
mapping:
template:
type: string
ui_patterns_source.menu:
type: mapping
label: 'Source: Menu'
mapping:
menu:
type: string
label: 'Menu Name'
level:
type: string
label: 'Entry Level'
depth:
type: string
label: 'Menu depth'
ui_patterns_source.token:
type: mapping
label: 'Source: Token'
mapping:
value:
type: string
label: 'Token value'
ui_patterns_source.field_property:*:*:*:
type: mapping
label: 'Source: Field Property'
mapping:
type:
type: string
label: 'Field Property type'
# block uses dynamic subkeys not under a specific key.
# The configuration looks like:
# plugin_id: block_id
# block_id:
# config_1: #
# I cant find a solution to handle this correct. Sequences would work
# if the the block_id key would be under an extra key. Something like config.block_id
ui_patterns_source.block:
type: ignore
# Same here ui_patterns_source.block
ui_patterns_source.entity_field:
type: ignore
block.settings.ui_patterns:*:*:
type: block_settings
label: 'Component block'
mapping:
ui_patterns:
type: ui_patterns_component
label: 'The component configuration'
block.settings.ui_patterns_entity:*:*:
type: block_settings
label: 'Entity Component block'
mapping:
ui_patterns:
type: ui_patterns_component
label: 'The component configuration'
......@@ -30,7 +30,7 @@ class BlockLayoutTest extends UiPatternsFunctionalTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = FALSE;
protected $strictConfigSchema = TRUE;
/**
* The layout plugin manager.
......@@ -61,7 +61,6 @@ class BlockLayoutTest extends UiPatternsFunctionalTestBase {
* Test the form and the existence of the.
*/
public function testBlockLayout(): void {
$assert_session = $this->assertSession();
$test_data = self::loadTestDataFixture();
$test_blocks_no_context = self::loadTestDataFixture(__DIR__ . "/../../fixtures/tests.blocks.no_context.yml");
$tests = array_merge($test_data->getTestSets(), $test_blocks_no_context->getTestSets());
......
......@@ -46,7 +46,7 @@ class LayoutBuilderBlockRenderTest extends UiPatternsFunctionalTestBase {
$this->createTestContentContentType();
$assert_session = $this->assertSession();
$config_import = $this->loadConfigFixture(__DIR__ . '/../../fixtures/config/core.entity_view_display.node.page.full.layout_builder.classic.yml');
$ui_patterns_config = &$config_import['third_party_settings']['layout_builder']['sections'][0]['components']['e35dd171-c69c-451f-a035-88dcb7a80af5']['configuration']['formatter']['settings']['ui_patterns'];
$ui_patterns_config = &$config_import['third_party_settings']['layout_builder']['sections'][0]['components']['e35dd171-c69c-451f-a035-88dcb7a80af5']['configuration']['ui_patterns'];
$test_data = $this->loadTestDataFixture();
$test_set = $test_data->getTestSet('context_exists_default');
$ui_patterns_config = $this->buildUiPatternsConfig($test_set);
......
......@@ -23,7 +23,7 @@ class SourcesDeriverTest extends SourcePluginsTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = FALSE;
protected $strictConfigSchema = TRUE;
/**
* The layout plugin manager.
......
field.formatter.settings.ui_patterns:
type: mapping
label: 'Component'
mapping:
ui_patterns:
type: ui_patterns_component
label: 'The component'
field.formatter.settings.ui_patterns_component:
type: field.formatter.settings.ui_patterns
label: 'Component for all (UI Patterns)'
field.formatter.settings.ui_patterns_component_per_item:
type: field.formatter.settings.ui_patterns
label: 'Component for each (UI Patterns)'
ui_patterns_source.field_formatter:*:*:*:
type: mapping
label: 'Source: field_formatter'
mapping:
type:
type: string
label: 'Field formatter type'
settings:
type: field.formatter.settings.[%parent.type]
label: 'Field formatter settings'
......@@ -14,6 +14,11 @@ class FieldFormatterRenderTest extends UiPatternsFunctionalTestBase {
use TestDataTrait;
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = TRUE;
/**
* {@inheritdoc}
*/
......@@ -31,7 +36,6 @@ class FieldFormatterRenderTest extends UiPatternsFunctionalTestBase {
* Tests preview and output of props.
*/
public function testRender(): void {
$assert_session = $this->assertSession();
$test_data = self::loadTestDataFixture();
$test_data_field_formatters = self::loadTestDataFixture(__DIR__ . "/../../fixtures/tests.formatter_per_item.yml");
$tests = array_merge($test_data->getTestSets(), $test_data_field_formatters->getTestSets());
......
......@@ -26,7 +26,7 @@ class SourcesDeriverTest extends SourcePluginsTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = FALSE;
protected $strictConfigSchema = TRUE;
/**
* The source plugin manager.
......
layout_plugin.settings.*:
type: layout_plugin.settings
label: 'Layout component configuration'
constraints:
FullyValidatable: ~
mapping:
ui_patterns:
type: ui_patterns_component
label: 'The component configuration'
......@@ -8,6 +8,7 @@ use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Layout\LayoutDefinition;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Theme\ComponentPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
......@@ -20,6 +21,8 @@ use Symfony\Component\Filesystem\Path;
*/
class ComponentLayout extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* Constructs new ComponentLayout Deriver.
*
......@@ -59,7 +62,7 @@ class ComponentLayout extends DeriverBase implements ContainerDeriverInterface {
"class" => $base_plugin_definition->getClass(),
], [
'label' => $component['annotated_name'] ?? $component['name'] ?? $component['id'],
'category' => $component['group'] ?? t('Others'),
'category' => $component['group'] ?? $this->t('Others'),
'provider' => $component['provider'],
'id' => $component['id'],
'context_definitions' => [
......
......@@ -22,7 +22,7 @@ class SourcesDeriverTest extends SourcePluginsTestBase {
/**
* {@inheritdoc}
*/
protected $strictConfigSchema = FALSE;
protected $strictConfigSchema = TRUE;
/**
* The layout plugin manager.
......
views.style.ui_patterns:
type: views_style
label: 'Views style'
mapping:
ui_patterns:
type: views.ui_patterns_configuration
label: 'Views UI Patterns sub key'
views.ui_patterns_configuration:
type: views_style
label: 'Views style'
mapping:
ui_patterns:
type: ui_patterns_component
label: 'The component'
views.row.ui_patterns:
type: views_row
label: 'Views row style'
mapping:
hide_empty:
type: boolean
ui_patterns:
type: ui_patterns_component
label: 'The component'
ui_patterns_source.view_field:
type: mapping
label: 'Source: Token'
mapping:
ui_patterns_views_field:
type: string
label: 'Token value'
ui_patterns_source.view_rows:
type: mapping
label: 'Source: view_rows'
mapping:
ui_patterns_views_field:
type: string
label: 'Field name'
......@@ -72,7 +72,6 @@ display:
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
......@@ -160,7 +159,6 @@ display:
default_field_elements: true
inline: { }
separator: ''
hide_empty: false
query:
type: views_query
options:
......
......@@ -196,7 +196,6 @@ display:
row:
type: ui_patterns
options:
hide_empty: 0
ui_patterns: {}
defaults:
title: false
......
......@@ -120,7 +120,7 @@ class EntityReferencedDerivableContextDeriver extends EntityFieldSourceDeriverBa
$bundle_label = ($target_bundle !== "" && (count($target_bundle_to_label) > 1)) ? $entity_bundle_label : sprintf("%s (%s)", $entity_bundle_label, $target_entity_label);
$this->derivatives[$id] = array_merge($base_plugin_derivative, [
"id" => $id,
"label" => t("@bundle referenced by @field", [
"label" => $this->t("@bundle referenced by @field", [
"@field" => $base_label,
"@bundle" => ($target_bundle == "") ? $target_entity_label : $bundle_label,
]),
......@@ -137,7 +137,7 @@ class EntityReferencedDerivableContextDeriver extends EntityFieldSourceDeriverBa
$field_storage_metadata = $this->entityFieldsMetadata[$entity_type_id]["field_storages"][$field_name];
$this->derivatives[$id_no_bundle] = array_merge($this->derivatives[$id], [
"id" => $id_no_bundle,
"label" => t("@target referenced by @field", [
"label" => $this->t("@target referenced by @field", [
"@field" => $field_storage_metadata["label"] ?? $field_name,
"@target" => $target_entity_label,
]),
......
......@@ -57,11 +57,11 @@ class AttributesWidget extends SourcePluginPropValue implements TrustedCallbackI
];
if (static::isValueForAttributes($value)) {
$form['value']['#pattern_unicode'] = static::buildAttributesRegexPattern();
$form['value']['#pattern_error'] = t('Format is not HTML attributes with double-quoted values.');
$form['value']['#pattern_error'] = $this->t('Format is not HTML attributes with double-quoted values.');
}
else {
$form['value']['#pattern_unicode'] = static::buildClassRegexPattern();
$form['value']['#pattern_error'] = t('Not a valid space-separated list of HTML classes.');
$form['value']['#pattern_error'] = $this->t('Not a valid space-separated list of HTML classes.');
}
// To allow form errors to be displayed correctly.
$form['value']['#title'] = '';
......
......@@ -51,7 +51,7 @@ class EntityReferencedSource extends DerivableContextSourceBase {
}
foreach ($groups as $group_key => $grouped_option_keys) {
$group = (string) $options[$group_key];
$returned[$group] = [$group_key => t('- All -')];
$returned[$group] = [$group_key => $this->t('- All -')];
foreach ($grouped_option_keys as $grouped_option_key) {
if ($grouped_option_key !== $group_key) {
$label = (string) $options[$grouped_option_key];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment