Skip to content

Commit

Permalink
Allow selecting mongo version when creating database server (#2223)
Browse files Browse the repository at this point in the history
* Allow selecting mongo version

* Remove noisy pick options

* Localize wizard string
  • Loading branch information
JasonYeMSFT authored Jan 19, 2024
1 parent 9497ddb commit 3944a7c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/tree/AzureDBAPIStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { CosmosDBAccountCapacityStep } from './CosmosDBAccountWizard/CosmosDBAcc
import { CosmosDBAccountCreateStep } from './CosmosDBAccountWizard/CosmosDBAccountCreateStep';
import { CosmosDBAccountNameStep } from './CosmosDBAccountWizard/CosmosDBAccountNameStep';
import { ICosmosDBWizardContext } from './CosmosDBAccountWizard/ICosmosDBWizardContext';
import { MongoVersionStep } from './CosmosDBAccountWizard/MongoDBVersionStep';
import { IAzureDBWizardContext } from './IAzureDBWizardContext';

export class AzureDBAPIStep extends AzureWizardPromptStep<IPostgresServerWizardContext | ICosmosDBWizardContext> {
Expand Down Expand Up @@ -61,7 +62,8 @@ export class AzureDBAPIStep extends AzureWizardPromptStep<IPostgresServerWizardC
promptSteps = [
new CosmosDBAccountNameStep(),
new CosmosDBAccountCapacityStep(),
];
context.defaultExperience?.api === API.MongoDB ? new MongoVersionStep() : undefined
].filter((step): step is AzureWizardPromptStep<ICosmosDBWizardContext> => step !== undefined);
executeSteps = [
new CosmosDBAccountCreateStep(),
new VerifyProvidersStep(['Microsoft.DocumentDB'])
Expand Down
4 changes: 3 additions & 1 deletion src/tree/CosmosDBAccountWizard/CosmosDBAccountCreateStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export class CosmosDBAccountCreateStep extends AzureWizardExecuteStep<ICosmosDBW
};

if (defaultExperience?.api === 'MongoDB') {
options.apiProperties = { serverVersion: '3.6' };
if (context.mongoVersion !== undefined) {
options.apiProperties = { serverVersion: context.mongoVersion };
}
}

if (defaultExperience.capability) {
Expand Down
1 change: 1 addition & 0 deletions src/tree/CosmosDBAccountWizard/ICosmosDBWizardContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export interface ICosmosDBWizardContext extends IAzureDBWizardContext, ExecuteAc
databaseAccount?: DatabaseAccountGetResults;
isServerless?: boolean;

mongoVersion?: string;
}
26 changes: 26 additions & 0 deletions src/tree/CosmosDBAccountWizard/MongoDBVersionStep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzureWizardPromptStep } from '@microsoft/vscode-azext-utils';
import { localize } from "../../utils/localize";
import { ICosmosDBWizardContext } from './ICosmosDBWizardContext';

export class MongoVersionStep extends AzureWizardPromptStep<ICosmosDBWizardContext> {

public async prompt(context: ICosmosDBWizardContext): Promise<void> {
const mongoVersionOption = await context.ui.showQuickPick([
{ label: "v4.0", detail: "4.0" },
{ label: "v3.6", detail: "3.6" },
{ label: "v3.2", detail: "3.2" },
], {
placeHolder: localize("selectMongoVersion", "Select MongoDB version")
});
context.mongoVersion = mongoVersionOption.detail;
}

public shouldPrompt(_context: ICosmosDBWizardContext): boolean {
return true;
}
}

0 comments on commit 3944a7c

Please sign in to comment.