diff --git a/extensions/mssql/package.json b/extensions/mssql/package.json index 3d8f0a5d3a..d614e9672d 100644 --- a/extensions/mssql/package.json +++ b/extensions/mssql/package.json @@ -478,17 +478,7 @@ { "displayName": "%databasesListProperties.name%", "value": "name", - "widthWeight": 60 - }, - { - "displayName": "%databasesListProperties.status%", - "value": "state", - "widthWeight": 20 - }, - { - "displayName": "%databasesListProperties.size%", - "value": "sizeInMB", - "widthWeight": 20 + "widthWeight": 100 } ] } diff --git a/src/sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerWidget.component.ts b/src/sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerWidget.component.ts index c6acf9ae9d..27e06c1d19 100644 --- a/src/sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerWidget.component.ts +++ b/src/sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerWidget.component.ts @@ -26,6 +26,8 @@ import { ILogService } from 'vs/platform/log/common/log'; import { IEditorProgressService } from 'vs/platform/progress/common/progress'; import { attachInputBoxStyler } from 'vs/platform/theme/common/styler'; import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement'; +import { DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes'; @Component({ selector: 'explorer-widget', @@ -51,6 +53,7 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget, @Inject(IMenuService) private readonly menuService: IMenuService, @Inject(IContextKeyService) private readonly contextKeyService: IContextKeyService, @Inject(IEditorProgressService) private readonly progressService: IEditorProgressService, + @Inject(IConnectionManagementService) private readonly connectionManagementService: IConnectionManagementService, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef ) { super(changeRef); @@ -95,7 +98,6 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget, this._register(subscriptionToDisposable(this._bootstrap.metadataService.metadata.subscribe( data => { if (data) { - const objectData = ObjectMetadataWrapper.createFromObjectMetadata(data.objectMetadata); objectData.sort(ObjectMetadataWrapper.sort); this.updateTable(objectData); @@ -106,34 +108,55 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget, } ))); } else { - this._register(subscriptionToDisposable(this._bootstrap.metadataService.databases.subscribe( - data => { - // Handle the case where there is no metadata service - data = data || []; - if (isStringArray(data)) { - data = data.map(item => { - const dbInfo: DatabaseInfo = { options: {} }; - dbInfo.options[NameProperty] = item; - return dbInfo; - }); + // TODO: remove this ADS side workaround for SQL On-Demand and handle it in SQL Tools Service + if (this._bootstrap.connectionManagementService.connectionInfo.serverInfo.engineEditionId === DatabaseEngineEdition.SqlOnDemand) { + this.connectionManagementService.listDatabases(this._bootstrap.connectionManagementService.connectionInfo.ownerUri).then( + result => { + // Sort the databases: system databases first and then the sorted list of other databases + const sysDatabases = ['master', 'model', 'msdb', 'tempdb']; + const databaseNames = result.databaseNames.filter(db => sysDatabases.indexOf(db) !== -1). + concat(result.databaseNames.filter(db => sysDatabases.indexOf(db) === -1).sort()); + this.handleServerContextResults(databaseNames); + }, + error => { + this.showErrorMessage(nls.localize('dashboard.explorer.databaseError', "Unable to load databases")); } - - const currentProfile = this._bootstrap.connectionManagementService.connectionInfo.connectionProfile; - this.updateTable(data.map(d => { - const item = assign({}, d.options); - const profile = currentProfile.toIConnectionProfile(); - profile.databaseName = d.options[NameProperty]; - item[ConnectionProfilePropertyName] = profile; - return item; - })); - }, - error => { - this.showErrorMessage(nls.localize('dashboard.explorer.databaseError', "Unable to load databases")); - } - ))); + ); + } + else { + this._register(subscriptionToDisposable(this._bootstrap.metadataService.databases.subscribe( + data => { + this.handleServerContextResults(data); + }, + error => { + this.showErrorMessage(nls.localize('dashboard.explorer.databaseError', "Unable to load databases")); + } + ))); + } } } + private handleServerContextResults(data: string[] | DatabaseInfo[]): void { + // Handle the case where there is no metadata service + data = data || []; + if (isStringArray(data)) { + data = data.map(item => { + const dbInfo: DatabaseInfo = { options: {} }; + dbInfo.options[NameProperty] = item; + return dbInfo; + }); + } + + const currentProfile = this._bootstrap.connectionManagementService.connectionInfo.connectionProfile; + this.updateTable(data.map(d => { + const item = assign({}, d.options); + const profile = currentProfile.toIConnectionProfile(); + profile.databaseName = d.options[NameProperty]; + item[ConnectionProfilePropertyName] = profile; + return item; + })); + } + private updateTable(data: Slick.SlickData[]) { this._table.setData(data); this.setLoadingStatus(false);