Move query history into extension (#19794)

* initial

* more

* Remove connectionId

* cleanup

* cleanup

* Remove core contributions, add to panel by default

* Add enabled state

* Update config

* cleanup

* Move

* Remove newlines

* update README
This commit is contained in:
Charles Gagnon
2022-06-22 12:37:32 -07:00
committed by GitHub
parent 8ce19dca8c
commit c24305f9d8
27 changed files with 353 additions and 1138 deletions

View File

@@ -3,15 +3,39 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as azdata from 'azdata';
import * as vscode from 'vscode';
import { QueryHistoryNode } from './queryHistoryNode';
import { QueryHistoryProvider } from './queryHistoryProvider';
export async function activate(context: vscode.ExtensionContext): Promise<void> {
// Currently all the functionality for this is contained within the core ADS
// code as the extensibility API doesn't currently support all the required
// functionality (such as contributing tab panels)
void vscode.commands.executeCommand('queryHistory.enableQueryHistory');
}
export async function deactivate(): Promise<void> {
const provider = new QueryHistoryProvider();
context.subscriptions.push(provider);
context.subscriptions.push(vscode.window.registerTreeDataProvider('queryHistory', provider));
context.subscriptions.push(vscode.commands.registerCommand('queryHistory.open', async (node: QueryHistoryNode) => {
return azdata.queryeditor.openQueryDocument(
{
content: node.queryText
}, node.connectionProfile?.providerId);
}));
context.subscriptions.push(vscode.commands.registerCommand('queryHistory.run', async (node: QueryHistoryNode) => {
const doc = await azdata.queryeditor.openQueryDocument(
{
content: node.queryText
}, node.connectionProfile?.providerId);
await azdata.queryeditor.connect(doc.uri, node.connectionProfile?.connectionId || '');
azdata.queryeditor.runQuery(doc.uri);
}));
context.subscriptions.push(vscode.commands.registerCommand('queryHistory.delete', (node: QueryHistoryNode) => {
provider.deleteNode(node);
}));
context.subscriptions.push(vscode.commands.registerCommand('queryHistory.clear', () => {
provider.clearAll();
}));
context.subscriptions.push(vscode.commands.registerCommand('queryHistory.disableCapture', async () => {
return provider.setCaptureEnabled(false);
}));
context.subscriptions.push(vscode.commands.registerCommand('queryHistory.enableCapture', async () => {
return provider.setCaptureEnabled(true);
}));
}