mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
drag n drop bounding characters (pgsql fix) (#14376)
* specifies object handling for all current providers * implements the same for column dragndrop * adjusted test * adds pgsql provider name constant
This commit is contained in:
committed by
GitHub
parent
1d60287795
commit
733c3628a1
@@ -11,6 +11,7 @@ export const outputChannelName = 'MSSQL';
|
|||||||
export const capabilitiesOptions = 'OPTIONS_METADATA';
|
export const capabilitiesOptions = 'OPTIONS_METADATA';
|
||||||
|
|
||||||
export const mssqlProviderName = 'MSSQL';
|
export const mssqlProviderName = 'MSSQL';
|
||||||
|
export const pgsqlProviderName = 'PGSQL';
|
||||||
export const anyProviderName = '*';
|
export const anyProviderName = '*';
|
||||||
export const connectionProviderContextKey = 'connectionProvider';
|
export const connectionProviderContextKey = 'connectionProvider';
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { IConnectionManagementService } from 'sql/platform/connection/common/con
|
|||||||
import { ITree, IDragAndDrop, IDragOverReaction, DRAG_OVER_ACCEPT_BUBBLE_DOWN, DRAG_OVER_REJECT } from 'vs/base/parts/tree/browser/tree';
|
import { ITree, IDragAndDrop, IDragOverReaction, DRAG_OVER_ACCEPT_BUBBLE_DOWN, DRAG_OVER_REJECT } from 'vs/base/parts/tree/browser/tree';
|
||||||
import { DragMouseEvent } from 'vs/base/browser/mouseEvent';
|
import { DragMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||||
import { TreeUpdateUtils } from 'sql/workbench/services/objectExplorer/browser/treeUpdateUtils';
|
import { TreeUpdateUtils } from 'sql/workbench/services/objectExplorer/browser/treeUpdateUtils';
|
||||||
import { UNSAVED_GROUP_ID } from 'sql/platform/connection/common/constants';
|
import { UNSAVED_GROUP_ID, mssqlProviderName, pgsqlProviderName } from 'sql/platform/connection/common/constants';
|
||||||
import { DataTransfers, IDragAndDropData } from 'vs/base/browser/dnd';
|
import { DataTransfers, IDragAndDropData } from 'vs/base/browser/dnd';
|
||||||
import { TreeNode } from 'sql/workbench/services/objectExplorer/common/treeNode';
|
import { TreeNode } from 'sql/workbench/services/objectExplorer/common/treeNode';
|
||||||
import { AsyncServerTree } from 'sql/workbench/services/objectExplorer/browser/asyncServerTree';
|
import { AsyncServerTree } from 'sql/workbench/services/objectExplorer/browser/asyncServerTree';
|
||||||
@@ -102,18 +102,29 @@ export class ServerTreeDragAndDrop implements IDragAndDrop {
|
|||||||
let providerName = this.getProviderNameFromElement(element);
|
let providerName = this.getProviderNameFromElement(element);
|
||||||
if (providerName === 'KUSTO') {
|
if (providerName === 'KUSTO') {
|
||||||
finalString = element.nodeTypeId !== 'Function' && escapedName.indexOf(' ') > 0 ? `[@"${escapedName}"]` : escapedName;
|
finalString = element.nodeTypeId !== 'Function' && escapedName.indexOf(' ') > 0 ? `[@"${escapedName}"]` : escapedName;
|
||||||
} else {
|
} else if (providerName === mssqlProviderName) {
|
||||||
finalString = escapedSchema ? `[${escapedSchema}].[${escapedName}]` : `[${escapedName}]`;
|
finalString = escapedSchema ? `[${escapedSchema}].[${escapedName}]` : `[${escapedName}]`;
|
||||||
|
} else if (providerName === pgsqlProviderName) {
|
||||||
|
finalString = element.metadata.schema ? `"${element.metadata.schema}"."${element.metadata.name}"` : `"${element.metadata.name}"`;
|
||||||
|
} else {
|
||||||
|
finalString = element.metadata.schema ? `${element.metadata.schema}.${element.metadata.name}` : `${element.metadata.name}`;
|
||||||
}
|
}
|
||||||
originalEvent.dataTransfer.setData(DataTransfers.RESOURCES, JSON.stringify([`${element.nodeTypeId}:${element.id}?${finalString}`]));
|
originalEvent.dataTransfer.setData(DataTransfers.RESOURCES, JSON.stringify([`${element.nodeTypeId}:${element.id}?${finalString}`]));
|
||||||
}
|
}
|
||||||
if (supportsFolderNodeNameDrop(element.nodeTypeId, element.label)) {
|
if (supportsFolderNodeNameDrop(element.nodeTypeId, element.label)) {
|
||||||
// get children
|
// get children
|
||||||
let returnString = '';
|
let returnString = '';
|
||||||
|
let providerName = this.getProviderNameFromElement(element);
|
||||||
for (let child of element.children) {
|
for (let child of element.children) {
|
||||||
escapedSchema = escapeString(child.metadata.schema);
|
escapedSchema = escapeString(child.metadata.schema);
|
||||||
escapedName = escapeString(child.metadata.name);
|
escapedName = escapeString(child.metadata.name);
|
||||||
|
if (providerName === mssqlProviderName) {
|
||||||
finalString = escapedSchema ? `[${escapedSchema}].[${escapedName}]` : `[${escapedName}]`;
|
finalString = escapedSchema ? `[${escapedSchema}].[${escapedName}]` : `[${escapedName}]`;
|
||||||
|
} else if (providerName === pgsqlProviderName) {
|
||||||
|
finalString = child.metadata.schema ? `"${child.metadata.schema}"."${child.metadata.name}"` : `"${child.metadata.name}"`;
|
||||||
|
} else {
|
||||||
|
finalString = child.metadata.schema ? `${child.metadata.schema}.${child.metadata.name}` : `${child.metadata.name}`;
|
||||||
|
}
|
||||||
returnString = returnString ? `${returnString},${finalString}` : `${finalString}`;
|
returnString = returnString ? `${returnString},${finalString}` : `${finalString}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { ServerTreeDragAndDrop } from 'sql/workbench/services/objectExplorer/bro
|
|||||||
import { TestTree } from 'sql/workbench/test/treeMock';
|
import { TestTree } from 'sql/workbench/test/treeMock';
|
||||||
import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
|
import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
import { mssqlProviderName, pgsqlProviderName } from 'sql/platform/connection/common/constants';
|
||||||
import { TreeNode } from 'sql/workbench/services/objectExplorer/common/treeNode';
|
import { TreeNode } from 'sql/workbench/services/objectExplorer/common/treeNode';
|
||||||
|
|
||||||
|
|
||||||
@@ -48,9 +48,29 @@ suite('SQL Drag And Drop Controller tests', () => {
|
|||||||
id: 'd936bb32-422b-49c3-963f-ae9532d63dc5'
|
id: 'd936bb32-422b-49c3-963f-ae9532d63dc5'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let iConnectionProfileId_pgsql: IConnectionProfile = {
|
||||||
|
connectionName: 'new name',
|
||||||
|
serverName: 'new server',
|
||||||
|
databaseName: 'database',
|
||||||
|
userName: 'user',
|
||||||
|
password: 'password',
|
||||||
|
authenticationType: '',
|
||||||
|
savePassword: true,
|
||||||
|
groupFullName: 'g2/g2-2',
|
||||||
|
groupId: 'group id',
|
||||||
|
getOptionsKey: undefined!,
|
||||||
|
matches: undefined!,
|
||||||
|
providerName: pgsqlProviderName,
|
||||||
|
options: {},
|
||||||
|
saveProfile: true,
|
||||||
|
id: 'd936bb32-422b-49c3-963f-ae9532d63dc6'
|
||||||
|
};
|
||||||
|
|
||||||
let connectionProfileId = new ConnectionProfile(capabilitiesService, iConnectionProfileId);
|
let connectionProfileId = new ConnectionProfile(capabilitiesService, iConnectionProfileId);
|
||||||
let connectionProfileArray = [connectionProfileId];
|
let connectionProfileId_pgsql = new ConnectionProfile(capabilitiesService, iConnectionProfileId_pgsql);
|
||||||
|
let connectionProfileArray = [connectionProfileId, connectionProfileId_pgsql];
|
||||||
let connectionProfileGroupId = new ConnectionProfileGroup('name', undefined, 'd936bb32-422b-49c3-963f-ae9532d63dc5', 'color', 'description');
|
let connectionProfileGroupId = new ConnectionProfileGroup('name', undefined, 'd936bb32-422b-49c3-963f-ae9532d63dc5', 'color', 'description');
|
||||||
|
connectionProfileGroupId.addConnections([connectionProfileId_pgsql]);
|
||||||
let connectionProfileGroupArray = [connectionProfileGroupId];
|
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];
|
let treeNodeArray = [treeNode];
|
||||||
@@ -79,8 +99,10 @@ suite('SQL Drag And Drop Controller tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('able to get DragURI', async () => {
|
test('able to get DragURI', async () => {
|
||||||
let uri = serverTreeDragAndDrop.getDragURI(testTree, connectionProfileId);
|
connectionProfileArray.forEach(connectionProfile => {
|
||||||
assert.equal(connectionProfileId.id, uri);
|
let uri = serverTreeDragAndDrop.getDragURI(testTree, connectionProfile);
|
||||||
|
assert.equal(connectionProfile.id, uri);
|
||||||
|
});
|
||||||
|
|
||||||
let uriGroup = serverTreeDragAndDrop.getDragURI(testTree, connectionProfileGroupId);
|
let uriGroup = serverTreeDragAndDrop.getDragURI(testTree, connectionProfileGroupId);
|
||||||
assert.equal(connectionProfileGroupId.id, uriGroup);
|
assert.equal(connectionProfileGroupId.id, uriGroup);
|
||||||
|
|||||||
Reference in New Issue
Block a user