Skip to content

Enhances remote provider connection flow #4411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/git/models/repositoryShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ export interface RepositoryShape {
integration?: { id: SupportedCloudIntegrationIds; connected: boolean };
supportedFeatures: RemoteProviderSupportedFeatures;
url?: string;
remotePath?: string;
remoteName?: string;
};
}
2 changes: 2 additions & 0 deletions src/git/utils/-webview/repository.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export async function toRepositoryShapeWithProvider(
: undefined,
supportedFeatures: remote.provider.supportedFeatures,
url: await remote.provider.url({ type: RemoteResourceType.Repo }),
remotePath: remote.path,
remoteName: remote.name,
};
}

Expand Down
16 changes: 8 additions & 8 deletions src/webviews/apps/shared/components/repo-button-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -198,9 +198,9 @@ export class GlRepoButtonGroup extends GlElement {
return html`
<code-icon style="margin-top: -3px" icon="plug" aria-hidden="true"></code-icon>
<a
href=${createCommandLink<ConnectCloudIntegrationsCommandArgs>(
'gitlens.plus.cloudIntegrations.connect',
{ integrationIds: [provider.integration!.id], source: this.source },
href=${createCommandLink<ConnectRemoteProviderCommandArgs>(
'gitlens.connectRemoteProvider',
{ remote: provider.remoteName!, repoPath: repo.path },
)}
>
Connect to ${repo.provider!.name}
Expand All @@ -227,10 +227,10 @@ export class GlRepoButtonGroup extends GlElement {
<gl-button
part="connect-icon"
appearance="toolbar"
href=${createCommandLink<ConnectCloudIntegrationsCommandArgs>(
'gitlens.plus.cloudIntegrations.connect',
{ integrationIds: [provider.integration.id], source: this.source },
)}
href=${createCommandLink<ConnectRemoteProviderCommandArgs>('gitlens.connectRemoteProvider', {
remote: provider.remoteName!,
repoPath: repo.path,
})}
>
<code-icon icon="plug" style="color: var(--titlebar-fg)"></code-icon>
<span slot="tooltip">
Expand Down
6 changes: 6 additions & 0 deletions src/webviews/home/homeWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import type { Subscription } from '../../plus/gk/models/subscription';
import type { SubscriptionChangeEvent } from '../../plus/gk/subscriptionService';
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';
Expand Down Expand Up @@ -170,6 +171,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
this.container.subscription.onDidChange(this.onSubscriptionChanged, this),
onDidChangeContext(this.onContextChanged, this),
this.container.integrations.onDidChange(this.onIntegrationsChanged, this),
this.container.integrations.onDidChangeConnectionState(this.onIntegrationConnectionStateChanged, this),
this.container.walkthrough?.onDidChangeProgress(this.onWalkthroughProgressChanged, this) ?? emptyDisposable,
configuration.onDidChange(this.onDidChangeConfig, this),
this.container.launchpad.onDidChange(this.onLaunchpadChanged, this),
Expand Down Expand Up @@ -238,6 +240,10 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
void this.notifyDidChangeIntegrations();
}

private onIntegrationConnectionStateChanged(_e: ConnectionStateChangeEvent) {
void this.notifyDidChangeIntegrations();
}

private async onChooseRepository() {
const currentRepo = this.getSelectedRepository();
// Ensure that the current repository is always last
Expand Down