mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 01:25:36 -05:00
ADS: Make select all tables by default instead of having to click edit and do select all (#21698)
* table are selected as default * refactor * fix save and close bug
This commit is contained in:
@@ -48,19 +48,6 @@ export class TableMigrationSelectionDialog {
|
||||
this._model.sourceConnectionId,
|
||||
this._sourceDatabaseName);
|
||||
|
||||
this._tableSelectionMap = new Map();
|
||||
sourceTableList.forEach(table => {
|
||||
const sourceTable = targetDatabaseInfo.sourceTables.get(table.tableName);
|
||||
const isSelected = sourceTable?.selectedForMigration === true;
|
||||
const tableInfo: TableInfo = {
|
||||
databaseName: table.databaseName,
|
||||
rowCount: table.rowCount,
|
||||
selectedForMigration: isSelected,
|
||||
tableName: table.tableName,
|
||||
};
|
||||
this._tableSelectionMap.set(table.tableName, tableInfo);
|
||||
});
|
||||
|
||||
const targetTableList: TableInfo[] = await collectTargetDatabaseTableInfo(
|
||||
this._model._targetServerInstance as AzureSqlDatabaseServer,
|
||||
targetDatabaseInfo.databaseName,
|
||||
@@ -77,6 +64,28 @@ export class TableMigrationSelectionDialog {
|
||||
selectedForMigration: false,
|
||||
tableName: table.tableName,
|
||||
}));
|
||||
|
||||
this._tableSelectionMap = new Map();
|
||||
sourceTableList.forEach(table => {
|
||||
// If the source table doesn't exist in the target, set isSelected to false.
|
||||
// Otherwise, set it to true as default.
|
||||
var isSelected = false;
|
||||
var sourceTable = targetDatabaseInfo.sourceTables.get(table.tableName);
|
||||
if (sourceTable === null || sourceTable === undefined) {
|
||||
sourceTable = this._targetTableMap.get(table.tableName);
|
||||
isSelected = sourceTable === null || sourceTable === undefined ? false : true;
|
||||
} else {
|
||||
isSelected = sourceTable.selectedForMigration;
|
||||
}
|
||||
|
||||
const tableInfo: TableInfo = {
|
||||
databaseName: table.databaseName,
|
||||
rowCount: table.rowCount,
|
||||
selectedForMigration: isSelected,
|
||||
tableName: table.tableName,
|
||||
};
|
||||
this._tableSelectionMap.set(table.tableName, tableInfo);
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
this._dialog!.message = {
|
||||
@@ -97,7 +106,9 @@ export class TableMigrationSelectionDialog {
|
||||
let tableRow = 0;
|
||||
this._missingTableCount = 0;
|
||||
this._tableSelectionMap.forEach(sourceTable => {
|
||||
if (filterText?.length === 0 || sourceTable.tableName.indexOf(filterText) > -1) {
|
||||
const tableName = sourceTable.tableName.toLocaleLowerCase();
|
||||
const searchText = filterText.toLocaleLowerCase();
|
||||
if (filterText?.length === 0 || tableName.indexOf(searchText) > -1) {
|
||||
const targetTable = this._targetTableMap.get(sourceTable.tableName);
|
||||
if (targetTable) {
|
||||
const targetTableRowCount = targetTable?.rowCount ?? 0;
|
||||
@@ -113,9 +124,11 @@ export class TableMigrationSelectionDialog {
|
||||
if (sourceTable.selectedForMigration) {
|
||||
selectedItems.push(tableRow);
|
||||
}
|
||||
|
||||
tableRow++;
|
||||
}
|
||||
|
||||
this._missingTableCount += targetTable ? 0 : 1;
|
||||
tableRow++;
|
||||
}
|
||||
});
|
||||
await this._tableSelectionTable.updateProperty('data', data);
|
||||
|
||||
Reference in New Issue
Block a user