-
Notifications
You must be signed in to change notification settings - Fork 881
fix: Update routes for project page, workspace creation page, and workspace page #415
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #415 +/- ##
==========================================
- Coverage 68.44% 68.11% -0.34%
==========================================
Files 155 160 +5
Lines 9052 9256 +204
Branches 73 76 +3
==========================================
+ Hits 6196 6305 +109
- Misses 2254 2327 +73
- Partials 602 624 +22
Continue to review full report at Codecov.
|
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.
Looks good to me.
I'd appreciate @presleyp and @vapurrmaid thoughts here too!
@@ -8,26 +8,36 @@ import { useUser } from "../../../../contexts/UserContext" | |||
import { ErrorSummary } from "../../../../components/ErrorSummary" | |||
import { FullScreenLoader } from "../../../../components/Loader/FullScreenLoader" | |||
import { CreateWorkspaceForm } from "../../../../forms/CreateWorkspaceForm" | |||
import { unsafeSWRArgument } from "../../../../util" |
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.
Curious what this is, but I'm sure you have a good reason for using it!
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.
Good question @presleyp ! I'm open to ideas for better ways to handle this (and luckily, it's at least temporary - if we switch to XState and migrate from SWR, this utility isn't needed).
With SWR - when one call relies on another call - SWR expects the function to 'throw' until the data is available. So I ended up with a lot of casts to any + suppressions:
const { data: project, error: projectError } = useSWR<API.Project, Error>(() => {
// Using `any` below so that, if the project isn't available, an exception is thrown - causing
// SWR to retry:
// eslint-disable-line no-any
return `/api/v2/organizations/${(project as any).id}/projects/${projectName}`
})
I ended up with a lot of these comments + any casts, so I figured if I extracted it out to a helper, it'd be a little clearer:
const { data: project, error: projectError } = useSWR<API.Project, Error>(() => {
return `/api/v2/organizations/${unsafeSWRArgument(project).id}/projects/${projectName}`
})
I'm happy to switch back to the more verbose comment + eslint disable + cast, or rename unsafeSWRArgument
to something more understandable. (Implementation is here if it helps) IMO the most important criteria is that it is readable / understandable for you and @vapurrmaid
And luckily, seems like this will be only temporary - if we remove SWR and use XState, this will no longer be an issue and this can be removed
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.
Oh I see where you defined! (Thought it was an SWR thing at first)
Thanks @presleyp and @kylecarbs for the review! |
Some API routes were updated in #401, which impacted the UX - the flow is currently broken when trying to navigate to a project:
This fixes all the routes so that the complete project -> create workspace -> workspace page flow works:
Because this had to touch a bunch of UI routes, I also opportunistically fixed #380 as part of this change.
TODO: