Skip to content

Commit 8eccc89

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)
1 parent 2179386 commit 8eccc89

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

src/git/models/repositoryShape.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ export interface RepositoryShape {
1414
integration?: { id: SupportedCloudIntegrationIds; connected: boolean };
1515
supportedFeatures: RemoteProviderSupportedFeatures;
1616
url?: string;
17+
remotePath?: string;
18+
remoteName?: string;
1719
};
1820
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ export async function toRepositoryShapeWithProvider(
8484
: undefined,
8585
supportedFeatures: remote.provider.supportedFeatures,
8686
url: await remote.provider.url({ type: RemoteResourceType.Repo }),
87+
remotePath: remote.path,
88+
remoteName: remote.name,
8789
};
8890
}
8991

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.remoteName!, 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.remoteName!,
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
@@ -51,6 +51,7 @@ import type { Subscription } from '../../plus/gk/models/subscription';
5151
import type { SubscriptionChangeEvent } from '../../plus/gk/subscriptionService';
5252
import { isSubscriptionTrialOrPaidFromState } from '../../plus/gk/utils/subscription.utils';
5353
import type { ConfiguredIntegrationsChangeEvent } from '../../plus/integrations/authentication/configuredIntegrationService';
54+
import type { ConnectionStateChangeEvent } from '../../plus/integrations/integrationService';
5455
import { providersMetadata } from '../../plus/integrations/providers/models';
5556
import type { LaunchpadCategorizedResult } from '../../plus/launchpad/launchpadProvider';
5657
import { getLaunchpadItemGroups } from '../../plus/launchpad/launchpadProvider';
@@ -170,6 +171,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
170171
this.container.subscription.onDidChange(this.onSubscriptionChanged, this),
171172
onDidChangeContext(this.onContextChanged, this),
172173
this.container.integrations.onDidChange(this.onIntegrationsChanged, this),
174+
this.container.integrations.onDidChangeConnectionState(this.onIntegrationConnectionStateChanged, this),
173175
this.container.walkthrough?.onDidChangeProgress(this.onWalkthroughProgressChanged, this) ?? emptyDisposable,
174176
configuration.onDidChange(this.onDidChangeConfig, this),
175177
this.container.launchpad.onDidChange(this.onLaunchpadChanged, this),
@@ -238,6 +240,10 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
238240
void this.notifyDidChangeIntegrations();
239241
}
240242

243+
private onIntegrationConnectionStateChanged(_e: ConnectionStateChangeEvent) {
244+
void this.notifyDidChangeIntegrations();
245+
}
246+
241247
private async onChooseRepository() {
242248
const currentRepo = this.getSelectedRepository();
243249
// Ensure that the current repository is always last

0 commit comments

Comments
 (0)