Stop using deprecated declarative table data in publish dialog (#12782)

* stop using deprecated declarative table data in publish dialog

* fix reloading values from project
This commit is contained in:
Kim Santiago
2020-10-07 13:50:46 -07:00
committed by GitHub
parent 280a9d20f9
commit acc58a0d1c

View File

@@ -80,7 +80,6 @@ export class PublishDatabaseDialog {
private initializePublishTab(): void {
this.publishTab.registerContent(async view => {
// TODO : enable using this when data source creation is enabled
this.createRadioButtons(view);
@@ -408,7 +407,7 @@ export class PublishDatabaseDialog {
const table = view.modelBuilder.declarativeTable().withProperties<azdata.DeclarativeTableProperties>({
ariaLabel: constants.sqlCmdTableLabel,
data: this.convertSqlCmdVarsToTableFormat(this.sqlCmdVars),
dataValues: this.convertSqlCmdVarsToTableFormat(this.sqlCmdVars),
columns: [
{
displayName: constants.sqlCmdVariableColumn,
@@ -431,8 +430,8 @@ export class PublishDatabaseDialog {
table.onDataChanged(() => {
this.sqlCmdVars = {};
table.data?.forEach((row) => {
(<Record<string, string>>this.sqlCmdVars)[row[0]] = row[1];
table.dataValues?.forEach((row) => {
(<Record<string, string>>this.sqlCmdVars)[<string>row[0].value] = <string>row[1].value;
});
this.tryEnableGenerateScriptAndOkButtons();
@@ -455,9 +454,10 @@ export class PublishDatabaseDialog {
loadSqlCmdVarsButton.onDidClick(async () => {
this.sqlCmdVars = { ...this.project.sqlCmdVariables };
const data = this.convertSqlCmdVarsToTableFormat(this.getSqlCmdVariablesForPublish());
await (<azdata.DeclarativeTableComponent>this.sqlCmdVariablesTable).updateProperties({
data: data
const data = this.convertSqlCmdVarsToTableFormat(this.sqlCmdVars!);
(<azdata.DeclarativeTableComponent>this.sqlCmdVariablesTable)!.updateProperties({
dataValues: data,
data: [] // data is deprecated, but the table gets updated incorrectly if this isn't set to an empty array
});
this.tryEnableGenerateScriptAndOkButtons();
@@ -586,10 +586,10 @@ export class PublishDatabaseDialog {
return loadProfileButton;
}
private convertSqlCmdVarsToTableFormat(sqlCmdVars: Record<string, string>): string[][] {
private convertSqlCmdVarsToTableFormat(sqlCmdVars: Record<string, string>): azdata.DeclarativeTableCellValue[][] {
let data = [];
for (let key in sqlCmdVars) {
data.push([key, sqlCmdVars[key]]);
data.push([{ value: key }, { value: sqlCmdVars[key] }]);
}
return data;