Exclude Object Types Coming from DacFx and tests all working as expected (#20015)

* Include Objects Coming from DacFx and tests all working as expected

* Exclude Object types functionality is working as expected and Unit tests

* more refactor updates

* Updated comments and prop name

* Addressing the coments and code updates accordingly

* Updating according to the comments

* STS vbump

* These changes should be deleted with SC changes, not here

* format fixed
This commit is contained in:
Sai Avishkar Sreerama
2022-08-08 12:04:24 -05:00
committed by GitHub
parent 66115d8f80
commit 2b5d2f0a0b
12 changed files with 193 additions and 26 deletions

View File

@@ -145,7 +145,6 @@ export class PublishDatabaseDialog {
this.connectionRow = this.createConnectionRow(view);
this.databaseRow = this.createDatabaseRow(view);
const displayOptionsButton = this.createOptionsButton(view);
displayOptionsButton.enabled = false;
const horizontalFormSection = view.modelBuilder.flexContainer().withLayout({ flexFlow: 'column' }).component();
horizontalFormSection.addItems([profileRow, this.databaseRow]);
@@ -172,12 +171,10 @@ export class PublishDatabaseDialog {
title: constants.selectConnectionRadioButtonsTitle,
component: selectConnectionRadioButtons
},*/
/* TODO : Disabling deployment options for the July release
{
component: displayOptionsButton,
title: ''
}
*/
]
}
], {
@@ -938,7 +935,12 @@ export class PublishDatabaseDialog {
* Gets the default deployment options from the dacfx service
*/
public async getDefaultDeploymentOptions(): Promise<DeploymentOptions> {
return await utils.getDefaultPublishDeploymentOptions(this.project) as DeploymentOptions;
const defaultDeploymentOptions = await utils.getDefaultPublishDeploymentOptions(this.project) as DeploymentOptions;
if (defaultDeploymentOptions && defaultDeploymentOptions.excludeObjectTypes !== undefined) {
// For publish dialog no default exclude options should exists
defaultDeploymentOptions.excludeObjectTypes.value = [];
}
return defaultDeploymentOptions;
}
/*

View File

@@ -24,6 +24,9 @@ export class PublishOptionsDialog {
private optionsFlexBuilder: azdataType.FlexContainer | undefined;
private optionsChanged: boolean = false;
private isResetOptionsClicked: boolean = false;
private excludeObjectTypesOptionsTab: azdataType.window.DialogTab | undefined;
private excludeObjectTypesOptionsTable: azdataType.TableComponent | undefined;
private excludeObjectTypesOptionsFlexBuilder: azdataType.FlexContainer | undefined;
constructor(defaultOptions: mssql.DeploymentOptions, private publish: PublishDatabaseDialog) {
this.optionsModel = new DeployOptionsModel(defaultOptions);
@@ -31,8 +34,10 @@ export class PublishOptionsDialog {
protected initializeDialog(): void {
this.optionsTab = utils.getAzdataApi()!.window.createTab(constants.PublishOptions);
this.intializeDeploymentOptionsDialogTab();
this.dialog.content = [this.optionsTab];
this.excludeObjectTypesOptionsTab = utils.getAzdataApi()!.window.createTab(constants.ExcludeObjectTypeTab);
this.initializeDeploymentOptionsDialogTab();
this.initializeExcludeObjectTypesOptionsDialogTab();
this.dialog.content = [this.optionsTab, this.excludeObjectTypesOptionsTab];
}
public openDialog(): void {
@@ -55,7 +60,7 @@ export class PublishOptionsDialog {
utils.getAzdataApi()!.window.openDialog(this.dialog);
}
private intializeDeploymentOptionsDialogTab(): void {
private initializeDeploymentOptionsDialogTab(): void {
this.optionsTab?.registerContent(async view => {
this.descriptionHeading = view.modelBuilder.table().withProps({
data: [],
@@ -113,6 +118,34 @@ export class PublishOptionsDialog {
});
}
private initializeExcludeObjectTypesOptionsDialogTab(): void {
this.excludeObjectTypesOptionsTab?.registerContent(async view => {
this.excludeObjectTypesOptionsTable = view.modelBuilder.table().component();
await this.updateExcludeObjectsTable();
// Update exclude type options value on checkbox onchange
this.disposableListeners.push(this.excludeObjectTypesOptionsTable!.onCellAction!((rowState) => {
const checkboxState = <azdataType.ICheckboxCellActionEventArgs>rowState;
if (checkboxState && checkboxState.row !== undefined) {
// data[row][1] contains the exclude type option display name
const displayName = this.excludeObjectTypesOptionsTable?.data[checkboxState.row][1];
this.optionsModel.setExcludeObjectTypesOptionValue(displayName, checkboxState.checked);
this.optionsChanged = true;
// customButton[0] is the reset button, enabling it when option checkbox is changed
this.dialog.customButtons[0].enabled = true;
}
}));
this.excludeObjectTypesOptionsFlexBuilder = view.modelBuilder.flexContainer()
.withLayout({
flexFlow: 'column'
}).component();
this.excludeObjectTypesOptionsFlexBuilder.addItem(this.excludeObjectTypesOptionsTable, { CSSStyles: { 'overflow': 'scroll', 'height': '80vh', 'padding-top': '2px' } });
await view.initializeModel(this.excludeObjectTypesOptionsFlexBuilder);
});
}
/*
* Update the default options to the options table area
*/
@@ -141,12 +174,41 @@ export class PublishOptionsDialog {
});
}
/*
* Update the default options to the exclude objects table area
*/
private async updateExcludeObjectsTable(): Promise<void> {
const data = this.optionsModel.getExcludeObjectTypesOptionsData();
await this.excludeObjectTypesOptionsTable?.updateProperties({
data: data,
columns: [
<azdataType.CheckboxColumn>
{
value: constants.OptionInclude,
type: utils.getAzdataApi()!.ColumnType.checkBox,
action: utils.getAzdataApi()!.ActionOnCellCheckboxCheck.customAction,
headerCssClass: 'display-none',
cssClass: 'no-borders align-with-header',
width: 50
},
{
value: constants.OptionName,
headerCssClass: 'display-none',
cssClass: 'no-borders align-with-header',
width: 50
}
],
ariaRowCount: data.length
});
}
/*
* Ok button click, will update the deployment options with selections
*/
protected execute(): void {
// Update the model deploymentoptions with the updated table component values
// Update the model deploymentoptions with the updated options/excludeObjects table component values
this.optionsModel.setDeploymentOptions();
this.optionsModel.setExcludeObjectTypesToDeploymentOptions();
// Set the publish deploymentoptions with the updated table component values
this.publish.setDeploymentOptions(this.optionsModel.deploymentOptions);
this.disposeListeners();
@@ -173,14 +235,19 @@ export class PublishOptionsDialog {
const result = await this.publish.getDefaultDeploymentOptions();
this.optionsModel.deploymentOptions = result;
// reset optionsvalueNameLookup with default deployment options
// reset optionsvalueNameLookup and excludeObjectTypesLookup with default deployment options
this.optionsModel.setOptionsToValueNameLookup();
this.optionsModel.setExcludeObjectTypesLookup();
await this.updateOptionsTable();
this.optionsFlexBuilder?.removeItem(this.optionsTable!);
this.optionsFlexBuilder?.insertItem(this.optionsTable!, 0, { CSSStyles: { 'overflow': 'scroll', 'height': '65vh', 'padding-top': '2px' } });
TelemetryReporter.sendActionEvent(TelemetryViews.PublishOptionsDialog, TelemetryActions.resetOptions);
await this.updateExcludeObjectsTable();
this.excludeObjectTypesOptionsFlexBuilder?.removeItem(this.excludeObjectTypesOptionsTable!);
this.excludeObjectTypesOptionsFlexBuilder?.addItem(this.excludeObjectTypesOptionsTable!, { CSSStyles: { 'overflow': 'scroll', 'height': '80vh', 'padding-top': '2px' } });
// setting optionsChanged to false when reset click, if optionsChanged is true during execute, that means there is an option changed after reset
this.isResetOptionsClicked = true;
this.optionsChanged = false;