Skip to content

Commit

Permalink
IBX-7981: [DAM] Added folder configuration (#1217)
Browse files Browse the repository at this point in the history
* Added parameters for folder configuration

* Added folder configuration to DamWidget

* [Tests] Adjusted DamWidgetTest
  • Loading branch information
ciastektk authored Mar 25, 2024
1 parent 79ce1a1 commit 64f16ae
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/bundle/Resources/config/default_parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ parameters:
name: keywords
contentTypeIdentifier: image
fieldDefinitionIdentifier: tags
ibexa.dam_widget.folder.content_type_identifier: folder

This comment has been minimized.

Copy link
@patrickallaert

patrickallaert Jul 1, 2024

Config change happening in a dot release?!

This change implies that a "folder" content type exists. A requirement that was not part of ibexa v4.6.0 -> v4.6.3 and is now one as of version >=4.6.4 (which includes several "improvements" according to: https://github.com/ibexa/oss/releases/tag/v4.6.4)

It is totally against Semantic Versioning to include anything else than hotfixes in dot releases!

Failing to do so, this is how issues like IBX-8285 (@emodric) pops up.

ibexa.dam_widget.folder.name_field_identifier: name
3 changes: 3 additions & 0 deletions src/bundle/Resources/config/services/ui_config/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }

Expand Down
10 changes: 8 additions & 2 deletions src/lib/UI/Config/Provider/Module/DamWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>,
* contentTypeIdentifiers: array<string>,
* aggregations: array<string, array<string, string>>,
* }
* },
* folder: TFolderConfig
* }
*/
final class DamWidget implements ProviderInterface
Expand Down Expand Up @@ -46,7 +51,8 @@ public function __construct(
* contentTypeIdentifiers: array<string>,
* aggregations: array<string, array<string, string>>,
* showImageFilters: bool,
* }
* },
* folder: TFolderConfig
* }
*
* @throws \Ibexa\Bundle\Core\ApiLoader\Exception\InvalidSearchEngine
Expand Down
27 changes: 20 additions & 7 deletions tests/lib/UI/Config/Provider/Module/DamWidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
* contentTypeIdentifiers: array<string>,
* aggregations: aggregations: array<string, array<string, string>>,
* showImageFilters: bool,
* }
* },
* contentTypeIdentifier: string,
* nameFieldIdentifier: string,
* }
* @template TRepositoryConfig of array {
* engine: string,
Expand All @@ -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',
Expand All @@ -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 */
Expand All @@ -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
);
Expand Down Expand Up @@ -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,
],
];
}

Expand Down

0 comments on commit 64f16ae

Please sign in to comment.