-
Notifications
You must be signed in to change notification settings - Fork 16
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-6750/IBX-6754/IBX-6839: Implementation of smart/expert mode #1017
Conversation
]) %} | ||
|
||
{% if ibexa_is_expert_mode() %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend utilizing ibexa_user_settings['user_mode']
instead of a dedicated Twig function.
If we name the function with the "expert" keyword, this designation will remain with us for the upcoming years. If we decide to change the name or introduce additional user modes, we will need to implement extra logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or ibexa_mode(...)
function if we cannot rely on user settings being present in the template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even, we can use wildcards in twig function names and do it like ibexa_is_*_mode
and handle it that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue with wildcards is that you cannot use mode value as a variable.
You have to use the full function name immediately.
{% set expected_mode = 'expert' %}
{{ expected_mode is same as 'expert' ? ibexa_is_expert_mode() : ibexa_is_smart_mode() }}
Using an argument does not have this limitation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ibexa_user_settings['user_mode']
or ibexa_mode(...)
is a no go for me. It's simply bad DX:
{% if ibexa_user_settings['user_mode'] === constant('\\Ibexa\\AdminUi\\UserSetting\\UserMode::SMART') %}
Do something
{% endif %}
Wildcard function is a good idea, but we don't need it at the moment.
if ($form->isSubmitted() && $form->isValid()) { | ||
$this->userSettingService->setUserSetting( | ||
UserMode::IDENTIFIER, | ||
$data->getMode() ? UserMode::EXPERT : UserMode::SMART |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why aren't we using UserMode::EXPERT
and UserMode::SMART
directly, instead of relying on a straight up boolean?
For me myself, it would make sense to use the same value as user settings. It would be also a lot easier to work with in case a third setting is introduced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I commented on the same issue. Fully agree, user setting was prepared to accept more user modes in the future. We could maybe even make it extendable by developers, especially with suggestions like #1017 (comment) Data format should reflect values from the user setting.
]) %} | ||
|
||
{% if ibexa_is_expert_mode() %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or ibexa_mode(...)
function if we cannot rely on user settings being present in the template.
|
||
final class UserModeChangeData | ||
{ | ||
private ?bool $mode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you use UserMode
class constants for the value? It makes more sense since the setting is prepared to handle more user modes if there is ever a need. If your data class could reflect it, introducing more user modes will be easier as you would only need to change the form type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't even need a Data Transformer. You can use arbitrary string values in data class and do some magic with false_values
and value
on CheckboxType
(ref. https://symfony.com/doc/5.4/reference/forms/types/checkbox.html).
b3623d7
to
58c890d
Compare
58c890d contains the Behat changes (together with https://github.com/ibexa/version-comparison/pull/62 and https://github.com/ibexa/product-catalog/pull/1103 it's enough to make tests pass) |
@mnocon There are some left over |
{{ ibexa_location_sort_order_as_rest_value(location_asc) }} | ||
{{ ibexa_location_sort_order_as_rest_value(location_desc) }} | ||
--DATA-- | ||
use \Ibexa\Contracts\Core\Repository\Values\Content\Location; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the import required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it does, SORT_ORDER_ASC
and SORT_ORDER_DESC
constants reference Location
.
58c890d
to
d31a7f1
Compare
Thanks, already removed 😅 |
Kudos, SonarCloud Quality Gate passed!
|
{{ ibexa_location_sort_order_as_rest_value(location_asc) }} | ||
{{ ibexa_location_sort_order_as_rest_value(location_desc) }} | ||
--DATA-- | ||
use \Ibexa\Contracts\Core\Repository\Values\Content\Location; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it does, SORT_ORDER_ASC
and SORT_ORDER_DESC
constants reference Location
.
{{ ibexa_location_sort_field_as_rest_sort_clause(location) }} | ||
{% endfor %} | ||
--DATA-- | ||
use \Ibexa\Contracts\Core\Repository\Values\Content\Location; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this import needed?
Changes summary:
New APIs to interact with smart/expert mode
ibexa_is_smart_mode
,ibexa_is_expert_mode
Ibexa\AdminUi\Specification\UserMode\IsUserModeEnabled
specification (internal)Added mode switcher to user context menu
![image](https://private-user-images.githubusercontent.com/211967/287238853-cc6a3a27-335e-455c-b8d2-18da1441f5de.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5ODk5MjUsIm5iZiI6MTczODk4OTYyNSwicGF0aCI6Ii8yMTE5NjcvMjg3MjM4ODUzLWNjNmEzYTI3LTMzNWUtNDU1Yy1iOGQyLTE4ZGExNDQxZjVkZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOFQwNDQwMjVaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iZjdhNzkwY2Q0MjU1MGIzMjEwZWEzN2YxMjcxZDExNTQ5MGZjN2YyNzllMDFjYjFiNzg2ODY3N2UyM2FhZTAyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.g3S8chjet3tWoXuTEzj4vq2sR_NOrJSVIMbBKTBb69k)
Applied user mode to main menu item & tabs visibility
Renamed "Quick preview" tab to "Data"
Hidden "Language Code" column in "Translations tab" when smart mode is active
Fixed sub-items list initialization which rely on forms from "Technical Details" tab
Added missing "Modified" and "Published" field to the "Authors" tab
Smart / Expert mode comparison
Smart mode
Expert mode
Checklist:
$ composer fix-cs
)