mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
add disposeTableDesigner (#17394)
This commit is contained in:
@@ -1050,4 +1050,7 @@ export namespace SaveTableDesignerChangesRequest {
|
||||
export const type = new RequestType<SaveTableDesignerChangesRequestParams, void, void, void>('tabledesigner/savechanges');
|
||||
}
|
||||
|
||||
export namespace DisposeTableDesignerRequest {
|
||||
export const type = new RequestType<azdata.designers.TableInfo, void, void, void>('tabledesigner/dispose');
|
||||
}
|
||||
// ------------------------------- < Table Designer > ------------------------------------
|
||||
|
||||
@@ -1146,11 +1146,22 @@ export class TableDesignerFeature extends SqlOpsFeature<undefined> {
|
||||
}
|
||||
};
|
||||
|
||||
const disposeTableDesigner = (tableInfo: azdata.designers.TableInfo): Thenable<void> => {
|
||||
try {
|
||||
return client.sendRequest(contracts.DisposeTableDesignerRequest.type, tableInfo);
|
||||
}
|
||||
catch (e) {
|
||||
client.logFailedRequest(contracts.DisposeTableDesignerRequest.type, e);
|
||||
return Promise.reject(e);
|
||||
}
|
||||
};
|
||||
|
||||
return azdata.dataprotocol.registerTableDesignerProvider({
|
||||
providerId: client.providerId,
|
||||
getTableDesignerInfo,
|
||||
processTableEdit,
|
||||
saveTable
|
||||
saveTable,
|
||||
disposeTableDesigner
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,15 +7,17 @@ import { AppContext } from '../appContext';
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import { sqlProviderName } from '../constants';
|
||||
import { generateUuid } from 'vscode-languageclient/lib/utils/uuid';
|
||||
|
||||
export function registerTableDesignerCommands(appContext: AppContext) {
|
||||
appContext.extensionContext.subscriptions.push(vscode.commands.registerCommand('mssql.newTable', async (context: azdata.ObjectExplorerContext) => {
|
||||
const connectionUri = await azdata.connection.getUriForConnection(context.connectionProfile.id);
|
||||
const connectionString = await azdata.connection.getConnectionString(context.connectionProfile.id, true);
|
||||
await azdata.designers.openTableDesigner(sqlProviderName, {
|
||||
server: context.connectionProfile.serverName,
|
||||
database: context.connectionProfile.databaseName,
|
||||
isNewTable: true,
|
||||
connectionUri: connectionUri
|
||||
id: generateUuid(),
|
||||
connectionString: connectionString
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -24,6 +26,7 @@ export function registerTableDesignerCommands(appContext: AppContext) {
|
||||
const database = context.connectionProfile.databaseName;
|
||||
const schema = context.nodeInfo.metadata.schema;
|
||||
const name = context.nodeInfo.metadata.name;
|
||||
const connectionString = await azdata.connection.getConnectionString(context.connectionProfile.id, true);
|
||||
const connectionUri = await azdata.connection.getUriForConnection(context.connectionProfile.id);
|
||||
await azdata.designers.openTableDesigner(sqlProviderName, {
|
||||
server: server,
|
||||
@@ -31,9 +34,8 @@ export function registerTableDesignerCommands(appContext: AppContext) {
|
||||
isNewTable: false,
|
||||
name: name,
|
||||
schema: schema,
|
||||
id: `${server}|${database}|${schema}|${name}`,
|
||||
connectionUri: connectionUri
|
||||
id: `${connectionUri}|${database}|${schema}|${name}`,
|
||||
connectionString: connectionString
|
||||
});
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user