Add New Object context menu entries on the objects themselves in OE (#23676)

This commit is contained in:
Cory Rivera
2023-07-07 10:45:39 -07:00
committed by GitHub
parent a6cba3b318
commit f4688f447c
3 changed files with 68 additions and 44 deletions

View File

@@ -78,8 +78,21 @@ async function handleNewObjectDialogCommand(context: azdata.ObjectExplorerContex
case FolderType.Databases:
objectType = ObjectManagement.NodeType.Database;
break;
default:
throw new Error(`Unsupported folder type: ${context.nodeInfo!.objectType}`);
}
// Fall back to node type in case the user right clicked on an object instead of a folder
if (!objectType) {
switch (context.nodeInfo!.nodeType) {
case ObjectManagement.NodeType.ApplicationRole:
case ObjectManagement.NodeType.DatabaseRole:
case ObjectManagement.NodeType.ServerLevelLogin:
case ObjectManagement.NodeType.ServerLevelServerRole:
case ObjectManagement.NodeType.User:
case ObjectManagement.NodeType.Database:
objectType = context.nodeInfo!.nodeType as ObjectManagement.NodeType;
break;
default:
throw new Error(objectManagementLoc.NoDialogFoundError(context.nodeInfo!.nodeType, context.nodeInfo!.objectType));
}
}
try {

View File

@@ -26,6 +26,7 @@ export const ApplicationRoleTypeDisplayNameInTitle: string = localize('objectMan
export const DatabaseRoleTypeDisplayName: string = localize('objectManagement.DatabaseRoleTypeDisplayName', "database role");
export const DatabaseRoleTypeDisplayNameInTitle: string = localize('objectManagement.DatabaseRoleTypeDisplayNameInTitle', "Database Role");
export const DatabaseTypeDisplayNameInTitle: string = localize('objectManagement.DatabaseDisplayNameInTitle', "Database");
export function NoDialogFoundError(nodeType: string, objectType: string): string { return localize('objectManagement.noDialogFoundError', "Could not find a supported dialog for node type '{0}' and object type '{1}'.", nodeType, objectType); }
// Shared Strings
export const FailedToRetrieveConnectionInfoErrorMessage: string = localize('objectManagement.noConnectionUriError', "Failed to retrieve the connection information, please reconnect and try again.")