mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-27 17:23:21 -05:00
[SQL Migration] Add support for assessing XEvent session files (#22210)
* Template * Refactor * Update strings * Clean up * Add clear button * Clean up * Fix typo and use aka.ms link * Refactor to use GroupContainer * Remove dialog and clean up common strings * Fix previous/forward behavior * Make group container default to collapsed * Clean up * Slightly reword string * Add https to aka.ms link
This commit is contained in:
@@ -8,7 +8,7 @@ import * as vscode from 'vscode';
|
||||
import { MigrationWizardPage } from '../models/migrationWizardPage';
|
||||
import { MigrationStateModel, StateChangeEvent } from '../models/stateMachine';
|
||||
import * as constants from '../constants/strings';
|
||||
import { debounce } from '../api/utils';
|
||||
import { debounce, promptUserForFolder } from '../api/utils';
|
||||
import * as styles from '../constants/styles';
|
||||
import { IconPathHelper } from '../constants/iconPathHelper';
|
||||
import { getDatabasesList, excludeDatabases, SourceDatabaseInfo, getSourceConnectionProfile } from '../api/sqlUtils';
|
||||
@@ -16,11 +16,16 @@ import { getDatabasesList, excludeDatabases, SourceDatabaseInfo, getSourceConnec
|
||||
export class DatabaseSelectorPage extends MigrationWizardPage {
|
||||
private _view!: azdata.ModelView;
|
||||
private _databaseSelectorTable!: azdata.TableComponent;
|
||||
private _xEventsGroup!: azdata.GroupContainer;
|
||||
private _xEventsFolderPickerInput!: azdata.InputBoxComponent;
|
||||
private _xEventsFilesFolderPath!: string;
|
||||
private _dbNames!: string[];
|
||||
private _dbCount!: azdata.TextComponent;
|
||||
private _databaseTableValues!: any[];
|
||||
private _disposables: vscode.Disposable[] = [];
|
||||
|
||||
private readonly TABLE_WIDTH = 650;
|
||||
|
||||
constructor(wizard: azdata.window.Wizard, migrationStateModel: MigrationStateModel) {
|
||||
super(wizard, azdata.window.createWizardPage(constants.DATABASE_FOR_ASSESSMENT_PAGE_TITLE), migrationStateModel);
|
||||
}
|
||||
@@ -61,6 +66,8 @@ export class DatabaseSelectorPage extends MigrationWizardPage {
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
this._xEventsFilesFolderPath = this.migrationStateModel._xEventsFilesFolderPath;
|
||||
}
|
||||
|
||||
public async onPageLeave(): Promise<void> {
|
||||
@@ -73,11 +80,15 @@ export class DatabaseSelectorPage extends MigrationWizardPage {
|
||||
// * no prior assessment
|
||||
// * the prior assessment had an error or
|
||||
// * the assessed databases list is different from the selected databases list
|
||||
// * the XEvents path has changed
|
||||
this.migrationStateModel._runAssessments = !this.migrationStateModel._assessmentResults
|
||||
|| !!this.migrationStateModel._assessmentResults?.assessmentError
|
||||
|| assessedDatabases.length === 0
|
||||
|| assessedDatabases.length !== selectedDatabases.length
|
||||
|| assessedDatabases.some(db => selectedDatabases.indexOf(db) < 0);
|
||||
|| assessedDatabases.some(db => selectedDatabases.indexOf(db) < 0)
|
||||
|| this.migrationStateModel._xEventsFilesFolderPath.toLowerCase() !== this._xEventsFilesFolderPath.toLowerCase();
|
||||
|
||||
this.migrationStateModel._xEventsFilesFolderPath = this._xEventsFilesFolderPath;
|
||||
}
|
||||
|
||||
protected async handleStateChange(e: StateChangeEvent): Promise<void> {
|
||||
@@ -156,8 +167,9 @@ export class DatabaseSelectorPage extends MigrationWizardPage {
|
||||
this._databaseSelectorTable = this._view.modelBuilder.table()
|
||||
.withProps({
|
||||
data: [],
|
||||
width: 650,
|
||||
width: this.TABLE_WIDTH,
|
||||
height: '100%',
|
||||
CSSStyles: { 'margin-bottom': '12px' },
|
||||
forceFitColumns: azdata.ColumnSizingMode.ForceFit,
|
||||
columns: [
|
||||
<azdata.CheckboxColumn>{
|
||||
@@ -212,18 +224,91 @@ export class DatabaseSelectorPage extends MigrationWizardPage {
|
||||
// load unfiltered table list and pre-select list of databases saved in state
|
||||
await this._filterTableList('', this.migrationStateModel._databasesForAssessment);
|
||||
|
||||
const xEventsDescription = this._view.modelBuilder.text()
|
||||
.withProps({
|
||||
value: constants.XEVENTS_ASSESSMENT_DESCRIPTION,
|
||||
width: this.TABLE_WIDTH,
|
||||
CSSStyles: { ...styles.BODY_CSS },
|
||||
links: [{ text: constants.XEVENTS_ASSESSMENT_HELPLINK, url: 'https://aka.ms/sql-migration-xe-assess' }]
|
||||
}).component();
|
||||
|
||||
const xEventsInstructions = this._view.modelBuilder.text()
|
||||
.withProps({
|
||||
value: constants.XEVENTS_ASSESSMENT_OPEN_FOLDER,
|
||||
width: this.TABLE_WIDTH,
|
||||
CSSStyles: { ...styles.LABEL_CSS },
|
||||
}).component();
|
||||
|
||||
this._xEventsFolderPickerInput = this._view.modelBuilder.inputBox()
|
||||
.withProps({
|
||||
placeHolder: constants.FOLDER_NAME,
|
||||
readOnly: true,
|
||||
width: 460,
|
||||
ariaLabel: constants.XEVENTS_ASSESSMENT_OPEN_FOLDER
|
||||
}).component();
|
||||
this._disposables.push(
|
||||
this._xEventsFolderPickerInput.onTextChanged(async (value) => {
|
||||
if (value) {
|
||||
this._xEventsFilesFolderPath = value.trim();
|
||||
}
|
||||
}));
|
||||
|
||||
const xEventsFolderPickerButton = this._view.modelBuilder.button()
|
||||
.withProps({
|
||||
label: constants.OPEN,
|
||||
width: 80,
|
||||
}).component();
|
||||
this._disposables.push(
|
||||
xEventsFolderPickerButton.onDidClick(
|
||||
async () => this._xEventsFolderPickerInput.value = await promptUserForFolder()));
|
||||
|
||||
const xEventsFolderPickerClearButton = this._view.modelBuilder.button()
|
||||
.withProps({
|
||||
label: constants.CLEAR,
|
||||
width: 80,
|
||||
}).component();
|
||||
this._disposables.push(
|
||||
xEventsFolderPickerClearButton.onDidClick(
|
||||
async () => {
|
||||
this._xEventsFolderPickerInput.value = '';
|
||||
this._xEventsFilesFolderPath = '';
|
||||
}));
|
||||
|
||||
const xEventsFolderPickerContainer = this._view.modelBuilder.flexContainer()
|
||||
.withProps({
|
||||
CSSStyles: { 'flex-direction': 'row', 'align-items': 'left' }
|
||||
}).withItems([
|
||||
this._xEventsFolderPickerInput,
|
||||
xEventsFolderPickerButton,
|
||||
xEventsFolderPickerClearButton
|
||||
]).component();
|
||||
|
||||
this._xEventsGroup = this._view.modelBuilder.groupContainer()
|
||||
.withLayout({
|
||||
header: constants.XEVENTS_ASSESSMENT_TITLE,
|
||||
collapsible: true,
|
||||
collapsed: true
|
||||
}).withItems([
|
||||
xEventsDescription,
|
||||
xEventsInstructions,
|
||||
xEventsFolderPickerContainer
|
||||
]).component();
|
||||
|
||||
const flex = view.modelBuilder.flexContainer().withLayout({
|
||||
flexFlow: 'column',
|
||||
height: '100%',
|
||||
height: '65%',
|
||||
}).withProps({
|
||||
CSSStyles: {
|
||||
'margin': '0px 28px 0px 28px'
|
||||
}
|
||||
}).component();
|
||||
|
||||
flex.addItem(text, { flex: '0 0 auto' });
|
||||
flex.addItem(this.createSearchComponent(), { flex: '0 0 auto' });
|
||||
flex.addItem(this._dbCount, { flex: '0 0 auto' });
|
||||
flex.addItem(this._databaseSelectorTable);
|
||||
flex.addItem(this._xEventsGroup, { flex: '0 0 auto' });
|
||||
|
||||
return flex;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user