Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-7981: [DAM] Added folder configuration #1217

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading