Skip to content
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

Generate Template link and blob container dropdown fix #25553

Merged
merged 4 commits into from
Apr 8, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import * as azdata from 'azdata';
import * as vscode from 'vscode';
import * as azurecore from 'azurecore';
import { MigrationServiceContext } from '../../models/migrationLocalStorage';
import * as styles from '../../constants/styles';
import * as constants from '../../constants/strings';
import * as utils from '../../api/utils';
Expand Down Expand Up @@ -42,7 +41,6 @@ export class SelectStorageAccountDialog {
private _dialog: azdata.window.Dialog;
private _view!: azdata.ModelView;
private _disposables: vscode.Disposable[] = [];
private _serviceContext!: MigrationServiceContext;
private _azureAccounts!: azdata.Account[];
private _accountTenants!: azurecore.Tenant[];
private _azureTenant!: azurecore.Tenant;
Expand Down Expand Up @@ -278,7 +276,7 @@ export class SelectStorageAccountDialog {
? utils.deepClone(selectedLocation)!
: undefined!;
} else {
this.migrationStateModel._location = undefined!;
this._location = undefined!;
}

await utils.clearDropDown(this._azureResourceGroupDropdown);
Expand Down Expand Up @@ -340,8 +338,6 @@ export class SelectStorageAccountDialog {
this._storageAccount = (selectedStorageAccount)
? utils.deepClone(selectedStorageAccount)!
: undefined!;
} else {
this._serviceContext.migrationService = undefined;
}
await utils.clearDropDown(this._blobContainerDropdown);
await this._populateBlobContainer();
Expand All @@ -365,6 +361,16 @@ export class SelectStorageAccountDialog {
CSSStyles: { ...DROPDOWN_CSS },
}).component();

this._disposables.push(
this._blobContainerDropdown.onValueChanged(async (value) => {
if (value && value !== undefined) {
const selectedBlobContainer = this._blobContainers?.find(rg => rg.name === (<azdata.CategoryValue>this._blobContainerDropdown.value)?.displayName);
this._blobContainer = (selectedBlobContainer)
? utils.deepClone(selectedBlobContainer)!
: undefined!;
}
}));

return this._view.modelBuilder.flexContainer()
.withItems([
subscriptionDropdownLabel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class AssessmentDetailsHeader {
private _generateTemplateLink!: azdata.HyperlinkComponent;
private _linksContainer!: azdata.FlexContainer;
private _separator!: azdata.TextComponent;
private _azureRecommendationLoadingText!: azdata.TextComponent;

// public getter for target type selection drop down.
public get targetTypeDropdown() {
Expand Down Expand Up @@ -219,8 +220,18 @@ export class AssessmentDetailsHeader {
CSSStyles: styles.SEPARATOR,
}).component();

this._azureRecommendationLoadingText = this._view.modelBuilder.text().withProps({
value: constants.LOADING_RECOMMENDATIONS,
CSSStyles: {
'font-size': '13px',
'font-weight': '400',
'line-height': '18px',
'display': 'none'
},
}).component();

this._linksContainer.addItems([this._viewDetailsLink, this._separator, this._generateTemplateLink]);
cardContainer.addItem(this._linksContainer);
cardContainer.addItems([this._azureRecommendationLoadingText, this._linksContainer]);
}

this._valueContainers.push(cardText);
Expand All @@ -232,35 +243,47 @@ export class AssessmentDetailsHeader {
// this value is populated to handle the case when user selects a target type and want to resume later.
this._targetSelectionDropdown.value = this.getTargetTypeBasedOnModel(migrationStateModel._targetType);

await this._viewDetailsLink.updateCssStyles({ 'display': 'none' });
await this._generateTemplateLink.updateCssStyles({ 'display': 'none' });
await this._separator.updateCssStyles({ 'display': 'none' });



const assessmentHeaderValues: { value: string | string[] | undefined; }[] = [];
assessmentHeaderValues.push({ value: "" });
assessmentHeaderValues.push(
{
value: String(migrationStateModel._assessmentResults?.databaseAssessments?.length)
},
{
value: String(migrationStateModel._assessmentResults.databaseAssessments.filter((db) => db.issues.filter(issue => issue.appliesToMigrationTargetPlatform === migrationStateModel._targetType && issue.issueCategory === IssueCategory.Issue)?.length === 0)?.length)
});

// iterating over each value container and filling it with the corresponding text.
let index = 0;
this._valueContainers.forEach((valueContainer) =>
valueContainer.value = assessmentHeaderValues[index++].value);

if (!this._readonly) {
const recommendedConfigurations = await utils.getRecommendedConfiguration(migrationStateModel._targetType, migrationStateModel);
await this._azureRecommendationLoadingText.updateCssStyles({ 'display': 'block' });
await this.migrationStateModel.getSkuRecommendations();
let configurationValue = recommendedConfigurations[0] ?? "--";
if (migrationStateModel._targetType === MigrationTargetType.SQLVM && recommendedConfigurations?.length > 1) {
configurationValue = recommendedConfigurations[0] + "\n" + recommendedConfigurations[1];
}
assessmentHeaderValues.push({
value: configurationValue
})

this._valueContainers[0].value = configurationValue;

if (configurationValue !== "--") {
await this._viewDetailsLink.updateCssStyles({ 'display': 'block' });
await this._generateTemplateLink.updateCssStyles({ 'display': 'block' });
await this._separator.updateCssStyles({ 'display': 'block' });
}

await this._azureRecommendationLoadingText.updateCssStyles({ 'display': 'none' });
}
assessmentHeaderValues.push(
{
value: String(migrationStateModel._assessmentResults?.databaseAssessments?.length)
},
{
value: String(migrationStateModel._assessmentResults.databaseAssessments.filter((db) => db.issues.filter(issue => issue.appliesToMigrationTargetPlatform === migrationStateModel._targetType && issue.issueCategory === IssueCategory.Issue)?.length === 0)?.length)
});

// iterating over each value container and filling it with the corresponding text.
let index = 0;
this._valueContainers.forEach((valueContainer) =>
valueContainer.value = assessmentHeaderValues[index++].value);
}

// function that create target selection dropdown
Expand Down
Loading