3491 Added Function to NodeTypes. Added Function to CanAlter and CanExecute. Added function support to css. Added drag and drop support for functions (#11990)

This commit is contained in:
Justin M
2020-08-31 16:46:00 -07:00
committed by GitHub
parent a35c267214
commit a5b1e027c1
7 changed files with 31 additions and 8 deletions

View File

@@ -15,7 +15,7 @@ import { TreeNode } from 'sql/workbench/services/objectExplorer/common/treeNode'
import { AsyncServerTree } from 'sql/workbench/services/objectExplorer/browser/asyncServerTree';
export function supportsNodeNameDrop(nodeId: string): boolean {
if (nodeId === 'Table' || nodeId === 'Column' || nodeId === 'View') {
if (nodeId === 'Table' || nodeId === 'Column' || nodeId === 'View' || nodeId === 'Function') {
return true;
}
return false;
@@ -97,7 +97,12 @@ export class ServerTreeDragAndDrop implements IDragAndDrop {
if (supportsNodeNameDrop(element.nodeTypeId)) {
escapedSchema = escapeString(element.metadata.schema);
escapedName = escapeString(element.metadata.name);
finalString = escapedSchema ? `[${escapedSchema}].[${escapedName}]` : `[${escapedName}]`;
let providerName = this.getProviderNameFromElement(element);
if (providerName === 'KUSTO') {
finalString = element.nodeTypeId !== 'Function' && escapedName.indexOf(' ') > 0 ? `[@"${escapedName}"]` : escapedName;
} else {
finalString = escapedSchema ? `[${escapedSchema}].[${escapedName}]` : `[${escapedName}]`;
}
originalEvent.dataTransfer.setData(DataTransfers.RESOURCES, JSON.stringify([`${element.nodeTypeId}:${element.id}?${finalString}`]));
}
if (supportsFolderNodeNameDrop(element.nodeTypeId, element.label)) {
@@ -115,6 +120,14 @@ export class ServerTreeDragAndDrop implements IDragAndDrop {
return;
}
private getProviderNameFromElement(element: TreeNode): string | undefined {
if (element.connection) {
return element.connection.providerName;
}
return this.getProviderNameFromElement(element.parent);
}
public canDragToConnectionProfileGroup(source: any, targetConnectionProfileGroup: ConnectionProfileGroup) {
let canDragOver: boolean = true;

View File

@@ -546,6 +546,9 @@
background: url("SystemUnicodeCharacterString.svg") center center no-repeat;
}
.vs .icon.function,
.vs-dark .icon.function,
.hc-black .icon.function,
.vs .icon.tablevaluedfunction,
.vs-dark .icon.tablevaluedfunction,
.hc-black .icon.tablevaluedfunction {

View File

@@ -27,9 +27,9 @@ export class MssqlNodeContext extends Disposable {
static readonly canCreateOrDelete = new Set([NodeType.AggregateFunction, NodeType.PartitionFunction, NodeType.ScalarValuedFunction,
NodeType.Schema, NodeType.StoredProcedure, NodeType.Table, NodeType.TableValuedFunction,
NodeType.User, NodeType.UserDefinedTableType, NodeType.View]);
static readonly canExecute = new Set([NodeType.StoredProcedure]);
static readonly canExecute = new Set([NodeType.StoredProcedure, NodeType.Function]);
static readonly canAlter = new Set([NodeType.AggregateFunction, NodeType.PartitionFunction, NodeType.ScalarValuedFunction,
NodeType.StoredProcedure, NodeType.TableValuedFunction, NodeType.View]);
NodeType.StoredProcedure, NodeType.TableValuedFunction, NodeType.View, NodeType.Function]);
// General node context keys
static NodeProvider = new RawContextKey<string>('nodeProvider', undefined);

View File

@@ -93,10 +93,11 @@ export class NodeType {
public static ExternalTable = 'ExternalTable';
public static ColumnMasterKey = 'ColumnMasterKey';
public static ColumnEncryptionKey = 'ColumnEncryptionKey';
public static Function = 'Function';
public static readonly SCRIPTABLE_OBJECTS = [NodeType.Table, NodeType.View, NodeType.Schema, NodeType.User, NodeType.UserDefinedTableType,
NodeType.StoredProcedure, NodeType.AggregateFunction, NodeType.PartitionFunction, NodeType.ScalarValuedFunction,
NodeType.TableValuedFunction];
NodeType.TableValuedFunction, NodeType.Function];
}
export interface SqlThemeIcon {