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

refactor(file-router): make route with non-null children detected as a layout #2493

Merged
merged 2 commits into from
May 31, 2024

Conversation

Lodin
Copy link
Contributor

@Lodin Lodin commented May 30, 2024

Fixes #2379.

@Lodin Lodin added the hilla Issues related to Hilla label May 30, 2024
@Lodin Lodin requested review from platosha and taefi May 30, 2024 12:01
Copy link

sonarcloud bot commented May 30, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

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

See analysis details on SonarCloud

Copy link

codecov bot commented May 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.02%. Comparing base (81d9a93) to head (1fd559f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2493   +/-   ##
=======================================
  Coverage   95.02%   95.02%           
=======================================
  Files          66       66           
  Lines        4546     4546           
  Branches      658      659    +1     
=======================================
  Hits         4320     4320           
  Misses        182      182           
  Partials       44       44           
Flag Coverage Δ
unittests 95.02% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@taefi taefi left a comment

Choose a reason for hiding this comment

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

There is this method called isMainLayout in the ClientRouteRegistry which is dependent on the children to be not null (could be empty array, but not null) for deciding about an entry being a MainLayout. The correct detection of a MainLayout is critical for the Flow views to be added to the menu. A case comes to mind that an application has a MainLayout in Hilla, but no Hilla views, and only some Flow views. Is this changes currently supporting that?

@Lodin
Copy link
Contributor Author

Lodin commented May 30, 2024

Nope. I guess, I can just exclude it from filtering and add as a route

@taefi
Copy link
Contributor

taefi commented May 30, 2024

Nope. I guess, I can just exclude it from filtering and add as a route

Probably, adding an exception case for MainLayout is the best choice for the short term. TBH, this part is a bit messy regarding what should be on Hilla side, and what should be on Flow side, and there are some related changes introduced in the #2449. Anyway, IMO it's best not to break the currently agreed functionality.

@Lodin
Copy link
Contributor Author

Lodin commented May 30, 2024

Hmm, maybe then it would be better to filter in the Hilla menu instead of a server?

@Lodin
Copy link
Contributor Author

Lodin commented May 30, 2024

Or... It is about the menu display, right? So, we basically don't care if the layout is excluded from the menu but continue existing in the real routing.

platosha
platosha previously approved these changes May 30, 2024
@platosha platosha dismissed their stale review May 30, 2024 13:27

discussion on the approach

@platosha
Copy link
Contributor

platosha commented May 30, 2024

There is this method called isMainLayout in the ClientRouteRegistry which is dependent on the children to be not null (could be empty array, but not null) for deciding about an entry being a MainLayout. The correct detection of a MainLayout is critical for the Flow views to be added to the menu. A case comes to mind that an application has a MainLayout in Hilla, but no Hilla views, and only some Flow views. Is this changes currently supporting that?

Seems so, as this line suggests: https://github.com/vaadin/hilla/pull/2493/files#diff-fd76ca650f85b66ff69dfdb7b1ff3248840101fef661307b71bb79bced728c10R90

  • layouts have empty array children by default, the main layout is not an exception
  • leaf views otherwise have undefined children (parsed as null in Java)

@platosha
Copy link
Contributor

So let me approve again, as according to my understanding, this change makes it more consistent, and the expectation for the main layout is fulfilled.

@taefi taefi merged commit 9f087d1 into main May 31, 2024
15 checks passed
@taefi taefi deleted the fix/file/layout-menu-item branch May 31, 2024 07:41
@vaadin-bot
Copy link
Collaborator

Hi @Lodin and @taefi, when i performed cherry-pick to this commit to 24.4, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick 9f087d1
error: could not apply 9f087d1... refactor(file-router): make route with non-null children detected as a layout (#2493)
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

platosha pushed a commit that referenced this pull request Jun 3, 2024
Lodin pushed a commit that referenced this pull request Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@layout.tsx is shown in the menu if there are no views
4 participants