Add Connect/disconnect, change database options to query toolbar (#17938)

This commit is contained in:
Christopher Suh 2024-07-22 14:24:06 -04:00 коммит произвёл GitHub
Родитель 81d15c7aeb
Коммит 0b1f2f32af
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
10 изменённых файлов: 46 добавлений и 2 удалений

Просмотреть файл

@ -11,6 +11,9 @@
<trans-unit id="mssql.cancelQuery">
<source xml:lang="en">Cancel Query</source>
</trans-unit>
<trans-unit id="mssql.changeDatabase">
<source xml:lang="en">Change Database</source>
</trans-unit>
<trans-unit id="mssql.addObjectExplorer">
<source xml:lang="en">Add Connection</source>
</trans-unit>

Просмотреть файл

@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#212121;}</style></defs><title>change_connection</title><g id="path1"><path class="cls-1" d="M7.7,6.72h.83l0,2.85H7.68ZM5.51,8.61h.73v1.52A2,2,0,0,0,8,12.3h.19A2,2,0,0,0,10,10.16V8.64h.73v1.52a2.81,2.81,0,0,1-2.52,3H8A2.81,2.81,0,0,1,5.5,10.13ZM6.46,3.8A2.23,2.23,0,0,1,8,3.11h.19a2.81,2.81,0,0,1,2.47,3.06V7.7H10V6.17A2,2,0,0,0,8.24,4H8A2,2,0,0,0,6.26,6.14V7.67H5.52V6.14A3.33,3.33,0,0,1,6.46,3.8Z"/></g><path class="cls-1" d="M8,14.83a7,7,0,0,0,6.76-5l.93.29a7.75,7.75,0,0,1-1.14,2.32,8.11,8.11,0,0,1-4,3A7.88,7.88,0,0,1,8,15.8a8,8,0,0,1-3.9-1,8.14,8.14,0,0,1-1.63-1.2A7.82,7.82,0,0,1,1.18,12v1.85H.2V10H4.1v1H1.69a7.05,7.05,0,0,0,2.6,2.84,7.29,7.29,0,0,0,1.76.79A6.8,6.8,0,0,0,8,14.83ZM15.8,2.15V6H11.9v-1h2.41a7,7,0,0,0-1.12-1.61A7.08,7.08,0,0,0,11.7,2.24a7.28,7.28,0,0,0-1.76-.78A6.8,6.8,0,0,0,8,1.17a7,7,0,0,0-6.76,5L.31,5.91A7.79,7.79,0,0,1,1.44,3.59a8.08,8.08,0,0,1,4-3A7.85,7.85,0,0,1,8,.2a8,8,0,0,1,3.9,1,8.14,8.14,0,0,1,1.63,1.2A7.81,7.81,0,0,1,14.82,4V2.15Z"/></svg>

После

Ширина:  |  Высота:  |  Размер: 1.1 KiB

Просмотреть файл

@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#fff;}</style></defs><title>change_connection_inverse</title><g id="path1"><path class="cls-1" d="M7.7,6.72h.83l0,2.85H7.68ZM5.51,8.61h.73v1.52A2,2,0,0,0,8,12.3h.19A2,2,0,0,0,10,10.16V8.64h.73v1.52a2.81,2.81,0,0,1-2.52,3H8A2.81,2.81,0,0,1,5.5,10.13ZM6.46,3.8A2.23,2.23,0,0,1,8,3.11h.19a2.81,2.81,0,0,1,2.47,3.06V7.7H10V6.17A2,2,0,0,0,8.24,4H8A2,2,0,0,0,6.26,6.14V7.67H5.52V6.14A3.33,3.33,0,0,1,6.46,3.8Z"/></g><path class="cls-1" d="M8,14.83a7,7,0,0,0,6.76-5l.93.29a7.75,7.75,0,0,1-1.14,2.32,8.11,8.11,0,0,1-4,3A7.88,7.88,0,0,1,8,15.8a8,8,0,0,1-3.9-1,8.14,8.14,0,0,1-1.63-1.2A7.82,7.82,0,0,1,1.18,12v1.85H.2V10H4.1v1H1.69a7.05,7.05,0,0,0,2.6,2.84,7.29,7.29,0,0,0,1.76.79A6.8,6.8,0,0,0,8,14.83ZM15.8,2.15V6H11.9v-1h2.41a7,7,0,0,0-1.12-1.61A7.08,7.08,0,0,0,11.7,2.24a7.28,7.28,0,0,0-1.76-.78A6.8,6.8,0,0,0,8,1.17a7,7,0,0,0-6.76,5L.31,5.91A7.79,7.79,0,0,1,1.44,3.59a8.08,8.08,0,0,1,4-3A7.85,7.85,0,0,1,8,.2a8,8,0,0,1,3.9,1,8.14,8.14,0,0,1,1.63,1.2A7.81,7.81,0,0,1,14.82,4V2.15Z"/></svg>

После

Ширина:  |  Высота:  |  Размер: 1.1 KiB

1
media/connect.svg Normal file
Просмотреть файл

@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#212121;}</style></defs><title>connect</title><path id="path1" class="cls-1" d="M7.67,5.75H9l0,4.51H7.64Zm-3.47,3H5.36l0,2.41c0,1.88,1.23,3.42,2.76,3.43h.31c1.54,0,2.8-1.51,2.82-3.38l0-2.41h1.16l0,2.41c0,2.66-1.8,4.8-4,4.78H8.1c-2.18,0-3.93-2.19-3.91-4.84ZM5.7,1.12A3.53,3.53,0,0,1,8.22,0h.31c2.18,0,3.93,2.19,3.91,4.85l0,2.41H11.26l0-2.41c0-1.88-1.23-3.41-2.76-3.43H8.21C6.67,1.44,5.41,3,5.39,4.84l0,2.41H4.22l0-2.41A5.28,5.28,0,0,1,5.7,1.12Z"/></svg>

После

Ширина:  |  Высота:  |  Размер: 570 B

Просмотреть файл

@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#fff;}</style></defs><title>connect_inverse</title><path id="path1" class="cls-1" d="M7.67,5.75H9l0,4.51H7.64Zm-3.47,3H5.36l0,2.41c0,1.88,1.23,3.42,2.76,3.43h.31c1.54,0,2.8-1.51,2.82-3.38l0-2.41h1.16l0,2.41c0,2.66-1.8,4.8-4,4.78H8.1c-2.18,0-3.93-2.19-3.91-4.84ZM5.7,1.12A3.53,3.53,0,0,1,8.22,0h.31c2.18,0,3.93,2.19,3.91,4.85l0,2.41H11.26l0-2.41c0-1.88-1.23-3.41-2.76-3.43H8.21C6.67,1.44,5.41,3,5.39,4.84l0,2.41H4.22l0-2.41A5.28,5.28,0,0,1,5.7,1.12Z"/></svg>

После

Ширина:  |  Высота:  |  Размер: 575 B

Просмотреть файл

@ -240,6 +240,20 @@
"command": "mssql.cancelQuery",
"when": "editorLangId == sql && resourcePath in mssql.runningQueries",
"group": "navigation@2"
},
{"command": "mssql.connect",
"when": "editorLangId == sql && resource not in mssql.connections",
"group": "navigation@3"
},
{
"command": "mssql.disconnect",
"when": "editorLangId == sql && resource in mssql.connections",
"group": "navigation@3"
},
{
"command": "mssql.changeDatabase",
"when": "editorLangId == sql",
"group": "navigation@4"
}
],
"editor/context": [
@ -446,12 +460,26 @@
{
"command": "mssql.connect",
"title": "%mssql.connect%",
"category": "MS SQL"
"category": "MS SQL",
"icon": {
"dark": "media/connect_inverse.svg",
"light": "media/connect.svg"
}
},
{
"command": "mssql.disconnect",
"title": "%mssql.disconnect%",
"category": "MS SQL"
"category": "MS SQL",
"icon": "$(debug-disconnect)"
},
{
"command": "mssql.changeDatabase",
"title": "%mssql.changeDatabase%",
"category": "MS SQL",
"icon": {
"dark": "media/changeConnection_inverse.svg",
"light": "media/changeConnection.svg"
}
},
{
"command": "mssql.manageProfiles",

Просмотреть файл

@ -2,6 +2,7 @@
"mssql.runQuery":"Execute Query",
"mssql.runCurrentStatement":"Execute Current Statement",
"mssql.cancelQuery":"Cancel Query",
"mssql.changeDatabase":"Change Database",
"mssql.addObjectExplorer":"Add Connection",
"mssql.scriptSelect":"Select Top 1000",
"mssql.scriptCreate":"Script as Create",

Просмотреть файл

@ -24,6 +24,7 @@ export const cmdRunCurrentStatement = 'mssql.runCurrentStatement';
export const cmdCancelQuery = 'mssql.cancelQuery';
export const cmdConnect = 'mssql.connect';
export const cmdDisconnect = 'mssql.disconnect';
export const cmdChangeDatabase = 'mssql.changeDatabase';
export const cmdChooseDatabase = 'mssql.chooseDatabase';
export const cmdChooseLanguageFlavor = 'mssql.chooseLanguageFlavor';
export const cmdShowReleaseNotes = 'mssql.showReleaseNotes';

Просмотреть файл

@ -707,6 +707,7 @@ export default class ConnectionManager {
}
delete this._connections[fileUri];
vscode.commands.executeCommand('setContext', 'mssql.connections', this._connections);
return result;
} else if (this.isConnecting(fileUri)) {
@ -873,6 +874,7 @@ export default class ConnectionManager {
if (error) {
reject(error);
} else {
vscode.commands.executeCommand('setContext', 'mssql.connections', this._connections);
resolve(connectResult);
}
});

Просмотреть файл

@ -148,6 +148,8 @@ export default class MainController implements vscode.Disposable {
this._event.on(Constants.cmdClearPooledConnections, async () => { await this.onClearPooledConnections(); });
this.registerCommand(Constants.cmdRunCurrentStatement);
this._event.on(Constants.cmdRunCurrentStatement, () => { this.onRunCurrentStatement(); });
this.registerCommand(Constants.cmdChangeDatabase);
this._event.on(Constants.cmdChangeDatabase, () => { this.runAndLogErrors(this.onChooseDatabase()); });
this.registerCommand(Constants.cmdChooseDatabase);
this._event.on(Constants.cmdChooseDatabase, () => { this.runAndLogErrors(this.onChooseDatabase()); });
this.registerCommand(Constants.cmdChooseLanguageFlavor);
@ -730,6 +732,9 @@ export default class MainController implements vscode.Disposable {
this._outputContentProvider.cancelQuery(fileUri);
}
const success = await this._connectionMgr.onDisconnect();
if (success) {
vscode.commands.executeCommand('setContext', 'mssql.editorConnected', false);
}
return success;
}
return false;