Skip to content

Commit aee3f28

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 c33e714 commit aee3f28

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
@@ -94,6 +94,7 @@ export async function toRepositoryShapeWithProvider(
9494
: undefined,
9595
supportedFeatures: remote.provider.supportedFeatures,
9696
url: await remote.provider.url({ type: RemoteResourceType.Repo }),
97+
bestRemoteName: remote.name,
9798
};
9899
if (provider.integration?.id == null) {
99100
provider.integration = undefined;

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
@@ -55,6 +55,7 @@ import { isMcpBannerEnabled, mcpExtensionRegistrationAllowed } from '../../plus/
5555
import { isAiAllAccessPromotionActive } from '../../plus/gk/utils/-webview/promo.utils';
5656
import { isSubscriptionTrialOrPaidFromState } from '../../plus/gk/utils/subscription.utils';
5757
import type { ConfiguredIntegrationsChangeEvent } from '../../plus/integrations/authentication/configuredIntegrationService';
58+
import type { ConnectionStateChangeEvent } from '../../plus/integrations/integrationService';
5859
import { providersMetadata } from '../../plus/integrations/providers/models';
5960
import type { LaunchpadCategorizedResult } from '../../plus/launchpad/launchpadProvider';
6061
import { getLaunchpadItemGroups } from '../../plus/launchpad/launchpadProvider';
@@ -179,6 +180,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
179180
this.container.subscription.onDidChange(this.onSubscriptionChanged, this),
180181
onDidChangeContext(this.onContextChanged, this),
181182
this.container.integrations.onDidChange(this.onIntegrationsChanged, this),
183+
this.container.integrations.onDidChangeConnectionState(this.onIntegrationConnectionStateChanged, this),
182184
this.container.walkthrough.onDidChangeProgress(this.onWalkthroughProgressChanged, this),
183185
configuration.onDidChange(this.onDidChangeConfig, this),
184186
this.container.launchpad.onDidChange(this.onLaunchpadChanged, this),
@@ -254,6 +256,10 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
254256
void this.notifyDidChangeIntegrations();
255257
}
256258

259+
private onIntegrationConnectionStateChanged(_e: ConnectionStateChangeEvent) {
260+
void this.notifyDidChangeIntegrations();
261+
}
262+
257263
private async onChooseRepository() {
258264
const currentRepo = this.getSelectedRepository();
259265
// // Ensure that the current repository is always last

0 commit comments

Comments
 (0)