Skip to content

Commit 510dd0b

Browse files
committed
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)
1 parent 82bd646 commit 510dd0b

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

src/git/models/repositoryShape.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ export interface RepositoryShape {
1414
integration?: { id: SupportedCloudIntegrationIds; connected: boolean };
1515
supportedFeatures: RemoteProviderSupportedFeatures;
1616
url?: string;
17+
bestRemoteName?: string;
1718
};
1819
}

src/git/utils/-webview/repository.utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export async function toRepositoryShapeWithProvider(
8484
: undefined,
8585
supportedFeatures: remote.provider.supportedFeatures,
8686
url: await remote.provider.url({ type: RemoteResourceType.Repo }),
87+
bestRemoteName: remote.name,
8788
};
8889
}
8990

src/webviews/apps/shared/components/repo-button-group.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { css, html, nothing } from 'lit';
22
import { customElement, property } from 'lit/decorators.js';
33
import { ifDefined } from 'lit/directives/if-defined.js';
44
import { when } from 'lit/directives/when.js';
5-
import type { ConnectCloudIntegrationsCommandArgs } from '../../../../commands/cloudIntegrations';
5+
import type { ConnectRemoteProviderCommandArgs } from '../../../../commands/remoteProviders';
66
import type { Source } from '../../../../constants.telemetry';
77
import type { RepositoryShape } from '../../../../git/models/repositoryShape';
88
import { createCommandLink } from '../../../../system/commands';
@@ -198,9 +198,9 @@ export class GlRepoButtonGroup extends GlElement {
198198
return html`
199199
<code-icon style="margin-top: -3px" icon="plug" aria-hidden="true"></code-icon>
200200
<a
201-
href=${createCommandLink<ConnectCloudIntegrationsCommandArgs>(
202-
'gitlens.plus.cloudIntegrations.connect',
203-
{ integrationIds: [provider.integration!.id], source: this.source },
201+
href=${createCommandLink<ConnectRemoteProviderCommandArgs>(
202+
'gitlens.connectRemoteProvider',
203+
{ remote: provider.bestRemoteName!, repoPath: repo.path },
204204
)}
205205
>
206206
Connect to ${repo.provider!.name}
@@ -227,10 +227,10 @@ export class GlRepoButtonGroup extends GlElement {
227227
<gl-button
228228
part="connect-icon"
229229
appearance="toolbar"
230-
href=${createCommandLink<ConnectCloudIntegrationsCommandArgs>(
231-
'gitlens.plus.cloudIntegrations.connect',
232-
{ integrationIds: [provider.integration.id], source: this.source },
233-
)}
230+
href=${createCommandLink<ConnectRemoteProviderCommandArgs>('gitlens.connectRemoteProvider', {
231+
remote: provider.bestRemoteName!,
232+
repoPath: repo.path,
233+
})}
234234
>
235235
<code-icon icon="plug" style="color: var(--titlebar-fg)"></code-icon>
236236
<span slot="tooltip">

src/webviews/home/homeWebview.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import type { SubscriptionChangeEvent } from '../../plus/gk/subscriptionService'
5454
import { isAiAllAccessPromotionActive } from '../../plus/gk/utils/-webview/promo.utils';
5555
import { isSubscriptionTrialOrPaidFromState } from '../../plus/gk/utils/subscription.utils';
5656
import type { ConfiguredIntegrationsChangeEvent } from '../../plus/integrations/authentication/configuredIntegrationService';
57+
import type { ConnectionStateChangeEvent } from '../../plus/integrations/integrationService';
5758
import { providersMetadata } from '../../plus/integrations/providers/models';
5859
import type { LaunchpadCategorizedResult } from '../../plus/launchpad/launchpadProvider';
5960
import { getLaunchpadItemGroups } from '../../plus/launchpad/launchpadProvider';
@@ -175,6 +176,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
175176
this.container.subscription.onDidChange(this.onSubscriptionChanged, this),
176177
onDidChangeContext(this.onContextChanged, this),
177178
this.container.integrations.onDidChange(this.onIntegrationsChanged, this),
179+
this.container.integrations.onDidChangeConnectionState(this.onIntegrationConnectionStateChanged, this),
178180
this.container.walkthrough?.onDidChangeProgress(this.onWalkthroughProgressChanged, this) ?? emptyDisposable,
179181
configuration.onDidChange(this.onDidChangeConfig, this),
180182
this.container.launchpad.onDidChange(this.onLaunchpadChanged, this),
@@ -243,6 +245,10 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
243245
void this.notifyDidChangeIntegrations();
244246
}
245247

248+
private onIntegrationConnectionStateChanged(_e: ConnectionStateChangeEvent) {
249+
void this.notifyDidChangeIntegrations();
250+
}
251+
246252
private async onChooseRepository() {
247253
const currentRepo = this.getSelectedRepository();
248254
// Ensure that the current repository is always last

0 commit comments

Comments
 (0)