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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twig component: Make navigation bar management independent #33702

Merged
merged 3 commits into from Sep 1, 2023

Conversation

M0rgan01
Copy link
Contributor

Questions Answers
Branch? develop
Description? Make navigation bar management independent
Type? improvement
Category? BO
BC breaks? no
Deprecations? no
How to test? CI 馃煝 and auto tests 馃煝
Fixed issue or discussion? Fixes #33701
Related PRs -
Sponsor company -

@M0rgan01 M0rgan01 requested a review from a team as a code owner August 23, 2023 16:07
@prestonBot prestonBot added develop Branch Improvement Type: Improvement labels Aug 23, 2023
@M0rgan01 M0rgan01 added this to the 9.0.0 milestone Aug 23, 2023
@M0rgan01
Copy link
Contributor Author

M0rgan01 commented Aug 23, 2023

@M0rgan01 M0rgan01 marked this pull request as ready for review August 24, 2023 13:54
Copy link
Contributor

@jolelievre jolelievre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @M0rgan01

Only a few suggestions, but nothing mandatory as we'll have to refacto some of the classes at some point anyway

public int $currentTabLevel;
public array $tabs;
public int $currentTabLevel = 0;
public array $navigationTabs = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok for this one but I noticed you and maybe @boherm as well kept a lot of public fields in the component classes in previous PRs

We shouldn't have public properties on these components except for variables that we absolutely have to inject/override in the component So mostly only variables that will come from twig and that the controller injected I guess

All the other public properties should be transformed in getter functions, and ideally they should only be populated Just In Time in the getter itself Except for "advanced" variables that depend on each other in which case the mount approach may be more adapted

/**
* @return array<int, MenuLink>
*/
public function buildNavigationTabs(Tab $tab): array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function buildNavigationTabs(Tab $tab): array
public function getNavigationTabs(Tab $tab): array

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another suggestion/refacto we'll have to handle in this service I think We don't cache the result so we'll have to think about how we can optimize this service to avoid doing the same DB queries multiple times for multiple components (not in this PR 馃槈)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW I love this idea of getting the siblings this way instead of the previous quadruple loop 馃槄 This is much smarter this way

/* @var $currentLevelTab Tab */
foreach ($currentLevelTabs as $currentLevelTab) {
$tabLang = $currentLevelTab->getTabLangByLanguageId($this->getContextLanguageId());
$menuLink = new MenuLink(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This MenuLink DTO was created as a very simple one, maybe we'll have to improve it (add fields that are used everywhere) Or create alternative ones like a dedicated TabLink DTO or something similar (not in this PR as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, might as well create a new TabLink

@ps-jarvis ps-jarvis added the Waiting for QA Status: action required, waiting for test feedback label Aug 30, 2023
@florine2623 florine2623 added QA 鉁旓笍 Status: check done, code approved and removed Waiting for QA Status: action required, waiting for test feedback labels Sep 1, 2023
@florine2623 florine2623 self-assigned this Sep 1, 2023
@M0rgan01 M0rgan01 merged commit 2bcb9a7 into PrestaShop:develop Sep 1, 2023
18 checks passed
@jolelievre jolelievre changed the title [twig component] Make navigation bar management independent Twig component: Make navigation bar management independent Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
develop Branch Improvement Type: Improvement QA 鉁旓笍 Status: check done, code approved
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Independent toolbar navigation twig component
6 participants