mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 17:22:42 -05:00
Toggle reset button on option change (#19975)
* Toggle reset button on option change * Reset functionliaty is revised and added edge case consideration
This commit is contained in:
committed by
GitHub
parent
e5b0e0255c
commit
425c9729ad
@@ -23,6 +23,7 @@ export class PublishOptionsDialog {
|
||||
public optionsModel: DeployOptionsModel;
|
||||
private optionsFlexBuilder: azdataType.FlexContainer | undefined;
|
||||
private optionsChanged: boolean = false;
|
||||
private isResetOptionsClicked: boolean = false;
|
||||
|
||||
constructor(defaultOptions: mssql.DeploymentOptions, private publish: PublishDatabaseDialog) {
|
||||
this.optionsModel = new DeployOptionsModel(defaultOptions);
|
||||
@@ -47,6 +48,8 @@ export class PublishOptionsDialog {
|
||||
|
||||
let resetButton = utils.getAzdataApi()!.window.createButton(constants.ResetButton);
|
||||
resetButton.onClick(async () => await this.reset());
|
||||
// If options values already modified then enable the reset button
|
||||
resetButton.enabled = this.publish.publishOptionsModified;
|
||||
this.dialog.customButtons = [resetButton];
|
||||
|
||||
utils.getAzdataApi()!.window.openDialog(this.dialog);
|
||||
@@ -91,6 +94,8 @@ export class PublishOptionsDialog {
|
||||
const displayName = this.optionsTable?.data[checkboxState.row][1];
|
||||
this.optionsModel.setOptionValue(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;
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -149,6 +154,9 @@ export class PublishOptionsDialog {
|
||||
if (this.optionsChanged) {
|
||||
TelemetryReporter.sendActionEvent(TelemetryViews.PublishOptionsDialog, TelemetryActions.optionsChanged);
|
||||
}
|
||||
// When options are Reset to default and clicked Ok, seting optionsChanged flag to false
|
||||
// When options are Reset to default and options are changed and then clicked Ok, seting optionsChanged flag to the state of the option change
|
||||
this.publish.publishOptionsModified = this.isResetOptionsClicked && !this.optionsChanged ? false : (this.optionsChanged || this.publish.publishOptionsModified);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -172,6 +180,10 @@ export class PublishOptionsDialog {
|
||||
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);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
private disposeListeners(): void {
|
||||
|
||||
Reference in New Issue
Block a user