Skip to content

Commit 69df7db

Browse files
committed
Avoid using location to avoid SSR issues
1 parent 03fab55 commit 69df7db

File tree

1 file changed

+41
-8
lines changed
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.settings

1 file changed

+41
-8
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.settings/route.tsx

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
Form,
1313
type MetaFunction,
1414
useActionData,
15-
useLocation,
1615
useNavigation,
1716
useNavigate,
1817
} from "@remix-run/react";
@@ -62,6 +61,7 @@ import {
6261
v3ProjectPath,
6362
githubAppInstallPath,
6463
EnvironmentParamSchema,
64+
v3ProjectSettingsPath,
6565
} from "~/utils/pathBuilder";
6666
import React, { useEffect, useState } from "react";
6767
import { Select, SelectItem } from "~/components/primitives/Select";
@@ -74,6 +74,7 @@ import {
7474
} from "~/components/environments/EnvironmentLabel";
7575
import { GitBranchIcon } from "lucide-react";
7676
import { env } from "~/env.server";
77+
import { useEnvironment } from "~/hooks/useEnvironment";
7778

7879
export const meta: MetaFunction = () => {
7980
return [
@@ -418,6 +419,7 @@ export default function Page() {
418419
useTypedLoaderData<typeof loader>();
419420
const project = useProject();
420421
const organization = useOrganization();
422+
const environment = useEnvironment();
421423
const lastSubmission = useActionData();
422424
const navigation = useNavigation();
423425

@@ -538,6 +540,8 @@ export default function Page() {
538540
<GitHubConnectionPrompt
539541
gitHubAppInstallations={githubAppInstallations}
540542
organizationSlug={organization.slug}
543+
projectSlug={project.slug}
544+
environmentSlug={environment.slug}
541545
/>
542546
)}
543547
</div>
@@ -607,13 +611,17 @@ type GitHubAppInstallation = {
607611

608612
function ConnectGitHubRepoModal({
609613
gitHubAppInstallations,
614+
organizationSlug,
615+
projectSlug,
616+
environmentSlug,
610617
}: {
611618
gitHubAppInstallations: GitHubAppInstallation[];
619+
organizationSlug: string;
620+
projectSlug: string;
621+
environmentSlug: string;
612622
}) {
613623
const [isModalOpen, setIsModalOpen] = useState(false);
614624
const lastSubmission = useActionData() as any;
615-
const organization = useOrganization();
616-
const location = useLocation();
617625
const navigate = useNavigate();
618626

619627
const [selectedInstallation, setSelectedInstallation] = useState<
@@ -693,7 +701,16 @@ function ConnectGitHubRepoModal({
693701
<SelectItem
694702
onClick={(e) => {
695703
e.preventDefault();
696-
navigate(githubAppInstallPath(organization.slug, location.pathname));
704+
navigate(
705+
githubAppInstallPath(
706+
organizationSlug,
707+
v3ProjectSettingsPath(
708+
{ slug: organizationSlug },
709+
{ slug: projectSlug },
710+
{ slug: environmentSlug }
711+
)
712+
)
713+
);
697714
}}
698715
key="new-account"
699716
icon={<PlusIcon className="size-3 text-text-dimmed" />}
@@ -771,16 +788,27 @@ function ConnectGitHubRepoModal({
771788
function GitHubConnectionPrompt({
772789
gitHubAppInstallations,
773790
organizationSlug,
791+
projectSlug,
792+
environmentSlug,
774793
}: {
775794
gitHubAppInstallations: GitHubAppInstallation[];
776795
organizationSlug: string;
796+
projectSlug: string;
797+
environmentSlug: string;
777798
}) {
778799
return (
779800
<Fieldset>
780801
<InputGroup fullWidth>
781802
{gitHubAppInstallations.length === 0 && (
782803
<LinkButton
783-
to={githubAppInstallPath(organizationSlug, location.pathname)}
804+
to={githubAppInstallPath(
805+
organizationSlug,
806+
v3ProjectSettingsPath(
807+
{ slug: organizationSlug },
808+
{ slug: projectSlug },
809+
{ slug: environmentSlug }
810+
)
811+
)}
784812
variant={"secondary/medium"}
785813
LeadingIcon={OctoKitty}
786814
>
@@ -789,7 +817,12 @@ function GitHubConnectionPrompt({
789817
)}
790818
{gitHubAppInstallations.length !== 0 && (
791819
<div className="flex items-center gap-3">
792-
<ConnectGitHubRepoModal gitHubAppInstallations={gitHubAppInstallations} />
820+
<ConnectGitHubRepoModal
821+
gitHubAppInstallations={gitHubAppInstallations}
822+
organizationSlug={organizationSlug}
823+
projectSlug={projectSlug}
824+
environmentSlug={environmentSlug}
825+
/>
793826
<span className="flex items-center gap-1 text-xs text-text-dimmed">
794827
<CheckCircleIcon className="size-4 text-success" /> GitHub app is installed
795828
</span>
@@ -872,7 +905,7 @@ function ConnectedGitHubRepoForm({
872905
<Input
873906
{...conform.input(fields.productionBranch, { type: "text" })}
874907
defaultValue={connectedGitHubRepo.branchTracking?.production?.branch}
875-
placeholder="Branch name"
908+
placeholder="none"
876909
variant="tertiary"
877910
icon={GitBranchIcon}
878911
/>
@@ -885,7 +918,7 @@ function ConnectedGitHubRepoForm({
885918
<Input
886919
{...conform.input(fields.stagingBranch, { type: "text" })}
887920
defaultValue={connectedGitHubRepo.branchTracking?.staging?.branch}
888-
placeholder="Branch name"
921+
placeholder="none"
889922
variant="tertiary"
890923
icon={GitBranchIcon}
891924
/>

0 commit comments

Comments
 (0)