From da51fd7f598ec0c6a15fde36caedc8c41fc9a38e Mon Sep 17 00:00:00 2001 From: Sergei Shmakov Date: Tue, 17 Jun 2025 16:40:32 +0200 Subject: [PATCH] Enhances remote provider connection flow Updates the connect remote provider flow to directly use the remote name and repository path. This change simplifies the connection process and ensures accurate remote provider association. Adds remotePath and remoteName to the repository shape. (#4387, #4411) --- src/git/models/repositoryShape.ts | 1 + src/git/utils/-webview/repository.utils.ts | 1 + .../apps/shared/components/repo-button-group.ts | 16 ++++++++-------- src/webviews/home/homeWebview.ts | 6 ++++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/git/models/repositoryShape.ts b/src/git/models/repositoryShape.ts index 809b53a4b50f0..8f1638f34eb87 100644 --- a/src/git/models/repositoryShape.ts +++ b/src/git/models/repositoryShape.ts @@ -14,5 +14,6 @@ export interface RepositoryShape { integration?: { id: SupportedCloudIntegrationIds; connected: boolean }; supportedFeatures: RemoteProviderSupportedFeatures; url?: string; + bestRemoteName: string; }; } diff --git a/src/git/utils/-webview/repository.utils.ts b/src/git/utils/-webview/repository.utils.ts index 9459d81d1ba5a..b08cdf7663609 100644 --- a/src/git/utils/-webview/repository.utils.ts +++ b/src/git/utils/-webview/repository.utils.ts @@ -94,6 +94,7 @@ export async function toRepositoryShapeWithProvider( : undefined, supportedFeatures: remote.provider.supportedFeatures, url: await remote.provider.url({ type: RemoteResourceType.Repo }), + bestRemoteName: remote.name, }; if (provider.integration?.id == null) { provider.integration = undefined; diff --git a/src/webviews/apps/shared/components/repo-button-group.ts b/src/webviews/apps/shared/components/repo-button-group.ts index 218a671815b18..3edc760225b9b 100644 --- a/src/webviews/apps/shared/components/repo-button-group.ts +++ b/src/webviews/apps/shared/components/repo-button-group.ts @@ -2,7 +2,7 @@ import { css, html, nothing } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { ifDefined } from 'lit/directives/if-defined.js'; import { when } from 'lit/directives/when.js'; -import type { ConnectCloudIntegrationsCommandArgs } from '../../../../commands/cloudIntegrations'; +import type { ConnectRemoteProviderCommandArgs } from '../../../../commands/remoteProviders'; import type { Source } from '../../../../constants.telemetry'; import type { RepositoryShape } from '../../../../git/models/repositoryShape'; import { createCommandLink } from '../../../../system/commands'; @@ -198,9 +198,9 @@ export class GlRepoButtonGroup extends GlElement { return html` ( - 'gitlens.plus.cloudIntegrations.connect', - { integrationIds: [provider.integration!.id], source: this.source }, + href=${createCommandLink( + 'gitlens.connectRemoteProvider', + { repoPath: repo.path, remote: provider.bestRemoteName }, )} > Connect to ${repo.provider!.name} @@ -227,10 +227,10 @@ export class GlRepoButtonGroup extends GlElement { ( - 'gitlens.plus.cloudIntegrations.connect', - { integrationIds: [provider.integration.id], source: this.source }, - )} + href=${createCommandLink('gitlens.connectRemoteProvider', { + repoPath: repo.path, + remote: provider.bestRemoteName, + })} > diff --git a/src/webviews/home/homeWebview.ts b/src/webviews/home/homeWebview.ts index daed7b7a3d01f..538e08ae2fbb3 100644 --- a/src/webviews/home/homeWebview.ts +++ b/src/webviews/home/homeWebview.ts @@ -55,6 +55,7 @@ import { isMcpBannerEnabled, mcpExtensionRegistrationAllowed } from '../../plus/ import { isAiAllAccessPromotionActive } from '../../plus/gk/utils/-webview/promo.utils'; import { isSubscriptionTrialOrPaidFromState } from '../../plus/gk/utils/subscription.utils'; import type { ConfiguredIntegrationsChangeEvent } from '../../plus/integrations/authentication/configuredIntegrationService'; +import type { ConnectionStateChangeEvent } from '../../plus/integrations/integrationService'; import { providersMetadata } from '../../plus/integrations/providers/models'; import type { LaunchpadCategorizedResult } from '../../plus/launchpad/launchpadProvider'; import { getLaunchpadItemGroups } from '../../plus/launchpad/launchpadProvider'; @@ -179,6 +180,7 @@ export class HomeWebviewProvider implements WebviewProvider