-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shortcut to switching to sovereign cloud within the tenant view (#…
…926) * initial commit * changes * rename and small changes * add new auth * fix bugs and add support for sovereign clouds * fix bugs * add another refresh * merge conflict fix * removed tools files and other requested changes * change * add in sovereign cloud shortcut * Add default * another change * add back comma * open setting on custom
- Loading branch information
Showing
7 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/commands/sovereignCloud/ConfigureSovereignCloudContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.md in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { IActionContext } from "@microsoft/vscode-azext-utils"; | ||
|
||
export interface ConfigureSovereignCloudContext extends IActionContext { | ||
sovereignCloud?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.md in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { AzureWizardPromptStep, IAzureQuickPickItem } from "@microsoft/vscode-azext-utils"; | ||
import { ConfigureSovereignCloudContext } from "./ConfigureSovereignCloudContext"; | ||
|
||
export class SovereignCloudListStep extends AzureWizardPromptStep<ConfigureSovereignCloudContext> { | ||
public async prompt(context: ConfigureSovereignCloudContext): Promise<void> { | ||
const picks: IAzureQuickPickItem<string>[] = [ | ||
{ label: 'Azure (Default)', data: '' }, | ||
{ label: 'Azure China', data: 'ChinaCloud' }, | ||
{ label: 'Azure US Government', data: 'USGovernment' }, | ||
{ label: 'A custom Microsoft Sovereign Cloud', data: 'custom' } | ||
] | ||
|
||
context.sovereignCloud = (await context.ui.showQuickPick(picks, { placeHolder: 'Select a sovereign cloud' })).data; | ||
} | ||
|
||
public shouldPrompt(context: ConfigureSovereignCloudContext): boolean { | ||
return !context.sovereignCloud; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.md in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { AzureWizardExecuteStep } from "@microsoft/vscode-azext-utils"; | ||
import * as vscode from 'vscode'; | ||
import { settingUtils } from "../../utils/settingUtils"; | ||
import { ConfigureSovereignCloudContext } from "./ConfigureSovereignCloudContext"; | ||
|
||
export class SovereignCloudSetStep extends AzureWizardExecuteStep<ConfigureSovereignCloudContext> { | ||
public priority: number = 10; | ||
|
||
public async execute(context: ConfigureSovereignCloudContext): Promise<void> { | ||
if (context.sovereignCloud === 'custom') { | ||
await vscode.commands.executeCommand('workbench.action.openSettings', 'microsoft-sovereign-cloud'); | ||
} else { | ||
await settingUtils.updateGlobalSetting('environment', context.sovereignCloud, 'microsoft-sovereign-cloud'); | ||
} | ||
} | ||
|
||
public shouldExecute(): boolean { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.md in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { AzureWizard } from "@microsoft/vscode-azext-utils"; | ||
import { ext } from "../../extensionVariables"; | ||
import { localize } from "../../utils/localize"; | ||
import { ConfigureSovereignCloudContext } from "./ConfigureSovereignCloudContext"; | ||
import { SovereignCloudListStep } from "./SovereignCloudListStep"; | ||
import { SovereignCloudSetStep } from "./SovereignCloudSetStep"; | ||
|
||
export async function configureSovereignCloud(context: ConfigureSovereignCloudContext): Promise<void> { | ||
const wizardContext: ConfigureSovereignCloudContext = { | ||
...context, | ||
}; | ||
|
||
const title: string = localize('selectSovereignCloud', 'Select Sovereign Cloud'); | ||
|
||
const wizard: AzureWizard<ConfigureSovereignCloudContext> = new AzureWizard(wizardContext, { | ||
title, | ||
promptSteps: [new SovereignCloudListStep()], | ||
executeSteps: [new SovereignCloudSetStep()], | ||
}); | ||
|
||
await wizard.prompt(); | ||
await wizard.execute(); | ||
|
||
// refresh resources and tenant view to accurrately reflect information for the selected sovereign cloud | ||
ext.actions.refreshAzureTree(); | ||
ext.actions.refreshTenantTree(); | ||
} |