-
Notifications
You must be signed in to change notification settings - Fork 79
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
Standardize extraction of account id and page id from route #456
Conversation
@@ -16,7 +16,7 @@ import { useCreatePage } from "../../../hooks/useCreatePage"; | |||
|
|||
type AccountPageListProps = { | |||
accountId: string; | |||
currentPageEntityId: string; | |||
currentPageEntityId?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@teenoh I’ve made this parameter optional so that we can see the list of pages even if we browse a type. This behavior feels more logical to me, but I’m happy to change it back if the spec suggests otherwise.
export interface UseRouteAccountInfo { | ||
(options: { allowUndefined: true }): RouteAccountInfo | undefined; | ||
(options?: { allowUndefined?: false }): RouteAccountInfo; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@teenoh this gives us extra type safety when we use the hook. We don’t need !
as discussed in #460 (comment)
@@ -2,7 +2,7 @@ import { test, expect } from "@playwright/test"; | |||
|
|||
test("guest user navigation to login and signup pages", async ({ page }) => { | |||
await page.goto("/"); | |||
await page.waitForNavigation({ url: "**/login" }); | |||
await page.waitForURL("**/login"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitForNavigation
failed for me in CI, so I investigated it and found the fix. Unlike waitForNavigation
, waitForURL
succeeds even if we are on the right page already. Not sure if I have fixed some general test flakiness by this or this was a new glitch. It might be related to a change in _app.page.tsx
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @kachkaev
🌟 What is the purpose of this PR?
This PR provides an alternative solution to #456. It prevents account id from being undefined during SSR by not rendering app pages on the server. Frontend page files are converted to
kebab-case
given the opportunity.🔍 What does this change?
New hooks:
useRouteAccountInfo
anduseRoutePageInfo
(inspired byCurrentWorkspaceContext
)Replacement of all
router.query["pageId|accountId"]
with new hooks. This improves type-safety and provides future-proofing. Using slugs instead of ids should be easier now.Page files were renamed
[account-slug]
and[page-slug]
instead of[accountId]
and[pageId]
_app.page.ts
is updated: server-side rendering is skipped because page and account ids are undefined and this may crash some componentsApp UI often depends on
[account-slug]
and other query params. However,router.query
is empty during server-side rendering for pages that don’t usegetServerSideProps
. By showing app skeleton on the server, we avoid UI mismatches during rehydrationkebab-case
is enforced for"[frontend]/src/pages/**/*"
to speed-up future reviews. Related to Configure ESLint rules for shared folders, bump ESLint deps #453null
. We should replace it with Hash logo or some loader. Alternatively, we can consider making all/[account-slug]/*
pages server-rendered by addinggetServerSideProps
. However, this will significantly increase server load and create some additional edge cases for UI layouts.🐾 Next steps
Continue working on UI components for the entity editor
Consider parsing
[account-slug]
and converting it toaccountId
insideRouteAccountInfoProvider
🔗 Related links
🛡 What tests cover this?
❓ How to test this?