From 4d1be1e2882e9bead453bed88c340930e5055701 Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Tue, 2 Aug 2022 13:39:20 -0700 Subject: [PATCH] fix menu item not showing up for non-English languages (#20224) * new object type property * vbump sts * fix azure tree * mark as optional * Fix test errors --- extensions/mssql/config.json | 2 +- extensions/mssql/package.json | 4 +-- src/sql/azdata.proposed.d.ts | 8 +++++ .../browser/connectionTreeActions.test.ts | 34 +++++++++++-------- .../test/browser/scriptingActions.test.ts | 3 +- .../browser/mssqlNodeContext.ts | 4 +++ .../browser/objectExplorerService.ts | 3 +- .../browser/objectExplorerViewTreeShim.ts | 3 +- .../browser/serverTreeActionProvider.ts | 2 +- .../objectExplorer/common/treeNode.ts | 8 ++++- .../common/treeNodeContextKey.ts | 5 +++ .../asyncServerTreeDragAndDrop.test.ts | 2 +- .../browser/dragAndDropController.test.ts | 2 +- .../browser/objectExplorerService.test.ts | 30 +++++++++------- 14 files changed, 72 insertions(+), 38 deletions(-) diff --git a/extensions/mssql/config.json b/extensions/mssql/config.json index b0db53416c..161e2cd237 100644 --- a/extensions/mssql/config.json +++ b/extensions/mssql/config.json @@ -1,6 +1,6 @@ { "downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/{#version#}/microsoft.sqltools.servicelayer-{#fileName#}", - "version": "4.2.0.5", + "version": "4.2.0.8", "downloadFileNames": { "Windows_86": "win-x86-net6.0.zip", "Windows_64": "win-x64-net6.0.zip", diff --git a/extensions/mssql/package.json b/extensions/mssql/package.json index ce695dd498..61d1866ca4 100644 --- a/extensions/mssql/package.json +++ b/extensions/mssql/package.json @@ -511,7 +511,7 @@ }, { "command": "mssql.newTable", - "when": "connectionProvider == MSSQL && nodeType == Folder && nodeLabel == Tables && config.workbench.enablePreviewFeatures", + "when": "connectionProvider == MSSQL && nodeType == Folder && objectType == Tables && config.workbench.enablePreviewFeatures", "group": "0_query@1" } ], @@ -523,7 +523,7 @@ }, { "command": "mssql.newTable", - "when": "connectionProvider == MSSQL && nodeType == Folder && nodeLabel == Tables && config.workbench.enablePreviewFeatures", + "when": "connectionProvider == MSSQL && nodeType == Folder && objectType == Tables && config.workbench.enablePreviewFeatures", "group": "connection@1" } ], diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index 8f182df555..f4af490c08 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -1606,4 +1606,12 @@ declare module 'azdata' { onQueryEvent(type: QueryEventType, document: QueryDocument, args: ResultSetSummary | string | undefined, queryInfo: QueryInfo): void; } } + + export interface NodeInfo { + /** + * The object type of the node. Node type is used to determine the icon, the object type is the actual type of the node, e.g. for Tables node + * under the database, the nodeType is Folder, the objectType is be Tables. + */ + objectType?: string; + } } diff --git a/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts b/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts index ecee983728..302d4cc49f 100644 --- a/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts +++ b/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts @@ -80,8 +80,8 @@ suite('SQL Connection Tree Action tests', () => { let objectExplorerService = TypeMoq.Mock.ofType(ObjectExplorerService, TypeMoq.MockBehavior.Strict, connectionManagementService); objectExplorerService.callBase = true; objectExplorerService.setup(x => x.getTreeNode(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(getTreeNodeReturnVal)); - objectExplorerService.setup(x => x.getObjectExplorerNode(TypeMoq.It.isAny())).returns(() => new TreeNode('', '', false, '', '', '', undefined, undefined, undefined, undefined)); - objectExplorerService.setup(x => x.getObjectExplorerNode(undefined)).returns(() => new TreeNode('', '', false, '', '', '', undefined, undefined, undefined, undefined)); + objectExplorerService.setup(x => x.getObjectExplorerNode(TypeMoq.It.isAny())).returns(() => new TreeNode('', '', '', false, '', '', '', undefined, undefined, undefined, undefined)); + objectExplorerService.setup(x => x.getObjectExplorerNode(undefined)).returns(() => new TreeNode('', '', '', false, '', '', '', undefined, undefined, undefined, undefined)); objectExplorerService.setup(x => x.onUpdateObjectExplorerNodes).returns(() => new Emitter().event); objectExplorerService.setup(x => x.onUpdateObjectExplorerNodes).returns(() => new Emitter().event); @@ -192,7 +192,7 @@ suite('SQL Connection Tree Action tests', () => { saveProfile: true, id: 'testId' }); - let treeNode = new TreeNode(NodeType.Database, 'db node', false, '', '', '', undefined, undefined, undefined, undefined); + let treeNode = new TreeNode(NodeType.Database, '', 'db node', false, '', '', '', undefined, undefined, undefined, undefined); treeNode.connection = connection; let connectionManagementService = createConnectionManagementService(isConnectedReturnValue, connection); let objectExplorerService = createObjectExplorerService(connectionManagementService.object, treeNode); @@ -409,6 +409,7 @@ suite('SQL Connection Tree Action tests', () => { rootNode: { nodePath: 'testServerName\tables', nodeType: NodeType.Folder, + objectType: '', label: 'Tables', isLeaf: false, metadata: null, @@ -419,11 +420,11 @@ suite('SQL Connection Tree Action tests', () => { errorMessage: '' }; - let tablesNode = new TreeNode(NodeType.Folder, 'Tables', false, 'testServerName\Db1\tables', '', '', null, null, undefined, undefined); + let tablesNode = new TreeNode(NodeType.Folder, '', 'Tables', false, 'testServerName\Db1\tables', '', '', null, null, undefined, undefined); tablesNode.connection = connection; tablesNode.session = objectExplorerSession; - let table1Node = new TreeNode(NodeType.Table, 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); - let table2Node = new TreeNode(NodeType.Table, 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); + let table1Node = new TreeNode(NodeType.Table, '', 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); + let table2Node = new TreeNode(NodeType.Table, '', 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); tablesNode.children = [table1Node, table2Node]; let objectExplorerService = TypeMoq.Mock.ofType(ObjectExplorerService, TypeMoq.MockBehavior.Loose, connectionManagementService.object); objectExplorerService.callBase = true; @@ -495,6 +496,7 @@ suite('SQL Connection Tree Action tests', () => { rootNode: { nodePath: 'testServerName\tables', nodeType: NodeType.Folder, + objectType: '', label: 'Tables', isLeaf: false, metadata: null, @@ -505,11 +507,11 @@ suite('SQL Connection Tree Action tests', () => { errorMessage: '' }; - let tablesNode = new TreeNode(NodeType.Folder, 'Tables', false, 'testServerName\Db1\tables', '', '', null, null, undefined, undefined); + let tablesNode = new TreeNode(NodeType.Folder, '', 'Tables', false, 'testServerName\Db1\tables', '', '', null, null, undefined, undefined); tablesNode.connection = connection; tablesNode.session = objectExplorerSession; - let table1Node = new TreeNode(NodeType.Table, 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); - let table2Node = new TreeNode(NodeType.Table, 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); + let table1Node = new TreeNode(NodeType.Table, '', 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); + let table2Node = new TreeNode(NodeType.Table, '', 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); tablesNode.children = [table1Node, table2Node]; let objectExplorerService = TypeMoq.Mock.ofType(ObjectExplorerService, TypeMoq.MockBehavior.Loose, connectionManagementService.object); objectExplorerService.callBase = true; @@ -582,6 +584,7 @@ suite('SQL Connection Tree Action tests', () => { rootNode: { nodePath: 'testServerName\tables', nodeType: NodeType.Folder, + objectType: '', label: 'Tables', isLeaf: false, metadata: null, @@ -592,11 +595,11 @@ suite('SQL Connection Tree Action tests', () => { errorMessage: '' }; - let tablesNode = new TreeNode(NodeType.Folder, 'Tables', false, 'testServerName\Db1\tables', '', '', null, null, undefined, undefined); + let tablesNode = new TreeNode(NodeType.Folder, '', 'Tables', false, 'testServerName\Db1\tables', '', '', null, null, undefined, undefined); tablesNode.connection = connection; tablesNode.session = objectExplorerSession; - let table1Node = new TreeNode(NodeType.Table, 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); - let table2Node = new TreeNode(NodeType.Table, 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); + let table1Node = new TreeNode(NodeType.Table, '', 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); + let table2Node = new TreeNode(NodeType.Table, '', 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); tablesNode.children = [table1Node, table2Node]; let objectExplorerService = TypeMoq.Mock.ofType(ObjectExplorerService, TypeMoq.MockBehavior.Loose, connectionManagementService.object); objectExplorerService.callBase = true; @@ -678,6 +681,7 @@ suite('SQL Connection Tree Action tests', () => { rootNode: { nodePath: 'testServerName\tables', nodeType: NodeType.Folder, + objectType: '', label: 'Tables', isLeaf: false, metadata: null, @@ -688,11 +692,11 @@ suite('SQL Connection Tree Action tests', () => { errorMessage: '' }; - let tablesNode = new TreeNode(NodeType.Folder, 'Tables', false, 'testServerName\Db1\tables', '', '', null, null, undefined, undefined); + let tablesNode = new TreeNode(NodeType.Folder, '', 'Tables', false, 'testServerName\Db1\tables', '', '', null, null, undefined, undefined); tablesNode.connection = connection; tablesNode.session = objectExplorerSession; - let table1Node = new TreeNode(NodeType.Table, 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); - let table2Node = new TreeNode(NodeType.Table, 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); + let table1Node = new TreeNode(NodeType.Table, '', 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); + let table2Node = new TreeNode(NodeType.Table, '', 'dbo.Table1', false, 'testServerName\tables\dbo.Table1', '', '', tablesNode, null, undefined, undefined); tablesNode.children = [table1Node, table2Node]; let objectExplorerService = TypeMoq.Mock.ofType(ObjectExplorerService, TypeMoq.MockBehavior.Loose, connectionManagementService.object); objectExplorerService.callBase = true; diff --git a/src/sql/workbench/contrib/scripting/test/browser/scriptingActions.test.ts b/src/sql/workbench/contrib/scripting/test/browser/scriptingActions.test.ts index 1f91d11340..d81500f042 100644 --- a/src/sql/workbench/contrib/scripting/test/browser/scriptingActions.test.ts +++ b/src/sql/workbench/contrib/scripting/test/browser/scriptingActions.test.ts @@ -42,6 +42,7 @@ const connection: azdata.IConnectionProfile = { const nodeInfo: azdata.NodeInfo = { nodePath: 'MyServer', + objectType: '', nodeStatus: '', nodeSubType: '', nodeType: 'Server', @@ -51,7 +52,7 @@ const nodeInfo: azdata.NodeInfo = { errorMessage: '' }; -const treeNode = new TreeNode(NodeType.Database, 'db node', false, '', '', '', undefined, undefined, undefined, undefined); +const treeNode = new TreeNode(NodeType.Database, '', 'db node', false, '', '', '', undefined, undefined, undefined, undefined); const oeActionArgs: ObjectExplorerActionsContext = { connectionProfile: connection, isConnectionNode: false, nodeInfo: nodeInfo }; let instantiationService: IInstantiationService; diff --git a/src/sql/workbench/services/objectExplorer/browser/mssqlNodeContext.ts b/src/sql/workbench/services/objectExplorer/browser/mssqlNodeContext.ts index 5d540f8f8c..eed0d8077e 100644 --- a/src/sql/workbench/services/objectExplorer/browser/mssqlNodeContext.ts +++ b/src/sql/workbench/services/objectExplorer/browser/mssqlNodeContext.ts @@ -38,6 +38,7 @@ export class MssqlNodeContext extends Disposable { static IsWindows = new RawContextKey('isWindows', isWindows); static IsCloud = new RawContextKey('isCloud', false); static NodeType = new RawContextKey('nodeType', undefined); + static ObjectType = new RawContextKey('objectType', undefined); static NodeLabel = new RawContextKey('nodeLabel', undefined); static EngineEdition = new RawContextKey('engineEdition', DatabaseEngineEdition.Unknown); static CanOpenInAzurePortal = new RawContextKey('canOpenInAzurePortal', false); @@ -53,6 +54,7 @@ export class MssqlNodeContext extends Disposable { private nodeProviderKey!: IContextKey; private isCloudKey!: IContextKey; private nodeTypeKey!: IContextKey; + private objectTypeKey!: IContextKey; private nodeLabelKey!: IContextKey; private isDatabaseOrServerKey!: IContextKey; private engineEditionKey!: IContextKey; @@ -96,6 +98,7 @@ export class MssqlNodeContext extends Disposable { if (node.label) { this.nodeLabelKey.set(node.label.label); } + this.objectTypeKey.set(node.nodeInfo?.objectType); } } @@ -103,6 +106,7 @@ export class MssqlNodeContext extends Disposable { this.isCloudKey = MssqlNodeContext.IsCloud.bindTo(this.contextKeyService); this.engineEditionKey = MssqlNodeContext.EngineEdition.bindTo(this.contextKeyService); this.nodeTypeKey = MssqlNodeContext.NodeType.bindTo(this.contextKeyService); + this.objectTypeKey = MssqlNodeContext.ObjectType.bindTo(this.contextKeyService); this.nodeLabelKey = MssqlNodeContext.NodeLabel.bindTo(this.contextKeyService); this.isDatabaseOrServerKey = MssqlNodeContext.IsDatabaseOrServer.bindTo(this.contextKeyService); this.canScriptAsSelectKey = MssqlNodeContext.CanScriptAsSelect.bindTo(this.contextKeyService); diff --git a/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts b/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts index aac679ee67..3898b0eb6b 100644 --- a/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts +++ b/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts @@ -469,6 +469,7 @@ export class ObjectExplorerService implements IObjectExplorerService { let allNodes: azdata.NodeInfo[] = []; let errorNode: azdata.NodeInfo = { nodePath: nodePath, + objectType: 'error', label: 'Error', errorMessage: '', nodeType: 'error', @@ -625,7 +626,7 @@ export class ObjectExplorerService implements IObjectExplorerService { } } - let node = new TreeNode(nodeInfo.nodeType, nodeInfo.label, isLeaf, nodeInfo.nodePath, + let node = new TreeNode(nodeInfo.nodeType, nodeInfo.objectType, nodeInfo.label, isLeaf, nodeInfo.nodePath, nodeInfo.nodeSubType!, nodeInfo.nodeStatus, parent, nodeInfo.metadata, nodeInfo.iconType, nodeInfo.icon, { getChildren: (treeNode?: TreeNode) => this.getChildren(treeNode), isExpanded: treeNode => this.isExpanded(treeNode), diff --git a/src/sql/workbench/services/objectExplorer/browser/objectExplorerViewTreeShim.ts b/src/sql/workbench/services/objectExplorer/browser/objectExplorerViewTreeShim.ts index 461d763d0b..a8a43e09f1 100644 --- a/src/sql/workbench/services/objectExplorer/browser/objectExplorerViewTreeShim.ts +++ b/src/sql/workbench/services/objectExplorer/browser/objectExplorerViewTreeShim.ts @@ -142,7 +142,7 @@ export class OEShimService extends Disposable implements IOEShimService { const sessionId = await this.getOrCreateSession(viewId, node); const requestHandle = this.nodeHandleMap.get(generateNodeMapKey(viewId, node)) || node.handle; - const treeNode = new TreeNode(undefined!, undefined!, undefined!, requestHandle, undefined!); // hack since this entire system is a hack anyways + const treeNode = new TreeNode(undefined!, undefined!, undefined!, undefined!, requestHandle, undefined!); // hack since this entire system is a hack anyways treeNode.connection = new ConnectionProfile(this.capabilities, node.payload); const childrenNodes = await this.oe.refreshTreeNode({ success: true, @@ -186,6 +186,7 @@ export class OEShimService extends Disposable implements IOEShimService { const nodeInfo: azdata.NodeInfo = { nodePath: nodePath, nodeType: node.nodeTypeId, + objectType: node.objectType, nodeSubType: node.nodeSubType, nodeStatus: node.nodeStatus, label: node.label, diff --git a/src/sql/workbench/services/objectExplorer/browser/serverTreeActionProvider.ts b/src/sql/workbench/services/objectExplorer/browser/serverTreeActionProvider.ts index 223cf01fc4..f70c74718d 100644 --- a/src/sql/workbench/services/objectExplorer/browser/serverTreeActionProvider.ts +++ b/src/sql/workbench/services/objectExplorer/browser/serverTreeActionProvider.ts @@ -69,7 +69,7 @@ export class ServerTreeActionProvider { * Return actions for connection elements */ private getConnectionActions(tree: AsyncServerTree | ITree, profile: ConnectionProfile): IAction[] { - let node = new TreeNode(NodeType.Server, '', false, '', '', '', undefined, undefined, undefined, undefined); + let node = new TreeNode(NodeType.Server, NodeType.Server, '', false, '', '', '', undefined, undefined, undefined, undefined); node.connection = profile; return this.getAllActions({ tree: tree, diff --git a/src/sql/workbench/services/objectExplorer/common/treeNode.ts b/src/sql/workbench/services/objectExplorer/common/treeNode.ts index b88206724b..abc86e8452 100644 --- a/src/sql/workbench/services/objectExplorer/common/treeNode.ts +++ b/src/sql/workbench/services/objectExplorer/common/treeNode.ts @@ -42,6 +42,11 @@ export class TreeNode { */ public nodeTypeId: string; + /** + * The object type. + */ + public objectType: string; + /** * Label to display to the user, describing this node */ @@ -94,12 +99,13 @@ export class TreeNode { public icon?: IconPath | SqlThemeIcon; - constructor(nodeTypeId: string, label: string, isAlwaysLeaf: boolean, nodePath: string, + constructor(nodeTypeId: string, objectType: string, label: string, isAlwaysLeaf: boolean, nodePath: string, nodeSubType: string, nodeStatus?: string, parent?: TreeNode, metadata?: azdata.ObjectMetadata, iconType?: string | SqlThemeIcon, icon?: IconPath | SqlThemeIcon, private _objectExplorerCallbacks?: ObjectExplorerCallbacks) { this.nodeTypeId = nodeTypeId; + this.objectType = objectType; this.label = label; this.isAlwaysLeaf = isAlwaysLeaf; this.nodePath = nodePath; diff --git a/src/sql/workbench/services/objectExplorer/common/treeNodeContextKey.ts b/src/sql/workbench/services/objectExplorer/common/treeNodeContextKey.ts index 28683758d3..8a15b0b970 100644 --- a/src/sql/workbench/services/objectExplorer/common/treeNodeContextKey.ts +++ b/src/sql/workbench/services/objectExplorer/common/treeNodeContextKey.ts @@ -10,6 +10,7 @@ import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilit export class TreeNodeContextKey implements IContextKey { static NodeType = new RawContextKey('nodeType', undefined); + static ObjectType = new RawContextKey('objectType', undefined); static SubType = new RawContextKey('nodeSubType', undefined); static Status = new RawContextKey('nodeStatus', undefined); static TreeNode = new RawContextKey('treeNode', undefined); @@ -18,6 +19,7 @@ export class TreeNodeContextKey implements IContextKey { static IsQueryProvider = new RawContextKey('isQueryProvider', false); private _nodeTypeKey: IContextKey; + private _objectTypeKey: IContextKey; private _subTypeKey: IContextKey; private _statusKey: IContextKey; private _treeNodeKey: IContextKey; @@ -30,6 +32,7 @@ export class TreeNodeContextKey implements IContextKey { @ICapabilitiesService private _capabilitiesService: ICapabilitiesService ) { this._nodeTypeKey = TreeNodeContextKey.NodeType.bindTo(contextKeyService); + this._objectTypeKey = TreeNodeContextKey.ObjectType.bindTo(contextKeyService); this._subTypeKey = TreeNodeContextKey.SubType.bindTo(contextKeyService); this._statusKey = TreeNodeContextKey.Status.bindTo(contextKeyService); this._treeNodeKey = TreeNodeContextKey.TreeNode.bindTo(contextKeyService); @@ -41,6 +44,7 @@ export class TreeNodeContextKey implements IContextKey { set(value: TreeNode) { this._treeNodeKey.set(value); this._nodeTypeKey.set(value && value.nodeTypeId); + this._objectTypeKey.set(value && value.objectType); this._subTypeKey.set(value && value.nodeSubType); if (value.nodeStatus) { this._statusKey.set(value && value.nodeStatus); @@ -54,6 +58,7 @@ export class TreeNodeContextKey implements IContextKey { reset(): void { this._nodeTypeKey.reset(); + this._objectTypeKey.reset(); this._subTypeKey.reset(); this._statusKey.reset(); this._treeNodeKey.reset(); diff --git a/src/sql/workbench/services/objectExplorer/test/browser/asyncServerTreeDragAndDrop.test.ts b/src/sql/workbench/services/objectExplorer/test/browser/asyncServerTreeDragAndDrop.test.ts index 70f6a4bd01..dd36db9005 100644 --- a/src/sql/workbench/services/objectExplorer/test/browser/asyncServerTreeDragAndDrop.test.ts +++ b/src/sql/workbench/services/objectExplorer/test/browser/asyncServerTreeDragAndDrop.test.ts @@ -47,7 +47,7 @@ suite('AsyncServerTreeDragAndDrop', () => { let connectionProfileArray = [connectionProfile]; let connectionProfileGroupId = new ConnectionProfileGroup('name', undefined, 'd936bb32-422b-49c3-963f-ae9532d63dc5', 'color', 'description'); let connectionProfileGroupArray = [connectionProfileGroupId]; - let treeNode = new TreeNode('Column', 'label', undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined); + let treeNode = new TreeNode('Column', '', 'label', undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined); let treeNodeArray = [treeNode]; setup(() => { diff --git a/src/sql/workbench/services/objectExplorer/test/browser/dragAndDropController.test.ts b/src/sql/workbench/services/objectExplorer/test/browser/dragAndDropController.test.ts index a81d9626a6..17bd29a7b3 100644 --- a/src/sql/workbench/services/objectExplorer/test/browser/dragAndDropController.test.ts +++ b/src/sql/workbench/services/objectExplorer/test/browser/dragAndDropController.test.ts @@ -72,7 +72,7 @@ suite('SQL Drag And Drop Controller tests', () => { let connectionProfileGroupId = new ConnectionProfileGroup('name', undefined, 'd936bb32-422b-49c3-963f-ae9532d63dc5', 'color', 'description'); connectionProfileGroupId.addConnections([connectionProfileId_pgsql]); let connectionProfileGroupArray = [connectionProfileGroupId]; - let treeNode = new TreeNode('Column', 'label', undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined); + let treeNode = new TreeNode('Column', '', 'label', undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined); let treeNodeArray = [treeNode]; setup(() => { diff --git a/src/sql/workbench/services/objectExplorer/test/browser/objectExplorerService.test.ts b/src/sql/workbench/services/objectExplorer/test/browser/objectExplorerService.test.ts index 1edf37d0aa..a3d97ee81e 100644 --- a/src/sql/workbench/services/objectExplorer/test/browser/objectExplorerService.test.ts +++ b/src/sql/workbench/services/objectExplorer/test/browser/objectExplorerService.test.ts @@ -43,6 +43,7 @@ suite('SQL Object Explorer Service tests', () => { const NodeInfoTable1 = { nodePath: 'testServerName/tables/dbo.Table1', nodeType: NodeType.Table, + objectType: '', label: 'dbo.Table1', isLeaf: false, metadata: null, @@ -53,6 +54,7 @@ suite('SQL Object Explorer Service tests', () => { const NodeInfoTable2 = { nodePath: 'testServerName/tables/dbo.Table2', nodeType: NodeType.Table, + objectType: '', label: 'dbo.Table2', isLeaf: false, metadata: null, @@ -64,6 +66,7 @@ suite('SQL Object Explorer Service tests', () => { const NodeInfoTable3 = { nodePath: 'testServerName/tables/dbo.Table3', nodeType: NodeType.Table, + objectType: '', label: 'dbo.Table3', isLeaf: false, metadata: null, @@ -78,6 +81,7 @@ suite('SQL Object Explorer Service tests', () => { rootNode: { nodePath: 'testServerName/tables', nodeType: NodeType.Folder, + objectType: '', label: 'Tables', isLeaf: false, metadata: null, @@ -325,7 +329,7 @@ suite('SQL Object Explorer Service tests', () => { }); test('expand node should expand node correctly', async () => { - const tablesNode = new TreeNode(NodeType.Folder, 'Tables', false, 'testServerName/tables', '', '', null, null, undefined, undefined); + const tablesNode = new TreeNode(NodeType.Folder, '', 'Tables', false, 'testServerName/tables', '', '', null, null, undefined, undefined); await objectExplorerService.createNewSession(mssqlProviderName, connection); objectExplorerService.onSessionCreated(1, objectExplorerSession); const expandInfo = await objectExplorerService.expandNode(mssqlProviderName, objectExplorerSession, tablesNode); @@ -338,7 +342,7 @@ suite('SQL Object Explorer Service tests', () => { }); test('refresh node should refresh node correctly', async () => { - const tablesNode = new TreeNode(NodeType.Folder, 'Tables', false, 'testServerName/tables', '', '', null, null, undefined, undefined); + const tablesNode = new TreeNode(NodeType.Folder, '', 'Tables', false, 'testServerName/tables', '', '', null, null, undefined, undefined); await objectExplorerService.createNewSession(mssqlProviderName, connection); objectExplorerService.onSessionCreated(1, objectExplorerSession); const expandInfo = await objectExplorerService.refreshNode(mssqlProviderName, objectExplorerSession, tablesNode); @@ -351,7 +355,7 @@ suite('SQL Object Explorer Service tests', () => { }); test('expand tree node should get correct children', async () => { - const tablesNode = new TreeNode(NodeType.Folder, 'Tables', false, 'testServerName/tables', '', '', null, null, undefined, undefined); + const tablesNode = new TreeNode(NodeType.Folder, '', 'Tables', false, 'testServerName/tables', '', '', null, null, undefined, undefined); tablesNode.connection = connection; await objectExplorerService.createNewSession(mssqlProviderName, connection); objectExplorerService.onSessionCreated(1, objectExplorerSession); @@ -366,7 +370,7 @@ suite('SQL Object Explorer Service tests', () => { }); test('refresh tree node should children correctly', async () => { - const tablesNode = new TreeNode(NodeType.Folder, 'Tables', false, 'testServerName/tables', '', '', null, null, undefined, undefined); + const tablesNode = new TreeNode(NodeType.Folder, '', 'Tables', false, 'testServerName/tables', '', '', null, null, undefined, undefined); tablesNode.connection = connection; await objectExplorerService.createNewSession(mssqlProviderName, connection); objectExplorerService.onSessionCreated(1, objectExplorerSession); @@ -413,13 +417,13 @@ suite('SQL Object Explorer Service tests', () => { parentName: undefined, parentTypeName: undefined }; - const databaseNode = new TreeNode(NodeType.Database, 'Db1', false, 'testServerName\\Db1', '', '', undefined, databaseMetaData, undefined, undefined); + const databaseNode = new TreeNode(NodeType.Database, '', 'Db1', false, 'testServerName\\Db1', '', '', undefined, databaseMetaData, undefined, undefined); databaseNode.connection = connection; databaseNode.session = objectExplorerSession; - const tablesNode = new TreeNode(NodeType.Folder, 'Tables', false, 'testServerName\\Db1\\tables', '', '', databaseNode, undefined, undefined, undefined); + const tablesNode = new TreeNode(NodeType.Folder, '', 'Tables', false, 'testServerName\\Db1\\tables', '', '', databaseNode, undefined, undefined, undefined); databaseNode.children = [tablesNode]; - const table1Node = new TreeNode(NodeType.Table, 'dbo.Table1', false, 'testServerName\\Db1\\tables\\dbo.Table1', '', '', tablesNode, undefined, undefined, undefined); - const table2Node = new TreeNode(NodeType.Table, 'dbo.Table2', false, 'testServerName\\Db1\\tables\\dbo.Table2', '', '', tablesNode, undefined, undefined, undefined); + const table1Node = new TreeNode(NodeType.Table, '', 'dbo.Table1', false, 'testServerName\\Db1\\tables\\dbo.Table1', '', '', tablesNode, undefined, undefined, undefined); + const table2Node = new TreeNode(NodeType.Table, '', 'dbo.Table2', false, 'testServerName\\Db1\\tables\\dbo.Table2', '', '', tablesNode, undefined, undefined, undefined); tablesNode.children = [table1Node, table2Node]; assert.strictEqual(table1Node.getSession(), objectExplorerSession); assert.strictEqual(table1Node.getConnectionProfile(), connection); @@ -438,7 +442,7 @@ suite('SQL Object Explorer Service tests', () => { test('getSelectedProfileAndDatabase returns the profile but no database if children of a server are selected', () => { const serverTreeView = TypeMoq.Mock.ofInstance({ getSelection: () => undefined, onSelectionOrFocusChange: Event.None } as IServerTreeView); - const databaseNode = new TreeNode(NodeType.Folder, 'Folder1', false, 'testServerName\\Folder1', '', '', undefined, undefined, undefined, undefined); + const databaseNode = new TreeNode(NodeType.Folder, '', 'Folder1', false, 'testServerName\\Folder1', '', '', undefined, undefined, undefined, undefined); databaseNode.connection = connection; serverTreeView.setup(x => x.getSelection()).returns(() => [databaseNode]); objectExplorerService.registerServerTreeView(serverTreeView.object); @@ -460,8 +464,8 @@ suite('SQL Object Explorer Service tests', () => { parentTypeName: undefined }; const databaseName = 'Db1'; - const databaseNode = new TreeNode(NodeType.Database, databaseName, false, 'testServerName\\Db1', '', '', undefined, databaseMetadata, undefined, undefined); - const tablesNode = new TreeNode(NodeType.Folder, 'Tables', false, 'testServerName\\Db1\\tables', '', '', databaseNode, undefined, undefined, undefined); + const databaseNode = new TreeNode(NodeType.Database, '', databaseName, false, 'testServerName\\Db1', '', '', undefined, databaseMetadata, undefined, undefined); + const tablesNode = new TreeNode(NodeType.Folder, '', 'Tables', false, 'testServerName\\Db1\\tables', '', '', databaseNode, undefined, undefined, undefined); databaseNode.connection = connection; databaseNode.children = [tablesNode]; serverTreeView.setup(x => x.getSelection()).returns(() => [tablesNode]); @@ -653,7 +657,7 @@ suite('SQL Object Explorer Service tests', () => { sqlOEProvider.setup(x => x.expandNode(TypeMoq.It.is(x => x.nodePath === nodePath))).callback(() => { }).returns(() => Promise.resolve(true)); // If I queue a second expand request (the first compconstes normally because of the original mock) and then close the session - const rootNode = new TreeNode(NodeType.Root, '', false, objectExplorerSession.rootNode.nodePath, '', '', null, null, undefined, undefined); + const rootNode = new TreeNode(NodeType.Root, '', '', false, objectExplorerSession.rootNode.nodePath, '', '', null, null, undefined, undefined); await objectExplorerService.expandNode(mssqlProviderName, objectExplorerSession, rootNode); const expandPromise = objectExplorerService.expandNode(mssqlProviderName, objectExplorerSession, rootNode); const closeSessionResult = await objectExplorerService.closeSession(mssqlProviderName, objectExplorerSession); @@ -670,7 +674,7 @@ suite('SQL Object Explorer Service tests', () => { // If I call resolveTreeNodeChildren once, set an error on the node, and then call it again const tablesNodePath = 'testServerName/tables'; - const tablesNode = new TreeNode(NodeType.Folder, 'Tables', false, tablesNodePath, '', '', null, null, undefined, undefined); + const tablesNode = new TreeNode(NodeType.Folder, '', 'Tables', false, tablesNodePath, '', '', null, null, undefined, undefined); tablesNode.connection = connection; await objectExplorerService.resolveTreeNodeChildren(objectExplorerSession, tablesNode); sqlOEProvider.verify(x => x.refreshNode(TypeMoq.It.is(x => x.nodePath === tablesNodePath)), TypeMoq.Times.never());