Skip to content

Commit 5b6f4eb

Browse files
Fix viewing an app with a Git source where the installation has been removed
1 parent 6705aa8 commit 5b6f4eb

5 files changed

Lines changed: 55 additions & 20 deletions

File tree

backend/src/service/getDeployment.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import type { OrganizationRepo } from "../db/repo/organization.ts";
55
import type { KubernetesClientService } from "./common/cluster/kubernetes.ts";
66
import type { DeploymentConfigService } from "./common/deploymentConfig.ts";
77
import type { GitProviderFactoryService } from "./common/git/gitProvider.ts";
8-
import { DeploymentNotFoundError } from "./errors/index.ts";
8+
import {
9+
DeploymentNotFoundError,
10+
InstallationNotFoundError,
11+
} from "./errors/index.ts";
912

1013
export class GetDeploymentService {
1114
private orgRepo: OrganizationRepo;
@@ -57,11 +60,17 @@ export class GetDeploymentService {
5760
let repositoryURL: string | null = null;
5861
let pods: V1PodList | null = null;
5962
if (config.source === "GIT") {
60-
const gitProvider = await this.gitProviderFactoryService.getGitProvider(
61-
org.id,
62-
);
63-
const repo = await gitProvider?.getRepoById(config.repositoryId);
64-
repositoryURL = repo?.htmlURL;
63+
try {
64+
const gitProvider = await this.gitProviderFactoryService.getGitProvider(
65+
org.id,
66+
);
67+
const repo = await gitProvider?.getRepoById(config.repositoryId);
68+
repositoryURL = repo?.htmlURL;
69+
} catch (e) {
70+
if (!(e instanceof InstallationNotFoundError)) {
71+
throw e;
72+
}
73+
}
6574
}
6675
if (config.appType === "workload") {
6776
pods = await api

frontend/src/pages/DashboardView.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,15 @@ const AppCard = ({ app }: { app: components["schemas"]["AppSummary"] }) => {
135135
</Link>
136136
</p>
137137
{app.source === "GIT" ? (
138-
<p className="text-black-4 z-10 text-sm">
138+
<p className="text-black-4 text-sm">
139139
Commit <code>{app.commitHash?.slice(0, 8)}</code> on{" "}
140140
<a
141-
href={`${app.repositoryURL}/tree/${app.branch}`}
141+
className="relative z-10"
142+
href={
143+
app.repositoryURL
144+
? `${app.repositoryURL}/tree/${app.branch}`
145+
: "#"
146+
}
142147
target="_blank"
143148
rel="noreferrer"
144149
>

frontend/src/pages/DeploymentView.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ export const DeploymentView = () => {
8080
{deployment.config.source === "git" && deployment.commitHash ? (
8181
<a
8282
className="flex gap-1"
83-
href={`${app.repositoryURL}/commit/${deployment.commitHash}`}
83+
href={
84+
app.repositoryURL
85+
? `${app.repositoryURL}/commit/${deployment.commitHash}`
86+
: "#"
87+
}
8488
>
8589
<GitCommit /> {deployment.commitHash.substring(0, 7)}
8690
</a>

frontend/src/pages/app/OverviewTab.tsx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ export const OverviewTab = ({
133133
" a workflow "
134134
) : (
135135
<a
136-
href={`${app.repositoryURL}/tree/${app.config.branch}/${workflow.path}`}
136+
href={
137+
app.repositoryURL
138+
? `${app.repositoryURL}/tree/${app.config.branch}/${workflow.path}`
139+
: "#"
140+
}
137141
target="_blank"
138142
className="underline"
139143
rel="noreferrer"
@@ -174,15 +178,24 @@ export const OverviewTab = ({
174178
Git repository
175179
</p>
176180
<p>
177-
<a
178-
href={app.repositoryURL}
179-
className="flex items-center gap-1 underline"
180-
target="_blank"
181-
rel="noopener noreferrer"
182-
>
183-
{URL.parse(app.repositoryURL!)?.pathname?.substring(1)}
184-
<ExternalLink size={14} />
185-
</a>
181+
{app.repositoryURL ? (
182+
<a
183+
href={app.repositoryURL ?? "#"}
184+
className="flex items-center gap-1 underline"
185+
target="_blank"
186+
rel="noopener noreferrer"
187+
>
188+
{URL.parse(app.repositoryURL)?.pathname?.substring(1)}
189+
<ExternalLink size={14} />
190+
</a>
191+
) : (
192+
<p>
193+
Disconnected.{" "}
194+
<Link to="?tab=configuration" className="underline">
195+
Reconnect
196+
</Link>
197+
</p>
198+
)}
186199
</p>
187200
</>
188201
) : app.config.source === "image" ? (

frontend/src/pages/app/overview/RedeployModal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,11 @@ export const RedeployModal = ({
222222
<div className="my-2 ml-6">
223223
{pastDeployment.config.source === "git" ? (
224224
<a
225-
href={`${pastDeployment.repositoryURL}/commit/${pastDeployment.commitHash}`}
225+
href={
226+
pastDeployment.repositoryURL
227+
? `${pastDeployment.repositoryURL}/commit/${pastDeployment.commitHash}`
228+
: "#"
229+
}
226230
className="flex items-start gap-2"
227231
target="_blank"
228232
rel="noreferrer"

0 commit comments

Comments
 (0)