Add repository weburl (#243)

This commit is contained in:
Brendan Kellam 2025-03-24 14:02:43 -07:00 committed by GitHub
parent fda7986617
commit f4db3d226f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 21 additions and 8 deletions

View file

@ -40,6 +40,7 @@ export const compileGithubConfig = async (
external_codeHostType: 'github', external_codeHostType: 'github',
external_codeHostUrl: hostUrl, external_codeHostUrl: hostUrl,
cloneUrl: cloneUrl.toString(), cloneUrl: cloneUrl.toString(),
webUrl: repo.html_url,
name: repoName, name: repoName,
imageUrl: repo.owner.avatar_url, imageUrl: repo.owner.avatar_url,
isFork: repo.fork, isFork: repo.fork,
@ -105,6 +106,7 @@ export const compileGitlabConfig = async (
external_codeHostType: 'gitlab', external_codeHostType: 'gitlab',
external_codeHostUrl: hostUrl, external_codeHostUrl: hostUrl,
cloneUrl: cloneUrl.toString(), cloneUrl: cloneUrl.toString(),
webUrl: projectUrl,
name: repoName, name: repoName,
imageUrl: project.avatar_url, imageUrl: project.avatar_url,
isFork: isFork, isFork: isFork,
@ -166,6 +168,7 @@ export const compileGiteaConfig = async (
external_codeHostType: 'gitea', external_codeHostType: 'gitea',
external_codeHostUrl: hostUrl, external_codeHostUrl: hostUrl,
cloneUrl: cloneUrl.toString(), cloneUrl: cloneUrl.toString(),
webUrl: repo.html_url,
name: repoName, name: repoName,
imageUrl: repo.owner?.avatar_url, imageUrl: repo.owner?.avatar_url,
isFork: repo.fork!, isFork: repo.fork!,
@ -230,6 +233,7 @@ export const compileGerritConfig = async (
external_codeHostType: 'gerrit', external_codeHostType: 'gerrit',
external_codeHostUrl: hostUrl, external_codeHostUrl: hostUrl,
cloneUrl: cloneUrl.toString(), cloneUrl: cloneUrl.toString(),
webUrl: webUrl,
name: project.name, name: project.name,
isFork: false, isFork: false,
isArchived: false, isArchived: false,

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Repo" ADD COLUMN "webUrl" TEXT;

View file

@ -45,6 +45,7 @@ model Repo {
isArchived Boolean isArchived Boolean
metadata Json metadata Json
cloneUrl String cloneUrl String
webUrl String?
connections RepoToConnection[] connections RepoToConnection[]
imageUrl String? imageUrl String?
repoIndexingStatus RepoIndexingStatus @default(NEW) repoIndexingStatus RepoIndexingStatus @default(NEW)

View file

@ -430,6 +430,7 @@ export const getRepos = async (domain: string, filter: { status?: RepoIndexingSt
repoId: repo.id, repoId: repo.id,
repoName: repo.name, repoName: repo.name,
repoCloneUrl: repo.cloneUrl, repoCloneUrl: repo.cloneUrl,
webUrl: repo.webUrl ?? undefined,
linkedConnections: repo.connections.map(({ connection }) => ({ linkedConnections: repo.connections.map(({ connection }) => ({
id: connection.id, id: connection.id,
name: connection.name, name: connection.name,

View file

@ -89,8 +89,12 @@ export const NavigationMenu = async ({
<div className="flex flex-row items-center gap-2"> <div className="flex flex-row items-center gap-2">
<ProgressNavIndicator /> <ProgressNavIndicator />
{env.SOURCEBOT_AUTH_ENABLED === 'true' && (
<>
<WarningNavIndicator /> <WarningNavIndicator />
<ErrorNavIndicator /> <ErrorNavIndicator />
</>
)}
<TrialNavIndicator subscription={subscription} /> <TrialNavIndicator subscription={subscription} />
<form <form
action={async () => { action={async () => {

View file

@ -44,7 +44,7 @@ export const RepositoryTable = ({ isAddNewRepoButtonVisible }: RepositoryTablePr
connections: repo.linkedConnections, connections: repo.linkedConnections,
repoIndexingStatus: repo.repoIndexingStatus as RepoIndexingStatus, repoIndexingStatus: repo.repoIndexingStatus as RepoIndexingStatus,
lastIndexed: repo.indexedAt?.toISOString() ?? "", lastIndexed: repo.indexedAt?.toISOString() ?? "",
url: repo.repoCloneUrl, url: repo.webUrl ?? repo.repoCloneUrl,
})).sort((a, b) => { })).sort((a, b) => {
return new Date(b.lastIndexed).getTime() - new Date(a.lastIndexed).getTime(); return new Date(b.lastIndexed).getTime() - new Date(a.lastIndexed).getTime();
}); });

View file

@ -105,14 +105,13 @@ const initSingleTenancy = async () => {
name: key, name: key,
orgId: SINGLE_TENANT_ORG_ID, orgId: SINGLE_TENANT_ORG_ID,
} }
},
select: {
config: true,
} }
}); });
const currentConnectionConfig = currentConnection ? currentConnection.config as unknown as ConnectionConfig : undefined; const currentConnectionConfig = currentConnection ? currentConnection.config as unknown as ConnectionConfig : undefined;
const syncNeededOnUpdate = currentConnectionConfig && JSON.stringify(currentConnectionConfig) !== JSON.stringify(newConnectionConfig); const syncNeededOnUpdate =
(currentConnectionConfig && JSON.stringify(currentConnectionConfig) !== JSON.stringify(newConnectionConfig)) ||
(currentConnection?.syncStatus === ConnectionSyncStatus.FAILED);
const connectionDb = await prisma.connection.upsert({ const connectionDb = await prisma.connection.upsert({
where: { where: {

View file

@ -169,6 +169,7 @@ export const repositoryQuerySchema = z.object({
repoId: z.number(), repoId: z.number(),
repoName: z.string(), repoName: z.string(),
repoCloneUrl: z.string(), repoCloneUrl: z.string(),
webUrl: z.string().optional(),
linkedConnections: z.array(z.object({ linkedConnections: z.array(z.object({
id: z.number(), id: z.number(),
name: z.string(), name: z.string(),

View file

@ -63,7 +63,7 @@ export const getRepoQueryCodeHostInfo = (repo?: RepositoryQuery): CodeHostInfo |
} }
const displayName = repo.repoName.split('/').slice(-2).join('/'); const displayName = repo.repoName.split('/').slice(-2).join('/');
return _getCodeHostInfoInternal(repo.codeHostType, displayName, repo.repoCloneUrl); return _getCodeHostInfoInternal(repo.codeHostType, displayName, repo.webUrl ?? repo.repoCloneUrl);
} }
const _getCodeHostInfoInternal = (type: string, displayName: string, cloneUrl: string): CodeHostInfo | undefined => { const _getCodeHostInfoInternal = (type: string, displayName: string, cloneUrl: string): CodeHostInfo | undefined => {
@ -101,6 +101,7 @@ const _getCodeHostInfoInternal = (type: string, displayName: string, cloneUrl: s
iconClassName: className, iconClassName: className,
} }
} }
case 'gerrit':
case 'gitiles': { case 'gitiles': {
const { src, className } = getCodeHostIcon('gerrit')!; const { src, className } = getCodeHostIcon('gerrit')!;
return { return {