From 64f16ae75741903f90512194aae799c4f0bf4c8d Mon Sep 17 00:00:00 2001 From: Tomasz Kryszan Date: Mon, 25 Mar 2024 14:49:32 +0100 Subject: [PATCH] IBX-7981: [DAM] Added folder configuration (#1217) * Added parameters for folder configuration * Added folder configuration to DamWidget * [Tests] Adjusted DamWidgetTest --- .../Resources/config/default_parameters.yaml | 2 ++ .../config/services/ui_config/common.yaml | 3 +++ .../UI/Config/Provider/Module/DamWidget.php | 10 +++++-- .../Config/Provider/Module/DamWidgetTest.php | 27 ++++++++++++++----- 4 files changed, 33 insertions(+), 9 deletions(-) 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 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 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, + ], ]; }