Skip to content

Commit 953b201

Browse files
committed
Hide git settings when github app is disabled
1 parent 4e8d20f commit 953b201

File tree

1 file changed

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

1 file changed

+33
-16
lines changed

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

Lines changed: 33 additions & 16 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({
@@ -257,8 +273,6 @@ export const action: ActionFunction = async ({ request, params }) => {
257273
return json({ errors: { body: "project not found" } }, { status: 404 });
258274
}
259275

260-
console.log(submission.value);
261-
262276
try {
263277
switch (submission.value.action) {
264278
case "rename": {
@@ -400,7 +414,8 @@ export const action: ActionFunction = async ({ request, params }) => {
400414
};
401415

402416
export default function Page() {
403-
const { githubAppInstallations, connectedGithubRepository } = useTypedLoaderData<typeof loader>();
417+
const { githubAppInstallations, connectedGithubRepository, githubAppEnabled } =
418+
useTypedLoaderData<typeof loader>();
404419
const project = useProject();
405420
const organization = useOrganization();
406421
const lastSubmission = useActionData();
@@ -513,19 +528,21 @@ export default function Page() {
513528
</div>
514529
</div>
515530

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-
)}
531+
{githubAppEnabled && (
532+
<div>
533+
<Header2 spacing>Git settings</Header2>
534+
<div className="w-full rounded-sm border border-grid-dimmed p-4">
535+
{connectedGithubRepository ? (
536+
<ConnectedGitHubRepoForm connectedGitHubRepo={connectedGithubRepository} />
537+
) : (
538+
<GitHubConnectionPrompt
539+
gitHubAppInstallations={githubAppInstallations}
540+
organizationSlug={organization.slug}
541+
/>
542+
)}
543+
</div>
527544
</div>
528-
</div>
545+
)}
529546

530547
<div>
531548
<Header2 spacing>Danger zone</Header2>

0 commit comments

Comments
 (0)