-
Notifications
You must be signed in to change notification settings - Fork 975
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Adds pageIdentifier to route manifest (#10680)
Co-authored-by: Daniel Choudhury <dannychoudhury@gmail.com>
- Loading branch information
1 parent
739da33
commit afda80e
Showing
5 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,85 @@ | ||
- chore: Adds pageIdentifier to route manifest (#10680) by @dthyresson | ||
|
||
This PR adds the `page_identifier_str` of `pageIdentifier` to the Route Manifest. | ||
|
||
Known what page belongs to the route can be useful to : | ||
|
||
* ensure if rendering a page/component that it belongs to the route and its auth permissions | ||
* for visualizing routes | ||
* general completeness in the manifest with the Routes jsx in manifest form | ||
|
||
## Example | ||
|
||
### Routes | ||
|
||
```jsx | ||
const Routes = () => { | ||
return ( | ||
<Router> | ||
<Set wrap={NavigationLayout}> | ||
<Route path="/" page={HomePage} name="home" /> | ||
<Route path="/about" page={AboutPage} name="about" /> | ||
<PrivateSet unauthenticated="home" roles={['admin']}> | ||
<Route path="/info" page={AboutPage} name="info" /> | ||
</PrivateSet> | ||
<Route path="/multi-cell" page={MultiCellPage} name="multiCell" /> | ||
|
||
``` | ||
### Manifest | ||
```json | ||
{ | ||
"/": { | ||
"name": "home", | ||
"bundle": null, | ||
"matchRegexString": "^/$", | ||
"pathDefinition": "/", | ||
"hasParams": false, | ||
"routeHooks": null, | ||
"redirect": null, | ||
"relativeFilePath": "pages/HomePage/HomePage.tsx", | ||
"isPrivate": false, | ||
"pageIdentifier": "HomePage" | ||
}, | ||
"/about": { | ||
"name": "about", | ||
"bundle": null, | ||
"matchRegexString": "^/about$", | ||
"pathDefinition": "/about", | ||
"hasParams": false, | ||
"routeHooks": null, | ||
"redirect": null, | ||
"relativeFilePath": "pages/AboutPage/AboutPage.tsx", | ||
"isPrivate": false, | ||
"pageIdentifier": "AboutPage" | ||
}, | ||
"/info": { | ||
"name": "info", | ||
"bundle": null, | ||
"matchRegexString": "^/info$", | ||
"pathDefinition": "/info", | ||
"hasParams": false, | ||
"routeHooks": null, | ||
"redirect": null, | ||
"relativeFilePath": "pages/AboutPage/AboutPage.tsx", | ||
"isPrivate": true, | ||
"unauthenticated": "home", | ||
"roles": [ | ||
"admin" | ||
], | ||
"pageIdentifier": "AboutPage" | ||
}, | ||
"/multi-cell": { | ||
"name": "multiCell", | ||
"bundle": null, | ||
"matchRegexString": "^/multi-cell$", | ||
"pathDefinition": "/multi-cell", | ||
"hasParams": false, | ||
"routeHooks": null, | ||
"redirect": null, | ||
"relativeFilePath": "pages/MultiCellPage/MultiCellPage.tsx", | ||
"isPrivate": false, | ||
"pageIdentifier": "MultiCellPage" | ||
}, | ||
``` |
This file contains 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
15 changes: 15 additions & 0 deletions
15
packages/structure/src/model/__tests__/__snapshots__/model.test.ts.snap
This file contains 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,15 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Redwood Route detection > detects the page identifier for a route 1`] = ` | ||
[ | ||
"HomePage", | ||
"TypeScriptPage", | ||
"EditUserPage", | ||
"FooPage", | ||
"BarPage", | ||
"PrivatePage", | ||
"PrivatePage", | ||
"PrivatePage", | ||
"NotFoundPage", | ||
] | ||
`; |
This file contains 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 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