-
Notifications
You must be signed in to change notification settings - Fork 1
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
Use redirect to default env #280
Conversation
Signed-off-by: Aaron Sutula <asutula@users.noreply.github.com>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -20,8 +20,7 @@ export default function NewProjectButton({ team }: { team: schema.Team }) { | |||
} | |||
onSuccess={(project) => { | |||
router.refresh(); | |||
// TODO: Deal with multiple envs | |||
router.push(`/${team.slug}/${project.slug}/default`); | |||
router.push(`/${team.slug}/${project.slug}`); |
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.
We can now simply link to or push to the team/project
path and the environment resolution gets handled in a server side redirect.
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.
Here's the server side redirect logic.
let table = ""; | ||
if (typeof searchParams.table === "string") { | ||
table = `/${searchParams.table}`; | ||
} |
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.
It optionally accepts a search param table
that will result in redirecting to a table page inside an environment.
router.push( | ||
`/${selectedTeam.slug}/${selectedProject.slug}${env ? `/${env.slug}/${def.slug}` : `?table=${def.slug}`}`, | ||
); | ||
if (selectedProject.id === project?.id) { | ||
void defsQuery.refetch(); | ||
} |
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.
There is some special logic in the case of this table menu because it is used in two contexts:
- While viewing a table in the context of a project/environment
- While viewing any tableland table page where there is no project/environment
The logic is to use the env in our context if we have it (1. above), or default to the server side redirect if we don't (2. above).
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
Signed-off-by: Aaron Sutula <asutula@users.noreply.github.com>
This makes sure that old URLs from before env was part of the url will keep working. It's also a more general way of handing navigation to an environment which will allow us to do something more sophisticated in the near future like read the correct env from the user session.