Skip to content

Commit 985ecc5

Browse files
committed
Fixes missing repo icon on Graph
Fixes incorrect integration connect button on Graph Fixes incorrect flow from integration connect button on Graph
1 parent 712cd33 commit 985ecc5

File tree

6 files changed

+51
-34
lines changed

6 files changed

+51
-34
lines changed

src/git/gitProviderService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2204,7 +2204,7 @@ export class GitProviderService implements Disposable {
22042204
const includeDisconnected = options?.includeDisconnected ?? false;
22052205
for (const r of remotes) {
22062206
if (r.hasIntegration()) {
2207-
const integration = await this.container.integrations.getByRemote(r);
2207+
const integration = await r.getIntegration();
22082208
if (integration != null) {
22092209
if (options?.filter?.(r, integration) === false) continue;
22102210

src/git/models/repository.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export type RepoGitProviderService = Pick<
3939
[K in keyof GitProviderService]: RemoveFirstArg<GitProviderService[K]>;
4040
},
4141
| keyof GitProviderRepository
42+
| 'getBestRemoteWithProvider'
43+
| 'getBestRemotesWithProviders'
4244
| 'getBestRemoteWithIntegration'
4345
| 'getBranch'
4446
| 'getRemote'

src/plus/integrations/integrationService.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -744,17 +744,8 @@ export class IntegrationService implements Disposable {
744744
await this.container.storage.deleteWithPrefix('provider:authentication:skip');
745745
}
746746

747-
supports(remoteId: RemoteProviderId): boolean {
748-
switch (remoteId) {
749-
case 'azure-devops':
750-
case 'bitbucket':
751-
case 'github':
752-
case 'gitlab':
753-
return true;
754-
case 'bitbucket-server':
755-
default:
756-
return false;
757-
}
747+
supports(remoteProviderId: RemoteProviderId): boolean {
748+
return remoteProviderIdToIntegrationId(remoteProviderId) != null;
758749
}
759750

760751
private _ignoreSSLErrors = new Map<string, boolean | 'force'>();
@@ -796,3 +787,22 @@ export class IntegrationService implements Disposable {
796787
return isSelfHostedIntegrationId(id) ? (`${id}:${domain}` as const) : id;
797788
}
798789
}
790+
791+
export function remoteProviderIdToIntegrationId(
792+
remoteProviderId: RemoteProviderId,
793+
): SupportedCloudIntegrationIds | undefined {
794+
switch (remoteProviderId) {
795+
// TODO: Uncomment when we support these integrations
796+
// case 'azure-devops':
797+
// return HostingIntegrationId.AzureDevOps;
798+
// case 'bitbucket':
799+
// return HostingIntegrationId.Bitbucket;
800+
case 'github':
801+
return HostingIntegrationId.GitHub;
802+
case 'gitlab':
803+
return HostingIntegrationId.GitLab;
804+
case 'bitbucket-server':
805+
default:
806+
return undefined;
807+
}
808+
}

src/plus/webviews/graph/graphWebview.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ import type { WebviewPanelShowCommandArgs, WebviewShowOptions } from '../../../w
120120
import { isSerializedState } from '../../../webviews/webviewsController';
121121
import type { SubscriptionChangeEvent } from '../../gk/account/subscriptionService';
122122
import type { ConnectionStateChangeEvent } from '../../integrations/integrationService';
123+
import { remoteProviderIdToIntegrationId } from '../../integrations/integrationService';
123124
import type {
124125
BranchState,
125126
DidChangeRefsVisibilityParams,
@@ -3741,34 +3742,34 @@ type GraphItemRefs<T> = {
37413742
async function formatRepositories(repositories: Repository[]): Promise<GraphRepository[]> {
37423743
if (repositories.length === 0) return Promise.resolve([]);
37433744

3744-
return Promise.all(
3745-
repositories.map(async r => {
3746-
const remote = await r.git.getBestRemoteWithIntegration();
3747-
3748-
// const integration = await remote?.getIntegration();
3749-
// const connected = integration ? integration?.maybeConnected ?? (await integration?.isConnected()) : false;
3750-
let connected = false;
3751-
if (remote?.maybeIntegrationConnected) {
3752-
connected = true;
3753-
}
3745+
const result = await Promise.allSettled(
3746+
repositories.map<Promise<GraphRepository>>(async repo => {
3747+
const remotes = await repo.git.getBestRemotesWithProviders();
3748+
const remote = remotes.find(r => r.hasIntegration()) ?? remotes[0];
37543749

37553750
return {
3756-
formattedName: r.formattedName,
3757-
id: r.id,
3758-
name: r.name,
3759-
path: r.path,
3751+
formattedName: repo.formattedName,
3752+
id: repo.id,
3753+
name: repo.name,
3754+
path: repo.path,
37603755
provider: remote?.provider
37613756
? {
37623757
name: remote.provider.name,
3763-
connected: connected,
3758+
integration: remote.hasIntegration()
3759+
? {
3760+
id: remoteProviderIdToIntegrationId(remote.provider.id)!,
3761+
connected: remote.maybeIntegrationConnected ?? false,
3762+
}
3763+
: undefined,
37643764
icon: remote.provider.icon === 'remote' ? 'cloud' : remote.provider.icon,
37653765
url: remote.provider.url({ type: RemoteResourceType.Repo }),
37663766
}
37673767
: undefined,
3768-
isVirtual: r.provider.virtual,
3768+
isVirtual: repo.provider.virtual,
37693769
};
37703770
}),
37713771
);
3772+
return result.map(r => getSettledValue(r)).filter(r => r != null);
37723773
}
37733774

37743775
function isGraphItemContext(item: unknown): item is GraphItemContext {

src/plus/webviews/graph/protocol.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import type {
2323
WorkDirStats,
2424
} from '@gitkraken/gitkraken-components';
2525
import type { Config, DateStyle, GraphBranchesVisibility } from '../../../config';
26+
import type { SupportedCloudIntegrationIds } from '../../../constants.integrations';
2627
import type { SearchQuery } from '../../../constants.search';
2728
import type { RepositoryVisibility } from '../../../git/gitProvider';
2829
import type { GitTrackingState } from '../../../git/models/branch';
@@ -153,7 +154,10 @@ export interface GraphRepository {
153154
isVirtual: boolean;
154155
provider?: {
155156
name: string;
156-
connected: boolean;
157+
integration?: {
158+
id: SupportedCloudIntegrationIds;
159+
connected: boolean;
160+
};
157161
icon?: string;
158162
url?: string;
159163
};

src/webviews/apps/plus/graph/GraphWrapper.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type { SlChangeEvent } from '@shoelace-style/shoelace';
1818
import { SlOption, SlSelect } from '@shoelace-style/shoelace/dist/react';
1919
import type { FormEvent, MouseEvent, ReactElement } from 'react';
2020
import React, { createElement, useEffect, useMemo, useRef, useState } from 'react';
21+
import type { ConnectCloudIntegrationsCommandArgs } from '../../../../commands/cloudIntegrations';
2122
import type { DateStyle, GraphBranchesVisibility } from '../../../../config';
2223
import type { Commands } from '../../../../constants.commands';
2324
import type { SearchQuery } from '../../../../constants.search';
@@ -1155,17 +1156,16 @@ export function GraphWrapper({
11551156
</a>
11561157
<span slot="content">Open Repository on {repo.provider.name}</span>
11571158
</GlTooltip>
1158-
{repo?.provider?.connected !== true && (
1159+
{repo?.provider?.integration?.connected === false && (
11591160
<GlConnect
11601161
type="action"
11611162
connected={false}
11621163
integration={repo.provider.name}
1163-
connectUrl={createCommandLink(
1164+
connectUrl={createCommandLink<ConnectCloudIntegrationsCommandArgs>(
11641165
'gitlens.plus.cloudIntegrations.connect' as Commands,
11651166
{
1166-
args: {
1167-
source: 'graph',
1168-
},
1167+
integrationIds: [repo.provider.integration.id],
1168+
source: 'graph',
11691169
},
11701170
)}
11711171
></GlConnect>

0 commit comments

Comments
 (0)