Skip to content
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

Merged
merged 2 commits into from
May 29, 2024
Merged

Use redirect to default env #280

merged 2 commits into from
May 29, 2024

Conversation

asutula
Copy link
Contributor

@asutula asutula commented May 29, 2024

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.

Signed-off-by: Aaron Sutula <asutula@users.noreply.github.com>
Copy link

vercel bot commented May 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2024 9:23pm

@@ -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}`);
Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Comment on lines 10 to 13
let table = "";
if (typeof searchParams.table === "string") {
table = `/${searchParams.table}`;
}
Copy link
Contributor Author

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.

packages/web/app/[team]/[project]/page.tsx Outdated Show resolved Hide resolved
Comment on lines +163 to +168
router.push(
`/${selectedTeam.slug}/${selectedProject.slug}${env ? `/${env.slug}/${def.slug}` : `?table=${def.slug}`}`,
);
if (selectedProject.id === project?.id) {
void defsQuery.refetch();
}
Copy link
Contributor Author

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:

  1. While viewing a table in the context of a project/environment
  2. 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).

dtbuchholz
dtbuchholz previously approved these changes May 29, 2024
Copy link
Contributor

@dtbuchholz dtbuchholz left a 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>
@asutula asutula merged commit 30bba70 into main May 29, 2024
3 of 4 checks passed
@asutula asutula deleted the asutula/env-redirect branch May 29, 2024 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants