mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-24 05:40:29 -04:00
Create separate ScriptableDialogBase (#22974)
* Create separate ScriptableDialogBase * more
This commit is contained in:
@@ -10,7 +10,8 @@ import { LoginDialog } from './ui/loginDialog';
|
||||
import { TestObjectManagementService } from './objectManagementService';
|
||||
import { getErrorMessage } from '../utils';
|
||||
import { FolderType, TelemetryActions, ObjectManagementViewName } from './constants';
|
||||
import * as localizedConstants from './localizedConstants';
|
||||
import * as objectManagementLoc from './localizedConstants';
|
||||
import * as uiLoc from '../ui/localizedConstants';
|
||||
import { UserDialog } from './ui/userDialog';
|
||||
import { IObjectManagementService, ObjectManagement } from 'mssql';
|
||||
import * as constants from '../constants';
|
||||
@@ -91,7 +92,7 @@ async function handleNewObjectDialogCommand(context: azdata.ObjectExplorerContex
|
||||
objectType: context.nodeInfo!.nodeType
|
||||
}).send();
|
||||
console.error(err);
|
||||
await vscode.window.showErrorMessage(localizedConstants.OpenNewObjectDialogError(localizedConstants.getNodeTypeDisplayName(objectType), getErrorMessage(err)));
|
||||
await vscode.window.showErrorMessage(objectManagementLoc.OpenNewObjectDialogError(objectManagementLoc.getNodeTypeDisplayName(objectType), getErrorMessage(err)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +121,7 @@ async function handleObjectPropertiesDialogCommand(context: azdata.ObjectExplore
|
||||
objectType: context.nodeInfo!.nodeType
|
||||
}).send();
|
||||
console.error(err);
|
||||
await vscode.window.showErrorMessage(localizedConstants.OpenObjectPropertiesDialogError(localizedConstants.getNodeTypeDisplayName(context.nodeInfo!.nodeType), context.nodeInfo!.label, getErrorMessage(err)));
|
||||
await vscode.window.showErrorMessage(objectManagementLoc.OpenObjectPropertiesDialogError(objectManagementLoc.getNodeTypeDisplayName(context.nodeInfo!.nodeType), context.nodeInfo!.label, getErrorMessage(err)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,22 +133,22 @@ async function handleDeleteObjectCommand(context: azdata.ObjectExplorerContext,
|
||||
let additionalConfirmationMessage: string | undefined = undefined;
|
||||
switch (context.nodeInfo!.nodeType) {
|
||||
case ObjectManagement.NodeType.ServerLevelLogin:
|
||||
additionalConfirmationMessage = localizedConstants.DeleteLoginConfirmationText;
|
||||
additionalConfirmationMessage = objectManagementLoc.DeleteLoginConfirmationText;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
const nodeTypeDisplayName = localizedConstants.getNodeTypeDisplayName(context.nodeInfo!.nodeType);
|
||||
let confirmMessage = localizedConstants.DeleteObjectConfirmationText(nodeTypeDisplayName, context.nodeInfo!.label);
|
||||
const nodeTypeDisplayName = objectManagementLoc.getNodeTypeDisplayName(context.nodeInfo!.nodeType);
|
||||
let confirmMessage = objectManagementLoc.DeleteObjectConfirmationText(nodeTypeDisplayName, context.nodeInfo!.label);
|
||||
if (additionalConfirmationMessage) {
|
||||
confirmMessage = `${additionalConfirmationMessage} ${confirmMessage}`;
|
||||
}
|
||||
const confirmResult = await vscode.window.showWarningMessage(confirmMessage, { modal: true }, localizedConstants.YesText);
|
||||
if (confirmResult !== localizedConstants.YesText) {
|
||||
const confirmResult = await vscode.window.showWarningMessage(confirmMessage, { modal: true }, uiLoc.YesText);
|
||||
if (confirmResult !== uiLoc.YesText) {
|
||||
return;
|
||||
}
|
||||
azdata.tasks.startBackgroundOperation({
|
||||
displayName: localizedConstants.DeleteObjectOperationDisplayName(nodeTypeDisplayName, context.nodeInfo!.label),
|
||||
displayName: objectManagementLoc.DeleteObjectOperationDisplayName(nodeTypeDisplayName, context.nodeInfo!.label),
|
||||
description: '',
|
||||
isCancelable: false,
|
||||
operation: async (operation) => {
|
||||
@@ -161,7 +162,7 @@ async function handleDeleteObjectCommand(context: azdata.ObjectExplorerContext,
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
operation.updateStatus(azdata.TaskStatus.Failed, localizedConstants.DeleteObjectError(nodeTypeDisplayName, context.nodeInfo!.label, getErrorMessage(err)));
|
||||
operation.updateStatus(azdata.TaskStatus.Failed, objectManagementLoc.DeleteObjectError(nodeTypeDisplayName, context.nodeInfo!.label, getErrorMessage(err)));
|
||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.DeleteObject, err).withAdditionalProperties({
|
||||
objectType: context.nodeInfo!.nodeType
|
||||
}).send();
|
||||
@@ -179,14 +180,14 @@ async function handleRenameObjectCommand(context: azdata.ObjectExplorerContext,
|
||||
if (!connectionUri) {
|
||||
return;
|
||||
}
|
||||
const nodeTypeDisplayName = localizedConstants.getNodeTypeDisplayName(context.nodeInfo!.nodeType);
|
||||
const nodeTypeDisplayName = objectManagementLoc.getNodeTypeDisplayName(context.nodeInfo!.nodeType);
|
||||
const originalName = context.nodeInfo!.metadata!.name;
|
||||
const newName = await vscode.window.showInputBox({
|
||||
title: localizedConstants.RenameObjectDialogTitle,
|
||||
title: objectManagementLoc.RenameObjectDialogTitle,
|
||||
value: originalName,
|
||||
validateInput: (value: string): string | undefined => {
|
||||
if (!value) {
|
||||
return localizedConstants.NameCannotBeEmptyError;
|
||||
return objectManagementLoc.NameCannotBeEmptyError;
|
||||
} else {
|
||||
// valid
|
||||
return undefined;
|
||||
@@ -200,7 +201,7 @@ async function handleRenameObjectCommand(context: azdata.ObjectExplorerContext,
|
||||
}
|
||||
|
||||
azdata.tasks.startBackgroundOperation({
|
||||
displayName: localizedConstants.RenameObjectOperationDisplayName(nodeTypeDisplayName, originalName, newName),
|
||||
displayName: objectManagementLoc.RenameObjectOperationDisplayName(nodeTypeDisplayName, originalName, newName),
|
||||
description: '',
|
||||
isCancelable: false,
|
||||
operation: async (operation) => {
|
||||
@@ -214,7 +215,7 @@ async function handleRenameObjectCommand(context: azdata.ObjectExplorerContext,
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
operation.updateStatus(azdata.TaskStatus.Failed, localizedConstants.RenameObjectError(nodeTypeDisplayName, originalName, newName, getErrorMessage(err)));
|
||||
operation.updateStatus(azdata.TaskStatus.Failed, objectManagementLoc.RenameObjectError(nodeTypeDisplayName, originalName, newName, getErrorMessage(err)));
|
||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.RenameObject, err).withAdditionalProperties({
|
||||
objectType: context.nodeInfo!.nodeType
|
||||
}).send();
|
||||
@@ -247,7 +248,7 @@ function getDialog(service: IObjectManagementService, dialogOptions: ObjectManag
|
||||
async function getConnectionUri(context: azdata.ObjectExplorerContext): Promise<string> {
|
||||
const connectionUri = await azdata.connection.getUriForConnection(context.connectionProfile!.id);
|
||||
if (!connectionUri) {
|
||||
await vscode.window.showErrorMessage(localizedConstants.FailedToRetrieveConnectionInfoErrorMessage, { modal: true });
|
||||
await vscode.window.showErrorMessage(objectManagementLoc.FailedToRetrieveConnectionInfoErrorMessage, { modal: true });
|
||||
}
|
||||
return connectionUri;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user