mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
fix strict null issues (#22430)
This commit is contained in:
4
extensions/mssql/src/mssql.d.ts
vendored
4
extensions/mssql/src/mssql.d.ts
vendored
@@ -1104,11 +1104,11 @@ declare module 'mssql' {
|
|||||||
/**
|
/**
|
||||||
* Schemas owned by the user.
|
* Schemas owned by the user.
|
||||||
*/
|
*/
|
||||||
ownedSchemas: string[] | undefined;
|
ownedSchemas: string[];
|
||||||
/**
|
/**
|
||||||
* Database roles that the user belongs to.
|
* Database roles that the user belongs to.
|
||||||
*/
|
*/
|
||||||
databaseRoles: string[] | undefined;
|
databaseRoles: string[];
|
||||||
/**
|
/**
|
||||||
* The name of the server login associated with the user.
|
* The name of the server login associated with the user.
|
||||||
* Only applicable when the user type is 'WithLogin'.
|
* Only applicable when the user type is 'WithLogin'.
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ async function handleNewUserDialogCommand(context: azdata.ObjectExplorerContext,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const dialog = new UserDialog(service, connectionUri, context.connectionProfile.databaseName, true, undefined, context);
|
const dialog = new UserDialog(service, connectionUri, context.connectionProfile!.databaseName!, true, undefined, context);
|
||||||
await dialog.open();
|
await dialog.open();
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -85,15 +85,15 @@ async function handleObjectPropertiesDialogCommand(context: azdata.ObjectExplore
|
|||||||
if (!connectionUri) {
|
if (!connectionUri) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const nodeTypeDisplayName = getNodeTypeDisplayName(context.nodeInfo.nodeType);
|
const nodeTypeDisplayName = getNodeTypeDisplayName(context.nodeInfo!.nodeType);
|
||||||
try {
|
try {
|
||||||
let dialog;
|
let dialog;
|
||||||
switch (context.nodeInfo.nodeType) {
|
switch (context.nodeInfo!.nodeType) {
|
||||||
case NodeType.Login:
|
case NodeType.Login:
|
||||||
dialog = new LoginDialog(service, connectionUri, false, context.nodeInfo.label);
|
dialog = new LoginDialog(service, connectionUri, false, context.nodeInfo!.label);
|
||||||
break;
|
break;
|
||||||
case NodeType.User:
|
case NodeType.User:
|
||||||
dialog = new UserDialog(service, connectionUri, context.connectionProfile.databaseName, false, context.nodeInfo.label);
|
dialog = new UserDialog(service, connectionUri, context.connectionProfile!.databaseName!, false, context.nodeInfo!.label);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -104,9 +104,9 @@ async function handleObjectPropertiesDialogCommand(context: azdata.ObjectExplore
|
|||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
TelemetryReporter.createErrorEvent2(TelemetryViews.ObjectManagement, TelemetryActions.OpenPropertiesDialog, err).withAdditionalProperties({
|
TelemetryReporter.createErrorEvent2(TelemetryViews.ObjectManagement, TelemetryActions.OpenPropertiesDialog, err).withAdditionalProperties({
|
||||||
objectType: context.nodeInfo.nodeType
|
objectType: context.nodeInfo!.nodeType
|
||||||
}).send();
|
}).send();
|
||||||
await vscode.window.showErrorMessage(localizedConstants.OpenObjectPropertiesDialogError(nodeTypeDisplayName, context.nodeInfo.label, getErrorMessage(err)));
|
await vscode.window.showErrorMessage(localizedConstants.OpenObjectPropertiesDialogError(nodeTypeDisplayName, context.nodeInfo!.label, getErrorMessage(err)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,16 +115,16 @@ async function handleDeleteObjectCommand(context: azdata.ObjectExplorerContext,
|
|||||||
if (!connectionUri) {
|
if (!connectionUri) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let additionalConfirmationMessage: string;
|
let additionalConfirmationMessage: string | undefined = undefined;
|
||||||
switch (context.nodeInfo.nodeType) {
|
switch (context.nodeInfo!.nodeType) {
|
||||||
case NodeType.Login:
|
case NodeType.Login:
|
||||||
additionalConfirmationMessage = localizedConstants.DeleteLoginConfirmationText;
|
additionalConfirmationMessage = localizedConstants.DeleteLoginConfirmationText;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const nodeTypeDisplayName = getNodeTypeDisplayName(context.nodeInfo.nodeType);
|
const nodeTypeDisplayName = getNodeTypeDisplayName(context.nodeInfo!.nodeType);
|
||||||
let confirmMessage = localizedConstants.DeleteObjectConfirmationText(nodeTypeDisplayName, context.nodeInfo.label);
|
let confirmMessage = localizedConstants.DeleteObjectConfirmationText(nodeTypeDisplayName, context.nodeInfo!.label);
|
||||||
if (additionalConfirmationMessage) {
|
if (additionalConfirmationMessage) {
|
||||||
confirmMessage = `${additionalConfirmationMessage} ${confirmMessage}`;
|
confirmMessage = `${additionalConfirmationMessage} ${confirmMessage}`;
|
||||||
}
|
}
|
||||||
@@ -133,23 +133,23 @@ async function handleDeleteObjectCommand(context: azdata.ObjectExplorerContext,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
azdata.tasks.startBackgroundOperation({
|
azdata.tasks.startBackgroundOperation({
|
||||||
displayName: localizedConstants.DeleteObjectOperationDisplayName(nodeTypeDisplayName, context.nodeInfo.label),
|
displayName: localizedConstants.DeleteObjectOperationDisplayName(nodeTypeDisplayName, context.nodeInfo!.label),
|
||||||
description: '',
|
description: '',
|
||||||
isCancelable: false,
|
isCancelable: false,
|
||||||
operation: async (operation) => {
|
operation: async (operation) => {
|
||||||
try {
|
try {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
await service.drop(connectionUri, context.nodeInfo.metadata.urn);
|
await service.drop(connectionUri, context.nodeInfo!.metadata!.urn);
|
||||||
TelemetryReporter.sendTelemetryEvent(TelemetryActions.DeleteObject, {
|
TelemetryReporter.sendTelemetryEvent(TelemetryActions.DeleteObject, {
|
||||||
objectType: context.nodeInfo.nodeType
|
objectType: context.nodeInfo!.nodeType
|
||||||
}, {
|
}, {
|
||||||
elapsedTimeMs: Date.now() - startTime
|
elapsedTimeMs: Date.now() - startTime
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
operation.updateStatus(azdata.TaskStatus.Failed, localizedConstants.DeleteObjectError(nodeTypeDisplayName, context.nodeInfo.label, getErrorMessage(err)));
|
operation.updateStatus(azdata.TaskStatus.Failed, localizedConstants.DeleteObjectError(nodeTypeDisplayName, context.nodeInfo!.label, getErrorMessage(err)));
|
||||||
TelemetryReporter.createErrorEvent2(TelemetryViews.ObjectManagement, TelemetryActions.DeleteObject, err).withAdditionalProperties({
|
TelemetryReporter.createErrorEvent2(TelemetryViews.ObjectManagement, TelemetryActions.DeleteObject, err).withAdditionalProperties({
|
||||||
objectType: context.nodeInfo.nodeType
|
objectType: context.nodeInfo!.nodeType
|
||||||
}).send();
|
}).send();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -164,8 +164,8 @@ async function handleRenameObjectCommand(context: azdata.ObjectExplorerContext,
|
|||||||
if (!connectionUri) {
|
if (!connectionUri) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const nodeTypeDisplayName = getNodeTypeDisplayName(context.nodeInfo.nodeType);
|
const nodeTypeDisplayName = getNodeTypeDisplayName(context.nodeInfo!.nodeType);
|
||||||
const originalName = context.nodeInfo.metadata.name;
|
const originalName = context.nodeInfo!.metadata!.name;
|
||||||
const newName = await vscode.window.showInputBox({
|
const newName = await vscode.window.showInputBox({
|
||||||
title: localizedConstants.RenameObjectDialogTitle,
|
title: localizedConstants.RenameObjectDialogTitle,
|
||||||
value: originalName,
|
value: originalName,
|
||||||
@@ -191,9 +191,9 @@ async function handleRenameObjectCommand(context: azdata.ObjectExplorerContext,
|
|||||||
operation: async (operation) => {
|
operation: async (operation) => {
|
||||||
try {
|
try {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
await service.rename(connectionUri, context.nodeInfo.metadata.urn, newName);
|
await service.rename(connectionUri, context.nodeInfo!.metadata!.urn, newName);
|
||||||
TelemetryReporter.sendTelemetryEvent(TelemetryActions.RenameObject, {
|
TelemetryReporter.sendTelemetryEvent(TelemetryActions.RenameObject, {
|
||||||
objectType: context.nodeInfo.nodeType
|
objectType: context.nodeInfo!.nodeType
|
||||||
}, {
|
}, {
|
||||||
elapsedTimeMs: Date.now() - startTime
|
elapsedTimeMs: Date.now() - startTime
|
||||||
});
|
});
|
||||||
@@ -201,7 +201,7 @@ async function handleRenameObjectCommand(context: azdata.ObjectExplorerContext,
|
|||||||
catch (err) {
|
catch (err) {
|
||||||
operation.updateStatus(azdata.TaskStatus.Failed, localizedConstants.RenameObjectError(nodeTypeDisplayName, originalName, newName, getErrorMessage(err)));
|
operation.updateStatus(azdata.TaskStatus.Failed, localizedConstants.RenameObjectError(nodeTypeDisplayName, originalName, newName, getErrorMessage(err)));
|
||||||
TelemetryReporter.createErrorEvent2(TelemetryViews.ObjectManagement, TelemetryActions.RenameObject, err).withAdditionalProperties({
|
TelemetryReporter.createErrorEvent2(TelemetryViews.ObjectManagement, TelemetryActions.RenameObject, err).withAdditionalProperties({
|
||||||
objectType: context.nodeInfo.nodeType
|
objectType: context.nodeInfo!.nodeType
|
||||||
}).send();
|
}).send();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -212,7 +212,7 @@ async function handleRenameObjectCommand(context: azdata.ObjectExplorerContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getConnectionUri(context: azdata.ObjectExplorerContext): Promise<string> {
|
async function getConnectionUri(context: azdata.ObjectExplorerContext): Promise<string> {
|
||||||
const connectionUri = await azdata.connection.getUriForConnection(context.connectionProfile.id);
|
const connectionUri = await azdata.connection.getUriForConnection(context.connectionProfile!.id);
|
||||||
if (!connectionUri) {
|
if (!connectionUri) {
|
||||||
await vscode.window.showErrorMessage(localizedConstants.FailedToRetrieveConnectionInfoErrorMessage, { modal: true });
|
await vscode.window.showErrorMessage(localizedConstants.FailedToRetrieveConnectionInfoErrorMessage, { modal: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,7 +236,8 @@ export class TestObjectManagementService implements IObjectManagementService {
|
|||||||
authenticationType: AuthenticationType.Sql,
|
authenticationType: AuthenticationType.Sql,
|
||||||
loginName: 'sa',
|
loginName: 'sa',
|
||||||
ownedSchemas: [],
|
ownedSchemas: [],
|
||||||
databaseRoles: []
|
databaseRoles: [],
|
||||||
|
password: ''
|
||||||
},
|
},
|
||||||
languages: languages,
|
languages: languages,
|
||||||
schemas: schemas,
|
schemas: schemas,
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ export class LoginDialog extends ObjectManagementDialogBase<ObjectManagement.Log
|
|||||||
width: DefaultInputWidth
|
width: DefaultInputWidth
|
||||||
}).component();
|
}).component();
|
||||||
this.disposables.push(this.nameInput.onTextChanged(async () => {
|
this.disposables.push(this.nameInput.onTextChanged(async () => {
|
||||||
this.objectInfo.name = this.nameInput.value;
|
this.objectInfo.name = this.nameInput.value!;
|
||||||
this.onObjectValueChange();
|
this.onObjectValueChange();
|
||||||
await this.runValidation(false);
|
await this.runValidation(false);
|
||||||
}));
|
}));
|
||||||
@@ -149,7 +149,7 @@ export class LoginDialog extends ObjectManagementDialogBase<ObjectManagement.Log
|
|||||||
|
|
||||||
this.enabledCheckbox = this.createCheckbox(localizedConstants.EnabledText, this.objectInfo.isEnabled);
|
this.enabledCheckbox = this.createCheckbox(localizedConstants.EnabledText, this.objectInfo.isEnabled);
|
||||||
this.disposables.push(this.enabledCheckbox.onChanged(() => {
|
this.disposables.push(this.enabledCheckbox.onChanged(() => {
|
||||||
this.objectInfo.isEnabled = this.enabledCheckbox.checked;
|
this.objectInfo.isEnabled = this.enabledCheckbox.checked!;
|
||||||
this.onObjectValueChange();
|
this.onObjectValueChange();
|
||||||
}));
|
}));
|
||||||
this.generalSection = this.createGroup(localizedConstants.GeneralSectionHeader, [nameContainer, authTypeContainer, this.enabledCheckbox], false);
|
this.generalSection = this.createGroup(localizedConstants.GeneralSectionHeader, [nameContainer, authTypeContainer, this.enabledCheckbox], false);
|
||||||
@@ -222,7 +222,7 @@ export class LoginDialog extends ObjectManagementDialogBase<ObjectManagement.Log
|
|||||||
this.lockedOutCheckbox = this.createCheckbox(localizedConstants.LoginLockedOutText, this.objectInfo.isLockedOut, this.viewInfo.canEditLockedOutState);
|
this.lockedOutCheckbox = this.createCheckbox(localizedConstants.LoginLockedOutText, this.objectInfo.isLockedOut, this.viewInfo.canEditLockedOutState);
|
||||||
items.push(this.lockedOutCheckbox);
|
items.push(this.lockedOutCheckbox);
|
||||||
this.disposables.push(this.lockedOutCheckbox.onChanged(() => {
|
this.disposables.push(this.lockedOutCheckbox.onChanged(() => {
|
||||||
this.objectInfo.isLockedOut = this.lockedOutCheckbox.checked;
|
this.objectInfo.isLockedOut = this.lockedOutCheckbox.checked!;
|
||||||
this.onObjectValueChange();
|
this.onObjectValueChange();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -250,7 +250,7 @@ export class LoginDialog extends ObjectManagementDialogBase<ObjectManagement.Log
|
|||||||
|
|
||||||
this.connectPermissionCheckbox = this.createCheckbox(localizedConstants.PermissionToConnectText, this.objectInfo.connectPermission);
|
this.connectPermissionCheckbox = this.createCheckbox(localizedConstants.PermissionToConnectText, this.objectInfo.connectPermission);
|
||||||
this.disposables.push(this.connectPermissionCheckbox.onChanged(() => {
|
this.disposables.push(this.connectPermissionCheckbox.onChanged(() => {
|
||||||
this.objectInfo.connectPermission = this.connectPermissionCheckbox.checked;
|
this.objectInfo.connectPermission = this.connectPermissionCheckbox.checked!;
|
||||||
this.onObjectValueChange();
|
this.onObjectValueChange();
|
||||||
}));
|
}));
|
||||||
items.push(defaultDatabaseContainer, defaultLanguageContainer, this.connectPermissionCheckbox);
|
items.push(defaultDatabaseContainer, defaultLanguageContainer, this.connectPermissionCheckbox);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
|||||||
protected readonly objectManagementService: IObjectManagementService,
|
protected readonly objectManagementService: IObjectManagementService,
|
||||||
protected readonly connectionUri: string,
|
protected readonly connectionUri: string,
|
||||||
protected isNewObject: boolean,
|
protected isNewObject: boolean,
|
||||||
protected readonly objectName: string | undefined = undefined,
|
protected readonly objectName: string = '',
|
||||||
protected readonly objectExplorerContext?: azdata.ObjectExplorerContext,
|
protected readonly objectExplorerContext?: azdata.ObjectExplorerContext,
|
||||||
dialogWidth: azdata.window.DialogWidth = 'narrow') {
|
dialogWidth: azdata.window.DialogWidth = 'narrow') {
|
||||||
const objectTypeDisplayName = getNodeTypeDisplayName(objectType, true);
|
const objectTypeDisplayName = getNodeTypeDisplayName(objectType, true);
|
||||||
@@ -204,7 +204,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
|||||||
level: azdata.window.MessageLevel.Error
|
level: azdata.window.MessageLevel.Error
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
this.dialogObject.message = undefined;
|
this.dialogObject.message = { text: '' };
|
||||||
}
|
}
|
||||||
return errors.length === 0;
|
return errors.length === 0;
|
||||||
}
|
}
|
||||||
@@ -270,7 +270,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
|||||||
height: getTableHeight(tableData.length)
|
height: getTableHeight(tableData.length)
|
||||||
}
|
}
|
||||||
).component();
|
).component();
|
||||||
this.disposables.push(table.onCellAction((arg: azdata.ICheckboxCellActionEventArgs) => {
|
this.disposables.push(table.onCellAction!((arg: azdata.ICheckboxCellActionEventArgs) => {
|
||||||
const name = listValues[arg.row];
|
const name = listValues[arg.row];
|
||||||
const idx = selectedValues.indexOf(name);
|
const idx = selectedValues.indexOf(name);
|
||||||
if (arg.checked && idx === -1) {
|
if (arg.checked && idx === -1) {
|
||||||
@@ -283,7 +283,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
|||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createDropdown(ariaLabel: string, values: string[], value: string, enabled: boolean = true, width: number = DefaultInputWidth): azdata.DropDownComponent {
|
protected createDropdown(ariaLabel: string, values: string[], value: string | undefined, enabled: boolean = true, width: number = DefaultInputWidth): azdata.DropDownComponent {
|
||||||
// Automatically add an empty item to the beginning of the list if the current value is not specified.
|
// Automatically add an empty item to the beginning of the list if the current value is not specified.
|
||||||
// This is needed when no meaningful default value can be provided.
|
// This is needed when no meaningful default value can be provided.
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export class UserDialog extends ObjectManagementDialogBase<ObjectManagement.User
|
|||||||
if (this.objectInfo.password !== this.confirmPasswordInput.value) {
|
if (this.objectInfo.password !== this.confirmPasswordInput.value) {
|
||||||
errors.push(localizedConstants.PasswordsNotMatchError);
|
errors.push(localizedConstants.PasswordsNotMatchError);
|
||||||
}
|
}
|
||||||
if (!isValidSQLPassword(this.objectInfo.password, this.objectInfo.name)
|
if (!isValidSQLPassword(this.objectInfo.password!, this.objectInfo.name)
|
||||||
&& (this.isNewObject || this.objectInfo.password !== this.originalObjectInfo.password)) {
|
&& (this.isNewObject || this.objectInfo.password !== this.originalObjectInfo.password)) {
|
||||||
errors.push(localizedConstants.InvalidPasswordError);
|
errors.push(localizedConstants.InvalidPasswordError);
|
||||||
}
|
}
|
||||||
@@ -96,12 +96,12 @@ export class UserDialog extends ObjectManagementDialogBase<ObjectManagement.User
|
|||||||
width: DefaultInputWidth
|
width: DefaultInputWidth
|
||||||
}).component();
|
}).component();
|
||||||
this.disposables.push(this.nameInput.onTextChanged(async () => {
|
this.disposables.push(this.nameInput.onTextChanged(async () => {
|
||||||
this.objectInfo.name = this.nameInput.value;
|
this.objectInfo.name = this.nameInput.value!;
|
||||||
this.onObjectValueChange();
|
this.onObjectValueChange();
|
||||||
await this.runValidation(false);
|
await this.runValidation(false);
|
||||||
}));
|
}));
|
||||||
const nameContainer = this.createLabelInputContainer(localizedConstants.NameText, this.nameInput);
|
const nameContainer = this.createLabelInputContainer(localizedConstants.NameText, this.nameInput);
|
||||||
this.defaultSchemaDropdown = this.createDropdown(localizedConstants.DefaultSchemaText, this.viewInfo.schemas, this.objectInfo.defaultSchema);
|
this.defaultSchemaDropdown = this.createDropdown(localizedConstants.DefaultSchemaText, this.viewInfo.schemas, this.objectInfo.defaultSchema!);
|
||||||
this.defaultSchemaContainer = this.createLabelInputContainer(localizedConstants.DefaultSchemaText, this.defaultSchemaDropdown);
|
this.defaultSchemaContainer = this.createLabelInputContainer(localizedConstants.DefaultSchemaText, this.defaultSchemaDropdown);
|
||||||
this.disposables.push(this.defaultSchemaDropdown.onValueChanged(() => {
|
this.disposables.push(this.defaultSchemaDropdown.onValueChanged(() => {
|
||||||
this.objectInfo.defaultSchema = <string>this.defaultSchemaDropdown.value;
|
this.objectInfo.defaultSchema = <string>this.defaultSchemaDropdown.value;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export function deepClone<T>(obj: T): T {
|
|||||||
export async function refreshParentNode(context: azdata.ObjectExplorerContext): Promise<void> {
|
export async function refreshParentNode(context: azdata.ObjectExplorerContext): Promise<void> {
|
||||||
if (context) {
|
if (context) {
|
||||||
try {
|
try {
|
||||||
const node = await azdata.objectexplorer.getNode(context.connectionProfile.id, context.nodeInfo.nodePath);
|
const node = await azdata.objectexplorer.getNode(context.connectionProfile!.id, context.nodeInfo!.nodePath);
|
||||||
const parentNode = await node?.getParent();
|
const parentNode = await node?.getParent();
|
||||||
await parentNode?.refresh();
|
await parentNode?.refresh();
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ export async function refreshParentNode(context: azdata.ObjectExplorerContext):
|
|||||||
export async function refreshNode(context: azdata.ObjectExplorerContext): Promise<void> {
|
export async function refreshNode(context: azdata.ObjectExplorerContext): Promise<void> {
|
||||||
if (context) {
|
if (context) {
|
||||||
try {
|
try {
|
||||||
const node = await azdata.objectexplorer.getNode(context.connectionProfile.id, context.nodeInfo.nodePath);
|
const node = await azdata.objectexplorer.getNode(context.connectionProfile!.id, context.nodeInfo!.nodePath);
|
||||||
await node?.refresh();
|
await node?.refresh();
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -72,7 +72,9 @@ export function getNodeTypeDisplayName(type: string, inTitle: boolean = false):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAuthenticationTypeDisplayName(authType: AuthenticationType): string {
|
export function getAuthenticationTypeDisplayName(authType: AuthenticationType | undefined): string | undefined {
|
||||||
|
if (authType === undefined) { return undefined; }
|
||||||
|
|
||||||
switch (authType) {
|
switch (authType) {
|
||||||
case AuthenticationType.Windows:
|
case AuthenticationType.Windows:
|
||||||
return WindowsAuthenticationTypeDisplayText;
|
return WindowsAuthenticationTypeDisplayText;
|
||||||
|
|||||||
@@ -20,30 +20,30 @@ const DidInformUserKey: string = 'tableDesigner.DidInformUser';
|
|||||||
export function registerTableDesignerCommands(appContext: AppContext) {
|
export function registerTableDesignerCommands(appContext: AppContext) {
|
||||||
appContext.extensionContext.subscriptions.push(vscode.commands.registerCommand('mssql.newTable', async (context: azdata.ObjectExplorerContext) => {
|
appContext.extensionContext.subscriptions.push(vscode.commands.registerCommand('mssql.newTable', async (context: azdata.ObjectExplorerContext) => {
|
||||||
void showPreloadDbModelSettingPrompt(appContext);
|
void showPreloadDbModelSettingPrompt(appContext);
|
||||||
const connectionString = await azdata.connection.getConnectionString(context.connectionProfile.id, true);
|
const connectionString = await azdata.connection.getConnectionString(context.connectionProfile!.id, true);
|
||||||
const tableIcon = context.nodeInfo.nodeSubType as azdata.designers.TableIcon;
|
const tableIcon = context.nodeInfo!.nodeSubType as azdata.designers.TableIcon;
|
||||||
const telemetryInfo = await getTelemetryInfo(context, tableIcon);
|
const telemetryInfo = await getTelemetryInfo(context, tableIcon);
|
||||||
await azdata.designers.openTableDesigner(sqlProviderName, {
|
await azdata.designers.openTableDesigner(sqlProviderName, {
|
||||||
title: NewTableText,
|
title: NewTableText,
|
||||||
tooltip: `${context.connectionProfile.serverName} - ${context.connectionProfile.databaseName} - ${NewTableText}`,
|
tooltip: `${context.connectionProfile!.serverName} - ${context.connectionProfile!.databaseName} - ${NewTableText}`,
|
||||||
server: context.connectionProfile.serverName,
|
server: context.connectionProfile!.serverName,
|
||||||
database: context.connectionProfile.databaseName,
|
database: context.connectionProfile!.databaseName,
|
||||||
isNewTable: true,
|
isNewTable: true,
|
||||||
id: generateUuid(),
|
id: generateUuid(),
|
||||||
connectionString: connectionString,
|
connectionString: connectionString,
|
||||||
accessToken: context.connectionProfile.options.azureAccountToken,
|
accessToken: context.connectionProfile!.options.azureAccountToken,
|
||||||
tableIcon: tableIcon
|
tableIcon: tableIcon
|
||||||
}, telemetryInfo);
|
}, telemetryInfo);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
appContext.extensionContext.subscriptions.push(vscode.commands.registerCommand('mssql.designTable', async (context: azdata.ObjectExplorerContext) => {
|
appContext.extensionContext.subscriptions.push(vscode.commands.registerCommand('mssql.designTable', async (context: azdata.ObjectExplorerContext) => {
|
||||||
void showPreloadDbModelSettingPrompt(appContext);
|
void showPreloadDbModelSettingPrompt(appContext);
|
||||||
const server = context.connectionProfile.serverName;
|
const server = context.connectionProfile!.serverName;
|
||||||
const database = context.connectionProfile.databaseName;
|
const database = context.connectionProfile!.databaseName;
|
||||||
const schema = context.nodeInfo.metadata.schema;
|
const schema = context.nodeInfo!.metadata!.schema;
|
||||||
const name = context.nodeInfo.metadata.name;
|
const name = context.nodeInfo!.metadata!.name;
|
||||||
const connectionString = await azdata.connection.getConnectionString(context.connectionProfile.id, true);
|
const connectionString = await azdata.connection.getConnectionString(context.connectionProfile!.id, true);
|
||||||
const tableIcon = context.nodeInfo.nodeSubType as azdata.designers.TableIcon;
|
const tableIcon = context.nodeInfo!.nodeSubType as azdata.designers.TableIcon;
|
||||||
const telemetryInfo = await getTelemetryInfo(context, tableIcon);
|
const telemetryInfo = await getTelemetryInfo(context, tableIcon);
|
||||||
await azdata.designers.openTableDesigner(sqlProviderName, {
|
await azdata.designers.openTableDesigner(sqlProviderName, {
|
||||||
title: `${schema}.${name}`,
|
title: `${schema}.${name}`,
|
||||||
@@ -55,14 +55,14 @@ export function registerTableDesignerCommands(appContext: AppContext) {
|
|||||||
schema: schema,
|
schema: schema,
|
||||||
id: `${sqlProviderName}|${server}|${database}|${schema}|${name}`,
|
id: `${sqlProviderName}|${server}|${database}|${schema}|${name}`,
|
||||||
connectionString: connectionString,
|
connectionString: connectionString,
|
||||||
accessToken: context.connectionProfile.options.azureAccountToken,
|
accessToken: context.connectionProfile!.options.azureAccountToken,
|
||||||
tableIcon: tableIcon
|
tableIcon: tableIcon
|
||||||
}, telemetryInfo);
|
}, telemetryInfo);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getTelemetryInfo(context: azdata.ObjectExplorerContext, tableType: string): Promise<telemetry.TelemetryEventProperties> {
|
async function getTelemetryInfo(context: azdata.ObjectExplorerContext, tableType: string): Promise<telemetry.TelemetryEventProperties> {
|
||||||
const serverInfo = await azdata.connection.getServerInfo(context.connectionProfile.id);
|
const serverInfo = await azdata.connection.getServerInfo(context.connectionProfile!.id);
|
||||||
const telemetryInfo: telemetry.TelemetryEventProperties = {
|
const telemetryInfo: telemetry.TelemetryEventProperties = {
|
||||||
tableType
|
tableType
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user