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

fix(file-router): get back Flow AutoLayout #2931

Merged
merged 7 commits into from
Nov 27, 2024
Merged

fix(file-router): get back Flow AutoLayout #2931

merged 7 commits into from
Nov 27, 2024

Conversation

Lodin
Copy link
Contributor

@Lodin Lodin commented Nov 27, 2024

Fixes #2928

@Lodin Lodin added the hilla Issues related to Hilla label Nov 27, 2024
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 88.09524% with 5 lines in your changes missing coverage. Please review.

Project coverage is 92.79%. Comparing base (e51780a) to head (fc63e61).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../generator-utils/src/dependencies/ImportManager.ts 16.66% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2931      +/-   ##
==========================================
- Coverage   92.89%   92.79%   -0.10%     
==========================================
  Files          83       84       +1     
  Lines        3137     3149      +12     
  Branches      757      759       +2     
==========================================
+ Hits         2914     2922       +8     
- Misses        171      175       +4     
  Partials       52       52              
Flag Coverage Δ
unittests 92.79% <88.09%> (-0.10%) ⬇️

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

@caalador caalador left a comment

Choose a reason for hiding this comment

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

Now there is at least the issue that in file-routes.ts the flowLayout is moved from a boolean property in createRoute to be a config parameter.
This has the issue that when creating the file-routes.ts we do not have the actual config from the tsx file available and the marking is done according to the available layouts.
This is remediesd in createViewConfigJson where the file-routes.ts flowLayout was set if config.flowLayout === null | undefined, but now it is always set so we do not set it to the user defined value at all.
So now if you have a @Layout("/") RouterLayout and have a hilla view with the configuration flowLayout: false it will still be shown in the layout as the file-routes definition overrides any user definitions.

@caalador
Copy link
Contributor

I also get the exception

2024-11-27T13:46:11.473+02:00  INFO 27456 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :  ERROR(TypeScript)  An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled.
2024-11-27T13:46:11.473+02:00  INFO 27456 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :  FILE  C:/Users/mgran/Code/Vaadin/flow-hilla-hybrid-example/src/main/frontend/generated/file-routes.ts:6:25
2024-11-27T13:46:11.473+02:00  INFO 27456 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   : 
2024-11-27T13:46:11.473+02:00  INFO 27456 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :     4 | import * as Page_2 from "../views/about.tsx";
2024-11-27T13:46:11.473+02:00  INFO 27456 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :     5 | import * as Page_3 from "../views/hilla.tsx";
2024-11-27T13:46:11.473+02:00  INFO 27456 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   > 6 | import * as Page_4 from "../views/login.tsx";

Which is fixed by removing the extension from the imports, but as this is a generated file it is a bit strange to get an exception.

@Lodin
Copy link
Contributor Author

Lodin commented Nov 27, 2024

@caalador, thanks for the review.

So now if you have a @layout("/") RouterLayout and have a hilla view with the configuration flowLayout: false it will still be shown in the layout as the file-routes definition overrides any user definitions.

Oh, thanks! I definitely need a test for that...

I also get the exception

That's a bug, sorry. Already fixed 😅

P.S. Don't hesitate to use Request Changes to block the PR until everything is fixed 😊

@Lodin Lodin requested a review from caalador November 27, 2024 12:01
@Lodin
Copy link
Contributor Author

Lodin commented Nov 27, 2024

@caalador, does the latest update fix the issue with config overriding you mentioned?

@caalador
Copy link
Contributor

The layouts seem to work as expected (unless I forgot some combination as there are many), but now the imports get this strange full path in the middle and do not work 😓

2024-11-27T14:13:49.665+02:00  INFO 21092 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :  ERROR(TypeScript)  Cannot find module '../C:\Users\mgran\Code\Vaadin\flow-hilla-hybrid-example\src\main\frontend\views/login.js' or its corresponding type declarations.
2024-11-27T14:13:49.665+02:00  INFO 21092 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :  FILE  C:/Users/mgran/Code/Vaadin/flow-hilla-hybrid-example/src/main/frontend/generated/file-routes.ts:6:25
2024-11-27T14:13:49.665+02:00  INFO 21092 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   : 
2024-11-27T14:13:49.665+02:00  INFO 21092 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :     4 | import * as Page_2 from "../C:\\Users\\mgran\\Code\\Vaadin\\flow-hilla-hybrid-example\\src\\main\\frontend\\views/about.js";

@Lodin
Copy link
Contributor Author

Lodin commented Nov 27, 2024

That darn windows paths... 🥲 Let me fix it

@caalador
Copy link
Contributor

That darn windows paths... 🥲 Let me fix it

That's the reason why I've taken on the burden of a windows machine for development

Copy link

sonarcloud bot commented Nov 27, 2024

@Lodin
Copy link
Contributor Author

Lodin commented Nov 27, 2024

@caalador, what about now? I hope it works...

@caalador
Copy link
Contributor

Now it seems to work correctly. 👍

@Lodin
Copy link
Contributor Author

Lodin commented Nov 27, 2024

Great! Could you approve it, so we can merge it?

@ZheSun88 ZheSun88 merged commit 38c12f0 into main Nov 27, 2024
13 of 15 checks passed
@ZheSun88 ZheSun88 deleted the fix/auto-layouts branch November 27, 2024 13:10
cromoteca pushed a commit that referenced this pull request Nov 27, 2024
* fix(file-router): get back the Flow AutoLayout feature

* test(file-router): add tests for createRoute & extendModule

* fix(file-router): address CI failures

* fix(generator-utils): make extension optional

* fix(file-router): address config overridding issue

* fix(file-router): correct Windows paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hilla Issues related to Hilla
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flow auto layout not applied
3 participants