Skip to content
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 @@ -76,3 +76,5 @@ parameters:
ibexa.io.multifile_upload.max_file_size: 5242880

ibexa.admin_ui.content_tree.node_factory.max_location_ids_in_single_aggregation: 100

ibexa.admin_ui.config.default.user_mode: 'smart'
9 changes: 9 additions & 0 deletions src/bundle/Resources/config/services/user_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@ services:
tags:
- { name: ibexa.user.setting.value, identifier: in_context_translation, group: location, priority: 60 }
- { name: ibexa.user.setting.mapper.form, identifier: in_context_translation }

Ibexa\AdminUi\UserSetting\Group\UserModeGroup:
tags:
- { name: ibexa.user.setting.group, identifier: mode, priority: -10 }

Ibexa\AdminUi\UserSetting\UserMode:
tags:
- { name: ibexa.user.setting.value, identifier: user_mode, group: mode, priority: 10 }
- { name: ibexa.user.setting.mapper.form, identifier: user_mode }
55 changes: 55 additions & 0 deletions src/bundle/Resources/translations/ibexa_user_settings.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@
<target state="new">Date and Time will be displayed in this format:</target>
<note>key: settings.datetime_format.preview_label</note>
</trans-unit>
<trans-unit id="f37ef9b83569317526cc7c550502606dfa703625" resname="settings.group.mode.description">
<source>settings.group.mode.description</source>
<target state="new"></target>
<note>key: settings.group.mode.description</note>
</trans-unit>
<trans-unit id="4030d22c6edcd7185a9584ae76a5948aedaa1594" resname="settings.group.mode.name">
<source>Mode</source>
<target state="new">Mode</target>
<note>key: settings.group.mode.name</note>
</trans-unit>
<trans-unit id="3e6a40d77072c330caa54630a0ee78371e3b5bcc" resname="settings.in_context_translation.value.description">
<source>Toggle In-Context translation feature</source>
<target state="new">Toggle In-Context translation feature</target>
Expand All @@ -76,6 +86,51 @@
<target state="new">In-Context translation</target>
<note>key: settings.in_context_translation.value.title</note>
</trans-unit>
<trans-unit id="1908a078c655a123c1e03b2b8dbe39240ad9d7f5" resname="user.setting.mode.description">
<source>Mode</source>
<target state="new">Mode</target>
<note>key: user.setting.mode.description</note>
</trans-unit>
<trans-unit id="581ee2faad6bfe1d4af2e60bf3912162bd57aedd" resname="user.setting.mode.expert">
<source>Expert</source>
<target state="new">Expert</target>
<note>key: user.setting.mode.expert</note>
</trans-unit>
<trans-unit id="7bbfadd84e2abbfb1923b38c4b27f14fe4585c55" resname="user.setting.mode.help">
<source><![CDATA[<p><strong>Smart mode</strong> – A clean and intuitive interface with a simplified content structure, designed for new and non-advanced users. Features include:</p>
<ul>
<li>Quick preview</li>
<li>Hidden Technical Details tab</li>
<li>Hidden Locations and Versions tabs in Content items</li>
</ul>
<p><strong>Expert mode</strong> – Tailored for experienced users familiar with Ibexa DXP. Provides comprehensive insights into the technical aspects of Content structure, including:</p>
<ul>
<li>Technical Details tab</li>
<li>Location: Archived versions</li>
</ul>]]></source>
<target state="new"><![CDATA[<p><strong>Smart mode</strong> – A clean and intuitive interface with a simplified content structure, designed for new and non-advanced users. Features include:</p>
<ul>
<li>Quick preview</li>
<li>Hidden Technical Details tab</li>
<li>Hidden Locations and Versions tabs in Content items</li>
</ul>
<p><strong>Expert mode</strong> – Tailored for experienced users familiar with Ibexa DXP. Provides comprehensive insights into the technical aspects of Content structure, including:</p>
<ul>
<li>Technical Details tab</li>
<li>Location: Archived versions</li>
</ul>]]></target>
<note>key: user.setting.mode.help</note>
</trans-unit>
<trans-unit id="7036f294d389a7a41226580ce5f0c62bc1a85c21" resname="user.setting.mode.name">
<source>Mode</source>
<target state="new">Mode</target>
<note>key: user.setting.mode.name</note>
</trans-unit>
<trans-unit id="3d0f321c83d4cf337389cbd0a0d36dc218516750" resname="user.setting.mode.smart">
<source>Smart</source>
<target state="new">Smart</target>
<note>key: user.setting.mode.smart</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/bundle/Resources/translations/messages.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,11 @@
<target state="new">Are you sure you want to delete selected URL wildcard(s)?</target>
<note>key: url_wildcard.modal.message</note>
</trans-unit>
<trans-unit id="7036f294d389a7a41226580ce5f0c62bc1a85c21" resname="user.setting.mode.name">
<source>user.setting.mode.name</source>
<target state="new">user.setting.mode.name</target>
<note>key: user.setting.mode.name</note>
</trans-unit>
<trans-unit id="cc411f80de934035a8572d79cb383398775f3cde" resname="user_menu.popup_menu.title">
<source>Logged as %userName%</source>
<target state="new">Logged as %userName%</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@

{% if item.getExtra('template') is not null %}
{% include item.getExtra('template') ignore missing with options only %}


// @TODO xxxxxxxx
{% endif %}

