Skip to content

Commit 5e66deb

Browse files
committed
Hide git settings when github app is disabled
1 parent 33d56f4 commit 5e66deb

File tree

1 file changed

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

1 file changed

+33
-14
lines changed

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

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import {
7373
environmentTextClassName,
7474
} from "~/components/environments/EnvironmentLabel";
7575
import { GitBranchIcon } from "lucide-react";
76+
import { env } from "~/env.server";
7677

7778
export const meta: MetaFunction = () => {
7879
return [
@@ -83,6 +84,16 @@ export const meta: MetaFunction = () => {
8384
};
8485

8586
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
87+
const githubAppEnabled = env.GITHUB_APP_ENABLED === "1";
88+
89+
if (!githubAppEnabled) {
90+
return typedjson({
91+
githubAppEnabled,
92+
githubAppInstallations: undefined,
93+
connectedGithubRepository: undefined,
94+
});
95+
}
96+
8697
const userId = await requireUserId(request);
8798
const { projectParam, organizationSlug } = EnvironmentParamSchema.parse(params);
8899

@@ -120,6 +131,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
120131
);
121132

122133
return typedjson({
134+
githubAppEnabled,
123135
connectedGithubRepository: {
124136
...connectedGithubRepository,
125137
branchTracking: branchTrackingOrFailure.success ? branchTrackingOrFailure.data : undefined,
@@ -158,7 +170,11 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
158170
},
159171
});
160172

161-
return typedjson({ githubAppInstallations, connectedGithubRepository: undefined });
173+
return typedjson({
174+
githubAppEnabled,
175+
githubAppInstallations,
176+
connectedGithubRepository: undefined,
177+
});
162178
};
163179

164180
const ConnectGitHubRepoFormSchema = z.object({
@@ -400,7 +416,8 @@ export const action: ActionFunction = async ({ request, params }) => {
400416
};
401417

402418
export default function Page() {
403-
const { githubAppInstallations, connectedGithubRepository } = useTypedLoaderData<typeof loader>();
419+
const { githubAppInstallations, connectedGithubRepository, githubAppEnabled } =
420+
useTypedLoaderData<typeof loader>();
404421
const project = useProject();
405422
const organization = useOrganization();
406423
const lastSubmission = useActionData();
@@ -513,19 +530,21 @@ export default function Page() {
513530
</div>
514531
</div>
515532

516-
<div>
517-
<Header2 spacing>Git settings</Header2>
518-
<div className="w-full rounded-sm border border-grid-dimmed p-4">
519-
{connectedGithubRepository ? (
520-
<ConnectedGitHubRepoForm connectedGitHubRepo={connectedGithubRepository} />
521-
) : (
522-
<GitHubConnectionPrompt
523-
gitHubAppInstallations={githubAppInstallations}
524-
organizationSlug={organization.slug}
525-
/>
526-
)}
533+
{githubAppEnabled && (
534+
<div>
535+
<Header2 spacing>Git settings</Header2>
536+
<div className="w-full rounded-sm border border-grid-dimmed p-4">
537+
{connectedGithubRepository ? (
538+
<ConnectedGitHubRepoForm connectedGitHubRepo={connectedGithubRepository} />
539+
) : (
540+
<GitHubConnectionPrompt
541+
gitHubAppInstallations={githubAppInstallations}
542+
organizationSlug={organization.slug}
543+
/>
544+
)}
545+
</div>
527546
</div>
528-
</div>
547+
)}
529548

530549
<div>
531550
<Header2 spacing>Danger zone</Header2>

0 commit comments

Comments
 (0)