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-7376: Fixed redirect to the not-existing menu after switching to focus mode #1065

Merged
merged 6 commits into from
Jan 15, 2024

Conversation

konradoboza
Copy link
Contributor

@konradoboza konradoboza commented Dec 15, 2023

Question Answer
Tickets IBX-7376
Bug fix? yes
New feature? no
BC breaks? no
Tests pass? yes
Doc needed? no

After switching to "focus mode" there are some sections that are no longer visible in the menu. It makes sense to redirect to the "Content structure" by default (agreed upon with UX team) whenever that happens.

It's not really reliable to those sections automatically due to variety of urls being part of menu items. Therefore I registered two basic strategies:

  • OriginalUrlRedirectStrategy which basically is a projection of the current behavior,
  • ContentStructureRedirectStrategy fixing the issue by detecting affected paths and redirecting to the default content structure menu.

Both implement Ibexa\Contracts\AdminUi\FocusMode\RedirectStrategyInterface which is an extension point allowing to circumvent the default behavior:

interface RedirectStrategyInterface
{
    public function supports(string $route): bool;

    public function generateRedirectPath(string $originalPath): string;
}

New strategy can be registered as follows:

App\CustomRedirectStrategy:
    tags:
        - { name: ibexa.admin_ui.focus_mode.redirect_strategy, priority: 10 }

Documentation:

It's worth mentioning the above extension point for adding custom focus mode redirect strategies.

Checklist:

  • Coding standards ($ composer fix-cs)
  • Ready for Code Review

@konradoboza konradoboza self-assigned this Dec 15, 2023
@konradoboza konradoboza force-pushed the ibx-7376-focus-mode-redirect-hidden-menu branch from 68a8f0f to 2f28c74 Compare December 15, 2023 12:28
@konradoboza konradoboza marked this pull request as ready for review December 15, 2023 12:28
@konradoboza konradoboza added Bug Something isn't working Ready for review labels Dec 15, 2023
@konradoboza konradoboza requested a review from a team December 15, 2023 12:37
@konradoboza konradoboza changed the title IBX-7376: Fixed redirect to the not-existing menu after switching to focus mode [WiP] IBX-7376: Fixed redirect to the not-existing menu after switching to focus mode Dec 15, 2023
@konradoboza konradoboza force-pushed the ibx-7376-focus-mode-redirect-hidden-menu branch from 5bcac46 to 56fabc2 Compare December 20, 2023 15:18
Comment on lines 96 to 98
return new RedirectResponse(
$this->resolveReturnPath($path)
);

Check failure

Code scanning / SonarCloud

HTTP request redirections should not be open to forging attacks

<!--SONAR_ISSUE_KEY:AYyHz4_oLIQXSFt1zRXb-->Change this code to not perform redirects based on user-controlled data. <p>See more on <a href="https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AYyHz4_oLIQXSFt1zRXb&open=AYyHz4_oLIQXSFt1zRXb&pullRequest=1065">SonarCloud</a></p>
@konradoboza konradoboza force-pushed the ibx-7376-focus-mode-redirect-hidden-menu branch from 56fabc2 to 99f6b7d Compare December 20, 2023 15:24
@konradoboza konradoboza added Doc needed The changes require some documentation Ready for review and removed Work in progress labels Dec 21, 2023
@konradoboza konradoboza force-pushed the ibx-7376-focus-mode-redirect-hidden-menu branch from 99f6b7d to 17d3807 Compare December 21, 2023 08:11
@konradoboza konradoboza changed the title [WiP] IBX-7376: Fixed redirect to the not-existing menu after switching to focus mode IBX-7376: Fixed redirect to the not-existing menu after switching to focus mode Dec 21, 2023
@Steveb-p Steveb-p requested a review from a team January 3, 2024 10:12
@konradoboza konradoboza force-pushed the ibx-7376-focus-mode-redirect-hidden-menu branch from 600d59b to 77dddcd Compare January 5, 2024 07:41
@konradoboza konradoboza requested review from Steveb-p and a team January 5, 2024 12:56
Comment on lines +46 to +52
'ibexa.section.list',
'ibexa.content_type_group.list',
'ibexa.object_state.groups.list',
'ibexa.content_type_group.view',
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this list be configurable?

Copy link
Contributor Author

@konradoboza konradoboza Jan 10, 2024

Choose a reason for hiding this comment

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

To me - not necessarily. It might look like an extension point nobody would really use. The thing is, we are lacking a proper list of columns/paths unavailable in focus mode which can be referenced here. That's why I decided to hardcode them and give a way to circumvent the default behavior by registering another strategy at the same time. To me, Open-Closed principle holds it ground in this case. 😉

@alongosz alongosz requested a review from a team January 10, 2024 10:27
@konradoboza konradoboza force-pushed the ibx-7376-focus-mode-redirect-hidden-menu branch from a6f1e6a to fd64555 Compare January 15, 2024 11:02
Copy link

sonarcloud bot commented Jan 15, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@bogusez bogusez left a comment

Choose a reason for hiding this comment

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

Regression tests passed

@adamwojs adamwojs merged commit e2f1be6 into main Jan 15, 2024
22 checks passed
@adamwojs adamwojs deleted the ibx-7376-focus-mode-redirect-hidden-menu branch January 15, 2024 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Doc needed The changes require some documentation QA approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants