-
-
Notifications
You must be signed in to change notification settings - Fork 751
feat: redirect to default project #1640
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
base: main
Are you sure you want to change the base?
Changes from all commits
bdf842c
db2897e
e89edf6
d055ea4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,30 @@ | ||
| import { createFileRoute, Outlet } from "@tanstack/react-router"; | ||
| import { createFileRoute, Outlet, redirect } from "@tanstack/react-router"; | ||
| import getProjects from "@/fetchers/project/get-projects"; | ||
|
|
||
| export const Route = createFileRoute( | ||
| "/_layout/_authenticated/dashboard/workspace/$workspaceId", | ||
| )({ | ||
| beforeLoad: async ({ params, location }) => { | ||
| const currentPath = location.pathname.replace(/\/+$/, ""); | ||
| const workspacePath = `/dashboard/workspace/${params.workspaceId}`; | ||
|
|
||
| if (currentPath !== workspacePath) return; | ||
|
|
||
| const projects = await getProjects({ | ||
| workspaceId: params.workspaceId, | ||
| }); | ||
|
|
||
|
Comment on lines
+13
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Unhandled projects fetch errors If getProjects() returns a non-OK response, it throws, and beforeLoad does not catch it—so visiting /dashboard/workspace/:workspaceId can hard-fail into the error boundary instead of simply skipping the redirect. This introduces a new route-level failure mode on transient network/auth issues. Agent Prompt
|
||
| if (projects?.length !== 1) return; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift Redirect the configured default project before the sole-project fallback.
Resolve the workspace default project first. Redirect to it when present. Keep the exactly-one-project redirect as the fallback. The PR objective requires a default-project redirect or a sole-project redirect. 🤖 Prompt for AI Agents |
||
|
|
||
| throw redirect({ | ||
| to: "/dashboard/workspace/$workspaceId/project/$projectId/board", | ||
| params: { | ||
| workspaceId: params.workspaceId, | ||
| projectId: projects[0].id, | ||
| }, | ||
| replace: true, | ||
| }); | ||
| }, | ||
| component: RouteComponent, | ||
| }); | ||
|
|
||
|
|
||
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.
1. Duplicate projects fetch on load
🐞 Bug➹ PerformanceAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools