mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Providers without metadata service or serverInfo shouldn't break dashboard (#1761)
- Fix a number of issues that arose while testing a provider without a metadata service or serverInfo object returned via DMP calls. These should be optional services/features and we should be resilient to them not existing. In most places we already have these checks - This does not cover a number of "improvement" scenarios, such as filtering extension tabs by provider, and defaulting any tabs that don't specify a provider to be MSSQL. This and some other features to ensure things make sense will be implemented in separate PRs but this unblocked the scenario
This commit is contained in:
@@ -37,7 +37,7 @@ export default class ContextProvider {
|
|||||||
public onDashboardOpen(e: sqlops.DashboardDocument): void {
|
public onDashboardOpen(e: sqlops.DashboardDocument): void {
|
||||||
let iscloud: boolean;
|
let iscloud: boolean;
|
||||||
let edition: number;
|
let edition: number;
|
||||||
if (e.profile.providerName.toLowerCase() === 'mssql' && !types.isUndefinedOrNull(e.serverInfo.engineEditionId)) {
|
if (e.profile.providerName.toLowerCase() === 'mssql' && !types.isUndefinedOrNull(e.serverInfo) && !types.isUndefinedOrNull(e.serverInfo.engineEditionId)) {
|
||||||
if (isCloudEditions.some(i => i === e.serverInfo.engineEditionId)) {
|
if (isCloudEditions.some(i => i === e.serverInfo.engineEditionId)) {
|
||||||
iscloud = true;
|
iscloud = true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -136,13 +136,17 @@ export function addProvider<T extends { connectionManagementService: SingleConne
|
|||||||
*/
|
*/
|
||||||
export function addEdition<T extends { connectionManagementService: SingleConnectionManagementService }>(config: WidgetConfig[], collection: DashboardServiceInterface): Array<WidgetConfig> {
|
export function addEdition<T extends { connectionManagementService: SingleConnectionManagementService }>(config: WidgetConfig[], collection: DashboardServiceInterface): Array<WidgetConfig> {
|
||||||
let connectionInfo: ConnectionManagementInfo = collection.connectionManagementService.connectionInfo;
|
let connectionInfo: ConnectionManagementInfo = collection.connectionManagementService.connectionInfo;
|
||||||
let edition = connectionInfo.serverInfo.engineEditionId;
|
if (connectionInfo.serverInfo) {
|
||||||
return config.map((item) => {
|
let edition = connectionInfo.serverInfo.engineEditionId;
|
||||||
if (item.edition === undefined) {
|
return config.map((item) => {
|
||||||
item.edition = edition;
|
if (item.edition === undefined) {
|
||||||
}
|
item.edition = edition;
|
||||||
return item;
|
}
|
||||||
});
|
return item;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import { IContextViewService, IContextMenuService } from 'vs/platform/contextvie
|
|||||||
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { IProgressService } from 'vs/platform/progress/common/progress';
|
import { IProgressService } from 'vs/platform/progress/common/progress';
|
||||||
|
import * as types from 'vs/base/common/types';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'explorer-widget',
|
selector: 'explorer-widget',
|
||||||
@@ -120,6 +121,8 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget,
|
|||||||
let currentProfile = this._bootstrap.connectionManagementService.connectionInfo.connectionProfile;
|
let currentProfile = this._bootstrap.connectionManagementService.connectionInfo.connectionProfile;
|
||||||
this._register(toDisposableSubscription(this._bootstrap.metadataService.databaseNames.subscribe(
|
this._register(toDisposableSubscription(this._bootstrap.metadataService.databaseNames.subscribe(
|
||||||
data => {
|
data => {
|
||||||
|
// Handle the case where there is no metadata service
|
||||||
|
data = data || [];
|
||||||
let profileData = data.map(d => {
|
let profileData = data.map(d => {
|
||||||
let profile = new ConnectionProfile(this.capabilitiesService, currentProfile);
|
let profile = new ConnectionProfile(this.capabilitiesService, currentProfile);
|
||||||
profile.databaseName = d;
|
profile.databaseName = d;
|
||||||
|
|||||||
@@ -166,7 +166,6 @@ export class TasksWidget extends DashboardWidget implements IDashboardWidget, On
|
|||||||
}
|
}
|
||||||
|
|
||||||
public runTask(task: ICommandAction) {
|
public runTask(task: ICommandAction) {
|
||||||
let serverInfo = this._bootstrap.connectionManagementService.connectionInfo.serverInfo;
|
|
||||||
this.commandService.executeCommand(task.id, this._profile);
|
this.commandService.executeCommand(task.id, this._profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export class MetadataService implements IMetadataService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve(undefined);
|
return Promise.resolve([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTableInfo(connectionUri: string, metadata: sqlops.ObjectMetadata): Thenable<sqlops.ColumnMetadata[]> {
|
public getTableInfo(connectionUri: string, metadata: sqlops.ObjectMetadata): Thenable<sqlops.ColumnMetadata[]> {
|
||||||
|
|||||||
Reference in New Issue
Block a user