Skip to content

Commit 2fa3fac

Browse files
authored
Bump users to portal when initiating a new GitHub connection (#407)
1 parent d200981 commit 2fa3fac

File tree

6 files changed

+15
-216
lines changed

6 files changed

+15
-216
lines changed

src/commands/gitHub/connectToGitHub/DockerfileLocationInputStep.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/commands/gitHub/connectToGitHub/GitHubRepositoryConnectStep.ts

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/commands/gitHub/connectToGitHub/IConnectToGitHubContext.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/commands/gitHub/connectToGitHub/ServicePrincipalIdInputStep.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/commands/gitHub/connectToGitHub/ServicePrincipalSecretInputStep.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/commands/gitHub/connectToGitHub/connectToGitHub.ts

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,38 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { GitHubBranchListStep, GitHubOrgListStep, GitHubRepositoryListStep } from "@microsoft/vscode-azext-github";
7-
import { AzureWizard, AzureWizardExecuteStep, AzureWizardPromptStep, ITreeItemPickerContext, createSubscriptionContext } from "@microsoft/vscode-azext-utils";
8-
import type { ContainerAppItem } from "../../../tree/ContainerAppItem";
9-
import { createActivityContext } from "../../../utils/activityUtils";
6+
import { ITreeItemPickerContext, createSubscriptionContext, openUrl } from "@microsoft/vscode-azext-utils";
7+
import type { ContainerAppItem, ContainerAppModel } from "../../../tree/ContainerAppItem";
8+
import { createPortalUrl } from "../../../utils/createPortalUrl";
109
import { localize } from "../../../utils/localize";
1110
import { pickContainerApp } from "../../../utils/pickContainerApp";
12-
import { AcrListStep } from "../../deployImage/imageSource/containerRegistry/acr/AcrListStep";
13-
import { AcrRepositoriesListStep } from "../../deployImage/imageSource/containerRegistry/acr/AcrRepositoriesListStep";
14-
import { DockerfileLocationInputStep } from "./DockerfileLocationInputStep";
15-
import { GitHubRepositoryConnectStep } from "./GitHubRepositoryConnectStep";
16-
import type { IConnectToGitHubContext } from "./IConnectToGitHubContext";
17-
import { ServicePrincipalIdInputStep } from "./ServicePrincipalIdInputStep";
18-
import { ServicePrincipalSecretInputStep } from "./ServicePrincipalSecretInputStep";
11+
import { IContainerAppContext } from "../../IContainerAppContext";
1912
import { isGitHubConnected } from "./isGitHubConnected";
2013

21-
export async function connectToGitHub(context: ITreeItemPickerContext & Partial<IConnectToGitHubContext>, item?: Pick<ContainerAppItem, 'containerApp' | 'subscription'>): Promise<void> {
14+
export async function connectToGitHub(context: ITreeItemPickerContext, item?: Pick<ContainerAppItem, 'containerApp' | 'subscription'>): Promise<void> {
2215
if (!item) {
2316
context.suppressCreatePick = true;
2417
item = await pickContainerApp(context);
2518
}
2619

2720
const { subscription, containerApp } = item;
2821

29-
const wizardContext: IConnectToGitHubContext = {
22+
// Make containerApp _required_
23+
const containerAppContext: IContainerAppContext & { containerApp: ContainerAppModel } = {
3024
...context,
3125
...createSubscriptionContext(subscription),
32-
...await createActivityContext(),
3326
subscription,
34-
containerApp,
27+
containerApp
3528
};
3629

37-
if (await isGitHubConnected(wizardContext)) {
30+
if (await isGitHubConnected(containerAppContext)) {
3831
throw new Error(localize('gitHubAlreadyConnected', '"{0}" is already connected to a GitHub repository.', containerApp.name));
3932
}
4033

41-
const title: string = localize('connectGitHubRepository', 'Connect a GitHub repository to "{0}"', containerApp.name);
42-
43-
const promptSteps: AzureWizardPromptStep<IConnectToGitHubContext>[] = [
44-
new GitHubOrgListStep(),
45-
new GitHubRepositoryListStep(),
46-
new GitHubBranchListStep(),
47-
new DockerfileLocationInputStep(),
48-
new AcrListStep(),
49-
new AcrRepositoriesListStep(),
50-
new ServicePrincipalIdInputStep(),
51-
new ServicePrincipalSecretInputStep()
52-
];
53-
54-
const executeSteps: AzureWizardExecuteStep<IConnectToGitHubContext>[] = [
55-
new GitHubRepositoryConnectStep()
56-
];
57-
58-
const wizard: AzureWizard<IConnectToGitHubContext> = new AzureWizard(wizardContext, {
59-
title,
60-
promptSteps,
61-
executeSteps,
62-
showLoadingPrompt: true
63-
});
64-
65-
await wizard.prompt();
66-
await wizard.execute();
34+
/**
35+
* VS Code does not have sufficient scopes to handle CRUD on service principals & federated credentials.
36+
* Bump users to the portal to avoid providing an incomplete/partial connection experience.
37+
*/
38+
const portalUrl: string = createPortalUrl(subscription, `${containerApp.id}/continuousDeployment`).toString(true /** skipEncoding */);
39+
await openUrl(portalUrl);
6740
}

0 commit comments

Comments
 (0)