Skip to content

Commit f4db3d2

Browse files
Add repository weburl (#243)
1 parent fda7986 commit f4db3d2

File tree

9 files changed

+21
-8
lines changed

9 files changed

+21
-8
lines changed

packages/backend/src/repoCompileUtils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const compileGithubConfig = async (
4040
external_codeHostType: 'github',
4141
external_codeHostUrl: hostUrl,
4242
cloneUrl: cloneUrl.toString(),
43+
webUrl: repo.html_url,
4344
name: repoName,
4445
imageUrl: repo.owner.avatar_url,
4546
isFork: repo.fork,
@@ -105,6 +106,7 @@ export const compileGitlabConfig = async (
105106
external_codeHostType: 'gitlab',
106107
external_codeHostUrl: hostUrl,
107108
cloneUrl: cloneUrl.toString(),
109+
webUrl: projectUrl,
108110
name: repoName,
109111
imageUrl: project.avatar_url,
110112
isFork: isFork,
@@ -166,6 +168,7 @@ export const compileGiteaConfig = async (
166168
external_codeHostType: 'gitea',
167169
external_codeHostUrl: hostUrl,
168170
cloneUrl: cloneUrl.toString(),
171+
webUrl: repo.html_url,
169172
name: repoName,
170173
imageUrl: repo.owner?.avatar_url,
171174
isFork: repo.fork!,
@@ -230,6 +233,7 @@ export const compileGerritConfig = async (
230233
external_codeHostType: 'gerrit',
231234
external_codeHostUrl: hostUrl,
232235
cloneUrl: cloneUrl.toString(),
236+
webUrl: webUrl,
233237
name: project.name,
234238
isFork: false,
235239
isArchived: false,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "Repo" ADD COLUMN "webUrl" TEXT;

packages/db/prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ model Repo {
4545
isArchived Boolean
4646
metadata Json
4747
cloneUrl String
48+
webUrl String?
4849
connections RepoToConnection[]
4950
imageUrl String?
5051
repoIndexingStatus RepoIndexingStatus @default(NEW)

packages/web/src/actions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ export const getRepos = async (domain: string, filter: { status?: RepoIndexingSt
430430
repoId: repo.id,
431431
repoName: repo.name,
432432
repoCloneUrl: repo.cloneUrl,
433+
webUrl: repo.webUrl ?? undefined,
433434
linkedConnections: repo.connections.map(({ connection }) => ({
434435
id: connection.id,
435436
name: connection.name,

packages/web/src/app/[domain]/components/navigationMenu.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ export const NavigationMenu = async ({
8989

9090
<div className="flex flex-row items-center gap-2">
9191
<ProgressNavIndicator />
92-
<WarningNavIndicator />
93-
<ErrorNavIndicator />
92+
{env.SOURCEBOT_AUTH_ENABLED === 'true' && (
93+
<>
94+
<WarningNavIndicator />
95+
<ErrorNavIndicator />
96+
</>
97+
)}
9498
<TrialNavIndicator subscription={subscription} />
9599
<form
96100
action={async () => {

packages/web/src/app/[domain]/repos/repositoryTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const RepositoryTable = ({ isAddNewRepoButtonVisible }: RepositoryTablePr
4444
connections: repo.linkedConnections,
4545
repoIndexingStatus: repo.repoIndexingStatus as RepoIndexingStatus,
4646
lastIndexed: repo.indexedAt?.toISOString() ?? "",
47-
url: repo.repoCloneUrl,
47+
url: repo.webUrl ?? repo.repoCloneUrl,
4848
})).sort((a, b) => {
4949
return new Date(b.lastIndexed).getTime() - new Date(a.lastIndexed).getTime();
5050
});

packages/web/src/initialize.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,13 @@ const initSingleTenancy = async () => {
105105
name: key,
106106
orgId: SINGLE_TENANT_ORG_ID,
107107
}
108-
},
109-
select: {
110-
config: true,
111108
}
112109
});
113110

114111
const currentConnectionConfig = currentConnection ? currentConnection.config as unknown as ConnectionConfig : undefined;
115-
const syncNeededOnUpdate = currentConnectionConfig && JSON.stringify(currentConnectionConfig) !== JSON.stringify(newConnectionConfig);
112+
const syncNeededOnUpdate =
113+
(currentConnectionConfig && JSON.stringify(currentConnectionConfig) !== JSON.stringify(newConnectionConfig)) ||
114+
(currentConnection?.syncStatus === ConnectionSyncStatus.FAILED);
116115

117116
const connectionDb = await prisma.connection.upsert({
118117
where: {

packages/web/src/lib/schemas.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export const repositoryQuerySchema = z.object({
169169
repoId: z.number(),
170170
repoName: z.string(),
171171
repoCloneUrl: z.string(),
172+
webUrl: z.string().optional(),
172173
linkedConnections: z.array(z.object({
173174
id: z.number(),
174175
name: z.string(),

packages/web/src/lib/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const getRepoQueryCodeHostInfo = (repo?: RepositoryQuery): CodeHostInfo |
6363
}
6464

6565
const displayName = repo.repoName.split('/').slice(-2).join('/');
66-
return _getCodeHostInfoInternal(repo.codeHostType, displayName, repo.repoCloneUrl);
66+
return _getCodeHostInfoInternal(repo.codeHostType, displayName, repo.webUrl ?? repo.repoCloneUrl);
6767
}
6868

6969
const _getCodeHostInfoInternal = (type: string, displayName: string, cloneUrl: string): CodeHostInfo | undefined => {
@@ -101,6 +101,7 @@ const _getCodeHostInfoInternal = (type: string, displayName: string, cloneUrl: s
101101
iconClassName: className,
102102
}
103103
}
104+
case 'gerrit':
104105
case 'gitiles': {
105106
const { src, className } = getCodeHostIcon('gerrit')!;
106107
return {

0 commit comments

Comments
 (0)