mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Pass connectionid to registered commands from command line (#3861)
* pass connectionid to registered commands from commandline * remove blank lines * fix commandline unit test
This commit is contained in:
@@ -13,10 +13,18 @@ const localize = nls.loadMessageBundle();
|
|||||||
let counter = 0;
|
let counter = 0;
|
||||||
|
|
||||||
export function activate(extensionContext: vscode.ExtensionContext) {
|
export function activate(extensionContext: vscode.ExtensionContext) {
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.new', () => {
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.new', ( connectionId? : string) => {
|
||||||
let title = `Untitled-${counter++}`;
|
let title = `Untitled-${counter++}`;
|
||||||
let untitledUri = vscode.Uri.parse(`untitled:${title}`);
|
let untitledUri = vscode.Uri.parse(`untitled:${title}`);
|
||||||
sqlops.nb.showNotebookDocument(untitledUri).then(success => {
|
let options: sqlops.nb.NotebookShowOptions = connectionId? {
|
||||||
|
viewColumn : null,
|
||||||
|
preserveFocus : true,
|
||||||
|
preview: null,
|
||||||
|
providerId : null,
|
||||||
|
connectionId : connectionId,
|
||||||
|
defaultKernel : null
|
||||||
|
} : null;
|
||||||
|
sqlops.nb.showNotebookDocument(untitledUri, options).then(success => {
|
||||||
|
|
||||||
}, (err: Error) => {
|
}, (err: Error) => {
|
||||||
vscode.window.showErrorMessage(err.message);
|
vscode.window.showErrorMessage(err.message);
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export class CommandLineService implements ICommandLineProcessing {
|
|||||||
} else {
|
} else {
|
||||||
self._connectionManagementService.connectIfNotConnected(self._connectionProfile, 'connection', true)
|
self._connectionManagementService.connectIfNotConnected(self._connectionProfile, 'connection', true)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
self._commandService.executeCommand(self._commandName, self._connectionProfile).then(() => resolve(), error => reject(error));
|
self._commandService.executeCommand(self._commandName, self._connectionProfile.id).then(() => resolve(), error => reject(error));
|
||||||
}, error => {
|
}, error => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ suite('commandLineService tests', () => {
|
|||||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver'), 'connection', true))
|
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver'), 'connection', true))
|
||||||
.returns(() => new Promise<string>((resolve, reject) => { resolve('unused'); }))
|
.returns(() => new Promise<string>((resolve, reject) => { resolve('unused'); }))
|
||||||
.verifiable(TypeMoq.Times.once());
|
.verifiable(TypeMoq.Times.once());
|
||||||
commandService.setup(c => c.executeCommand('mycommand', TypeMoq.It.is<ConnectionProfile>(p => p.serverName === 'myserver')))
|
commandService.setup(c => c.executeCommand('mycommand', TypeMoq.It.isAnyString()))
|
||||||
.returns(() => TPromise.wrap(1))
|
.returns(() => TPromise.wrap(1))
|
||||||
.verifiable(TypeMoq.Times.once());
|
.verifiable(TypeMoq.Times.once());
|
||||||
const configurationService = getConfigurationServiceMock(true);
|
const configurationService = getConfigurationServiceMock(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user