{{ parent() }}
Expand Down
46 changes: 46 additions & 0 deletions src/lib/Form/Type/User/UserModeChoiceType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\AdminUi\Form\Type\User;

use Ibexa\AdminUi\UserSetting\UserMode;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\ChoiceList\ChoiceList;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;

final class UserModeChoiceType extends AbstractType
{
private const TRANSLATION_DOMAIN = 'ibexa_user_settings';

public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'choice_loader' => ChoiceList::lazy($this, $this->getChoiceLoader()),
'translation_domain' => self::TRANSLATION_DOMAIN,
]);
}

public function getParent(): string
{
return ChoiceType::class;
}

/**
* @phpstan-return callable(): array<string, string>
*/
private function getChoiceLoader(): callable
{
return static function (): array {
return [
'user.setting.mode.expert' => UserMode::EXPERT,
'user.setting.mode.smart' => UserMode::SMART,
];
};
}
}
49 changes: 49 additions & 0 deletions src/lib/UserSetting/Group/UserModeGroup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\AdminUi\UserSetting\Group;

use Ibexa\User\UserSetting\Group\AbstractGroup;
use JMS\TranslationBundle\Annotation\Desc;
use Symfony\Contracts\Translation\TranslatorInterface;

final class UserModeGroup extends AbstractGroup
{
private TranslatorInterface $translator;

/**
* @param array<string, \Ibexa\Contracts\User\UserSetting\ValueDefinitionInterface> $values
*/
public function __construct(
TranslatorInterface $translator,
array $values = []
) {
$this->translator = $translator;
parent::__construct($values);
}

public function getName(): string
{
return $this->translator->trans(
/** @Desc("Mode") */
'settings.group.mode.name',
[],
'ibexa_user_settings'
);
}

public function getDescription(): string
{
return $this->translator->trans(
/** @Desc("") */
'settings.group.mode.description',
[],
'ibexa_user_settings'
);
}
}
114 changes: 114 additions & 0 deletions src/lib/UserSetting/UserMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\AdminUi\UserSetting;

use Ibexa\AdminUi\Form\Type\User\UserModeChoiceType;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Ibexa\Contracts\User\UserSetting\FormMapperInterface;
use Ibexa\Contracts\User\UserSetting\ValueDefinitionInterface;
use JMS\TranslationBundle\Model\Message;
use JMS\TranslationBundle\Translation\TranslationContainerInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

final class UserMode implements ValueDefinitionInterface, FormMapperInterface, TranslationContainerInterface
{
public const EXPERT = '0';
public const SMART = '1';
private const TRANSLATION_DOMAIN = 'ibexa_user_settings';

private TranslatorInterface $translator;

private ConfigResolverInterface $configResolver;

public function __construct(
ConfigResolverInterface $configResolver,
TranslatorInterface $translator
) {
$this->configResolver = $configResolver;
$this->translator = $translator;
}

public function getName(): string
{
return $this->translator->trans(
'user.setting.mode.name',
[],
self::TRANSLATION_DOMAIN
);
}

public function getDescription(): string
{
return $this->translator->trans(
'user.setting.mode.description',
[],
self::TRANSLATION_DOMAIN
);
}

public function getDisplayValue(string $storageValue): string
{
switch (true) {
case $storageValue === self::EXPERT:
return $this->translator->trans('user.setting.mode.expert', [], self::TRANSLATION_DOMAIN);
case $storageValue === self::SMART:
return $this->translator->trans('user.setting.mode.smart', [], self::TRANSLATION_DOMAIN);
}

return $storageValue;
}

public function getDefaultValue(): string
{
return $this->configResolver->getParameter('default.user_mode');
}

public function mapFieldForm(
FormBuilderInterface $formBuilder,
ValueDefinitionInterface $value
): FormBuilderInterface {
return $formBuilder->create(
'value',
UserModeChoiceType::class,
[
'label' => 'user.setting.mode.name',
'expanded' => true,
'multiple' => false,
'translation_domain' => self::TRANSLATION_DOMAIN,
'help' => $this->translator->trans('user.setting.mode.help', [], self::TRANSLATION_DOMAIN),
'help_html' => true,
]
);
}

public static function getTranslationMessages(): array
{
return [
(new Message('user.setting.mode.help', self::TRANSLATION_DOMAIN))
->setDesc(
'<p><strong>Smart mode</strong> – A clean and intuitive interface with a simplified content structure, designed for new and non-advanced users. Features include:</p>
<ul>
<li>Quick preview</li>
<li>Hidden Technical Details tab</li>
<li>Hidden Locations and Versions tabs in Content items</li>
</ul>
<p><strong>Expert mode</strong> – Tailored for experienced users familiar with Ibexa DXP. Provides comprehensive insights into the technical aspects of Content structure, including:</p>
<ul>
<li>Technical Details tab</li>
<li>Location: Archived versions</li>
</ul>'
),
(new Message('user.setting.mode.expert', self::TRANSLATION_DOMAIN))->setDesc('Expert'),
(new Message('user.setting.mode.smart', self::TRANSLATION_DOMAIN))->setDesc('Smart'),
(new Message('user.setting.mode.name', self::TRANSLATION_DOMAIN))->setDesc('Mode'),
(new Message('user.setting.mode.description', self::TRANSLATION_DOMAIN))->setDesc('Mode'),
];
}
}