-
Notifications
You must be signed in to change notification settings - Fork 1
Fix redirect guard behaviour #33
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
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9d55b78
Fix redirect guard routing behaviour
IzumiSy 249bf2b
Add tests
IzumiSy eb4d9ee
Update changeset
IzumiSy 117d3ab
Fix lint error
IzumiSy f8748b4
docs: clarify redirect guard nav visibility and update changeset
IzumiSy 5a19020
fix: throw 404 when guards pass on component-less route
IzumiSy a3fc155
Fix format
IzumiSy d2f25cf
refactor: separate guardLoader from loader in Module/Resource types
IzumiSy 5ee76dc
test: fix test name and add tests for guardLoader behavior
IzumiSy 66fd119
Format
IzumiSy 5fc10ac
Fix lint errors
IzumiSy 6e2f4d5
Add and update changesets
IzumiSy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@tailor-platform/app-shell": patch | ||
| --- | ||
|
|
||
| Fixed file-based routing (vite plugin) not chaining guards with user-provided loaders. When a page module defines both guards and a `loader` export, guards are now evaluated first via `withGuardsLoader`, and the user loader runs only after guards pass. Previously, guards could overwrite the user loader. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| --- | ||
| "@tailor-platform/app-shell": minor | ||
| --- | ||
|
|
||
| Fixed `redirectTo()` guard not working on modules/resources without a component. Index routes are now created for loader-only routes, enabling redirect guards to execute properly. | ||
|
|
||
| Fixed auto-generated sidebar navigation hiding modules/resources that use `redirectTo()` guards. Navigation filtering now only excludes `hidden()` guards, so redirect-guarded items remain visible in the sidebar. This only affects the auto-generation mode of `SidebarLayout`; composition mode (where children are explicitly provided) is not affected. | ||
|
|
||
| Fixed a component-less module with a mixed guard (one that sometimes returns `pass()`) rendering a blank page. When guards pass on a route without a component, a 404 error is now thrown instead of rendering an empty page. | ||
|
|
||
| ### Guard result types and their effect on navigation visibility | ||
|
|
||
| | Guard result | Nav visibility | Routing behaviour | | ||
| | ------------------ | -------------- | ------------------------------- | | ||
| | `pass()` | Visible | Renders the component | | ||
| | `hidden()` | **Hidden** | Returns 404 | | ||
| | `redirectTo(path)` | Visible | Redirects to the specified path | | ||
|
|
||
| `redirectTo()` guards intentionally keep the item visible in the sidebar. This supports the common pattern where a module has no component of its own but should still appear as a sidebar item that redirects elsewhere (e.g. aliasing a legacy path to a new location). Additionally, if a module with `redirectTo()` were hidden from the sidebar, all of its child resources would also disappear from navigation, even though those children may have real pages that users need to access. | ||
|
|
||
| ```tsx | ||
| // This pattern previously rendered a blank page — now correctly redirects: | ||
| defineModule({ | ||
| path: "old-dashboard", | ||
| guards: [() => redirectTo("/new-dashboard")], | ||
| resources: [...], | ||
| }); | ||
|
|
||
| // Modules/resources with redirectTo guards remain visible in the sidebar. | ||
| // Clicking "Legacy" navigates to /legacy, which then redirects to /modern. | ||
| defineModule({ | ||
| path: "legacy", | ||
| guards: [() => redirectTo("/modern")], | ||
| resources: [ | ||
| defineResource({ | ||
| path: "page", | ||
| component: () => <div>Page</div>, | ||
| }), | ||
| ], | ||
| }); | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.