[SQL Migration] Add buttons to allow saving assessment/recommendation reports (#20212)

* Implement save assessment report

* Implement save recommendation report
This commit is contained in:
Raymond Truong
2022-08-15 15:29:40 -07:00
committed by GitHub
parent 10f5b8b76e
commit e64171503a
7 changed files with 116 additions and 24 deletions

View File

@@ -9,6 +9,10 @@ import { MigrationStateModel, MigrationTargetType } from '../../models/stateMach
import { SqlDatabaseTree } from './sqlDatabasesTree';
import { SqlMigrationImpactedObjectInfo } from 'mssql';
import { SKURecommendationPage } from '../../wizard/skuRecommendationPage';
import * as constants from '../../constants/strings';
import * as utils from '../../api/utils';
import * as fs from 'fs';
import path = require('path');
export type Issues = {
description: string,
@@ -24,6 +28,8 @@ export class AssessmentResultsDialog {
private _isOpen: boolean = false;
private dialog: azdata.window.Dialog | undefined;
private _model: MigrationStateModel;
private _saveButton!: azdata.window.Button;
private static readonly _assessmentReportName: string = 'SqlAssessmentReport.json';
// Dialog Name for Telemetry
public dialogName: string | undefined;
@@ -71,6 +77,27 @@ export class AssessmentResultsDialog {
this.dialog.cancelButton.label = AssessmentResultsDialog.CancelButtonText;
this._disposables.push(this.dialog.cancelButton.onClick(async () => await this.cancel()));
this._saveButton = azdata.window.createButton(
constants.SAVE_ASSESSMENT_REPORT,
'left');
this._disposables.push(
this._saveButton.onClick(async () => {
const folder = await utils.promptUserForFolder();
const destinationFilePath = path.join(folder, AssessmentResultsDialog._assessmentReportName);
if (this.model._assessmentReportFilePath) {
fs.copyFile(this.model._assessmentReportFilePath, destinationFilePath, (err) => {
if (err) {
console.log(err);
} else {
void vscode.window.showInformationMessage(constants.SAVE_ASSESSMENT_REPORT_SUCCESS(destinationFilePath));
}
});
} else {
console.log('assessment report not found');
}
}));
this.dialog.customButtons = [this._saveButton];
const dialogSetupPromises: Thenable<void>[] = [];
dialogSetupPromises.push(this.initializeDialog(this.dialog));