From 04abb006e59447b5541ba7d5ca29f0309170f048 Mon Sep 17 00:00:00 2001 From: Tomasz Kryszan Date: Tue, 19 Mar 2024 09:37:31 +0100 Subject: [PATCH 1/3] Added parameters for folder configuration --- src/bundle/Resources/config/default_parameters.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bundle/Resources/config/default_parameters.yaml b/src/bundle/Resources/config/default_parameters.yaml index bcb08bf090..755afb5520 100644 --- a/src/bundle/Resources/config/default_parameters.yaml +++ b/src/bundle/Resources/config/default_parameters.yaml @@ -88,3 +88,5 @@ parameters: name: keywords contentTypeIdentifier: image fieldDefinitionIdentifier: tags + ibexa.dam_widget.folder.content_type_identifier: folder + ibexa.dam_widget.folder.name_field_identifier: name From 0729ac01e4a4eaac5b54c2a6f6a5778be8ec14e4 Mon Sep 17 00:00:00 2001 From: Tomasz Kryszan Date: Tue, 19 Mar 2024 09:38:38 +0100 Subject: [PATCH 2/3] Added folder configuration to DamWidget --- .../Resources/config/services/ui_config/common.yaml | 3 +++ src/lib/UI/Config/Provider/Module/DamWidget.php | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/bundle/Resources/config/services/ui_config/common.yaml b/src/bundle/Resources/config/services/ui_config/common.yaml index 644d11ece7..acc6a323c7 100644 --- a/src/bundle/Resources/config/services/ui_config/common.yaml +++ b/src/bundle/Resources/config/services/ui_config/common.yaml @@ -150,6 +150,9 @@ services: fieldDefinitionIdentifiers: '%ibexa.dam_widget.image.field_definition_identifiers%' contentTypeIdentifiers: '%ibexa.dam_widget.image.content_type_identifiers%' aggregations: '%ibexa.dam_widget.image.aggregations%' + folder: + contentTypeIdentifier: '%ibexa.dam_widget.folder.content_type_identifier%' + nameFieldIdentifier: '%ibexa.dam_widget.folder.name_field_identifier%' tags: - { name: ibexa.admin_ui.config.provider, key: 'damWidget' } diff --git a/src/lib/UI/Config/Provider/Module/DamWidget.php b/src/lib/UI/Config/Provider/Module/DamWidget.php index 562ed31948..0338efc76b 100644 --- a/src/lib/UI/Config/Provider/Module/DamWidget.php +++ b/src/lib/UI/Config/Provider/Module/DamWidget.php @@ -13,12 +13,17 @@ use Ibexa\Contracts\AdminUi\UI\Config\ProviderInterface; /** + * @template TFolderConfig of array{ + * contentTypeIdentifier: string, + * nameFieldIdentifier: string + * } * @template TConfig of array{ * image: array{ * fieldDefinitionIdentifiers: array, * contentTypeIdentifiers: array, * aggregations: array>, - * } + * }, + * folder: TFolderConfig * } */ final class DamWidget implements ProviderInterface @@ -46,7 +51,8 @@ public function __construct( * contentTypeIdentifiers: array, * aggregations: array>, * showImageFilters: bool, - * } + * }, + * folder: TFolderConfig * } * * @throws \Ibexa\Bundle\Core\ApiLoader\Exception\InvalidSearchEngine From ace83baba3a9ed944be01d85bef4ead4914ffb4e Mon Sep 17 00:00:00 2001 From: Tomasz Kryszan Date: Tue, 19 Mar 2024 09:38:56 +0100 Subject: [PATCH 3/3] [Tests] Adjusted DamWidgetTest --- .../Config/Provider/Module/DamWidgetTest.php | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/lib/UI/Config/Provider/Module/DamWidgetTest.php b/tests/lib/UI/Config/Provider/Module/DamWidgetTest.php index 97a310476a..c9b00e7c8d 100644 --- a/tests/lib/UI/Config/Provider/Module/DamWidgetTest.php +++ b/tests/lib/UI/Config/Provider/Module/DamWidgetTest.php @@ -21,7 +21,9 @@ * contentTypeIdentifiers: array, * aggregations: aggregations: array>, * showImageFilters: bool, - * } + * }, + * contentTypeIdentifier: string, + * nameFieldIdentifier: string, * } * @template TRepositoryConfig of array { * engine: string, @@ -35,8 +37,8 @@ */ final class DamWidgetTest extends TestCase { - private const FIELD_DEFINITION_IDENTIFIERS = ['field_foo', 'field_bar']; - private const CONTENT_TYPE_IDENTIFIERS = ['content_type_foo', 'content_type_bar']; + private const IMAGE_FIELD_DEFINITION_IDENTIFIERS = ['field_foo', 'field_bar']; + private const IMAGE_CONTENT_TYPE_IDENTIFIERS = ['content_type_foo', 'content_type_bar']; private const IMAGE_AGGREGATIONS = [ 'KeywordTermAggregation' => [ 'name' => 'keywords', @@ -45,6 +47,9 @@ final class DamWidgetTest extends TestCase ], ]; + private const FOLDER_CONTENT_TYPE_IDENTIFIER = 'folder'; + private const FOLDER_NAME_FIELD_IDENTIFIER = 'name'; + private ProviderInterface $provider; /** @var \Ibexa\Bundle\Core\ApiLoader\RepositoryConfigurationProvider&\PHPUnit\Framework\MockObject\MockObject */ @@ -56,10 +61,14 @@ protected function setUp(): void $this->provider = new DamWidget( [ 'image' => [ - 'fieldDefinitionIdentifiers' => self::FIELD_DEFINITION_IDENTIFIERS, - 'contentTypeIdentifiers' => self::CONTENT_TYPE_IDENTIFIERS, + 'fieldDefinitionIdentifiers' => self::IMAGE_FIELD_DEFINITION_IDENTIFIERS, + 'contentTypeIdentifiers' => self::IMAGE_CONTENT_TYPE_IDENTIFIERS, 'aggregations' => self::IMAGE_AGGREGATIONS, ], + 'folder' => [ + 'contentTypeIdentifier' => self::FOLDER_CONTENT_TYPE_IDENTIFIER, + 'nameFieldIdentifier' => self::FOLDER_NAME_FIELD_IDENTIFIER, + ], ], $this->repositoryConfigurationProvider ); @@ -130,11 +139,15 @@ private function getExpectedConfig(bool $showImageFilters): array { return [ 'image' => [ - 'fieldDefinitionIdentifiers' => self::FIELD_DEFINITION_IDENTIFIERS, - 'contentTypeIdentifiers' => self::CONTENT_TYPE_IDENTIFIERS, + 'fieldDefinitionIdentifiers' => self::IMAGE_FIELD_DEFINITION_IDENTIFIERS, + 'contentTypeIdentifiers' => self::IMAGE_CONTENT_TYPE_IDENTIFIERS, 'aggregations' => self::IMAGE_AGGREGATIONS, 'showImageFilters' => $showImageFilters, ], + 'folder' => [ + 'contentTypeIdentifier' => self::FOLDER_CONTENT_TYPE_IDENTIFIER, + 'nameFieldIdentifier' => self::FOLDER_NAME_FIELD_IDENTIFIER, + ], ]; }