mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-10-24 13:47:39 -05:00
Add Commit and Rollback buttons to the Query Tool. Fixes #2418
This commit is contained in:
1 parent
0766b17726
commit
38b034ec3c
19 files changed
+394
-51
No files matched your search
+61
-43
@@ -49,19 +49,19 @@ icons may support functionality accessed via the :ref:`data editor <editgrid>`.
|
|||||||
|
|
||||||
Hover over an icon to display a tooltip that describes the icon's functionality:
|
Hover over an icon to display a tooltip that describes the icon's functionality:
|
||||||
|
|
||||||
+----------------------+---------------------------------------------------------------------------------------------------+-------------+
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
| Icon | Behavior | Shortcut |
|
| Icon | Behavior | Shortcut |
|
||||||
+======================+===================================================================================================+=============+
|
+======================+===================================================================================================+================+
|
||||||
| *Open File* | Click the *Open File* icon to display a previously saved query in the SQL Editor. | |
|
| *Open File* | Click the *Open File* icon to display a previously saved query in the SQL Editor. | Accesskey + O |
|
||||||
+----------------------+---------------------------------------------------------------------------------------------------+-------------+
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
| *Save* | Click the *Save* icon to perform a quick-save of a previously saved query, or to access the | |
|
| *Save* | Click the *Save* icon to perform a quick-save of a previously saved query, or to access the | Accesskey + S |
|
||||||
| | *Save* menu: | |
|
| | *Save* menu: | |
|
||||||
| | | |
|
| | | |
|
||||||
| | * Select *Save* to save the selected content of the SQL Editor panel in a file. | |
|
| | * Select *Save* to save the selected content of the SQL Editor panel in a file. | |
|
||||||
| | | |
|
| | | |
|
||||||
| | * Select *Save As* to open a new browser dialog and specify a new location to which to save the | |
|
| | * Select *Save As* to open a new browser dialog and specify a new location to which to save the | |
|
||||||
| | selected content of the SQL Editor panel. | |
|
| | selected content of the SQL Editor panel. | |
|
||||||
+----------------------+---------------------------------------------------------------------------------------------------+-------------+
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
| *Find* | Use the *Find* menu to search, replace, or navigate the code displayed in the SQL Editor: | |
|
| *Find* | Use the *Find* menu to search, replace, or navigate the code displayed in the SQL Editor: | |
|
||||||
| | | |
|
| | | |
|
||||||
| | * Select *Find* to provide a search target, and search the SQL Editor contents. | Cmd+F |
|
| | * Select *Find* to provide a search target, and search the SQL Editor contents. | Cmd+F |
|
||||||
@@ -77,11 +77,16 @@ Hover over an icon to display a tooltip that describes the icon's functionality:
|
|||||||
| | * Select *Replace all* to locate and replace all occurrences of the target within the editor. | |
|
| | * Select *Replace all* to locate and replace all occurrences of the target within the editor. | |
|
||||||
| | | |
|
| | | |
|
||||||
| | * Select *Jump* to navigate to the next occurrence of the search target. | Alt+G |
|
| | * Select *Jump* to navigate to the next occurrence of the search target. | Alt+G |
|
||||||
+----------------------+---------------------------------------------------------------------------------------------------+-------------+
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
| *Copy* | Click the *Copy* icon to copy the content that is currently highlighted in the Data Output panel. | |
|
| *Copy* | Click the *Copy* icon to copy the content that is currently highlighted in the Data Output panel. | Accesskey + C |
|
||||||
+----------------------+---------------------------------------------------------------------------------------------------+-------------+
|
| | when in View/Edit data mode. | |
|
||||||
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
|
| *Paste* | Click the *Paste* icon to paste a previously row into a new row when in View/Edit data mode. | Accesskey + P |
|
||||||
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
|
| *Delete* | Click the *Delete* icon to delete the selected rows when in View/Edit data mode. | Accesskey + D |
|
||||||
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
| *Edit* | Use options on the *Edit* menu to access text editing tools; the options operate on the text | |
|
| *Edit* | Use options on the *Edit* menu to access text editing tools; the options operate on the text | |
|
||||||
| | displayed in the SQL Editor panel: | |
|
| | displayed in the SQL Editor panel when in Query Tool mode: | |
|
||||||
| | | |
|
| | | |
|
||||||
| | * Select *Indent Selection* to indent the currently selected text. | Tab |
|
| | * Select *Indent Selection* to indent the currently selected text. | Tab |
|
||||||
| | | |
|
| | | |
|
||||||
@@ -95,53 +100,66 @@ Hover over an icon to display a tooltip that describes the icon's functionality:
|
|||||||
| | | |
|
| | | |
|
||||||
| | * Select *Block Comment* to enclose all lines that contain the selection in C style | Shift+Cmd+/ |
|
| | * Select *Block Comment* to enclose all lines that contain the selection in C style | Shift+Cmd+/ |
|
||||||
| | comment notation. This option acts as a toggle. | |
|
| | comment notation. This option acts as a toggle. | |
|
||||||
+----------------------+---------------------------------------------------------------------------------------------------+-------------+
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
| *Execute/Refresh* | Click the *Execute/Refresh* icon to either execute or refresh the query highlighted in the SQL | |
|
| *Filter* | Click the *Filter* icon to set filtering and sorting criteria for the data when in View/Edit data | Accesskey + F |
|
||||||
|
| | mode. Click the down arrow to access other filtering and sorting options: | |
|
||||||
|
| | | |
|
||||||
|
| | * Click *Sort/Filter* to open the sorting and filtering dialogue. | |
|
||||||
|
| | | |
|
||||||
|
| | * Click *Filter by Selection* to show only the rows containing the values in the selected cells. | |
|
||||||
|
| | | |
|
||||||
|
| | * Click *Exclude by Selection* to show only the rows that do not contain the values in the | |
|
||||||
|
| | selected cells. | |
|
||||||
|
| | | |
|
||||||
|
| | * Click *Remove Sort/Filter* to remove any previously selected sort or filtering options. | |
|
||||||
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
|
| Limit Selector | Select a value in the *Limit Selector* to limit the size of the dataset to a number of rows. | Accesskey + R |
|
||||||
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
|
| *Stop* | Click the *Stop* icon to cancel the execution of the currently running query. | Accesskey + Q |
|
||||||
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
|
| *Execute/Refresh* | Click the *Execute/Refresh* icon to either execute or refresh the query highlighted in the SQL | F5 |
|
||||||
| | editor panel. Click the down arrow to access other execution options: | |
|
| | editor panel. Click the down arrow to access other execution options: | |
|
||||||
| | | |
|
| | | |
|
||||||
| | * Select *Execute/Refresh* to invoke the SQL command and refresh the result set. | F5 |
|
|
||||||
| | | |
|
|
||||||
| | * Select *Explain* to view an explanation plan for the current query. The result of the | F7 |
|
|
||||||
| | EXPLAIN is displayed graphically on the *Explain* tab of the output panel, and in text | |
|
|
||||||
| | form on the *Data Output* tab. | |
|
|
||||||
| | | |
|
|
||||||
| | * Select *Explain analyze* to invoke an EXPLAIN ANALYZE command on the current query. | Shift+F7 |
|
|
||||||
| | | |
|
|
||||||
| | * Navigate through the *Explain Options* menu to select options for the EXPLAIN command: | |
|
|
||||||
| | | |
|
|
||||||
| | Select *Verbose* to display additional information regarding the query plan. | |
|
|
||||||
| | | |
|
|
||||||
| | Select *Costs* to include information on the estimated startup and total cost of each | |
|
|
||||||
| | plan node, as well as the estimated number of rows and the estimated width of each | |
|
|
||||||
| | row. | |
|
|
||||||
| | | |
|
|
||||||
| | Select *Buffers* to include information on buffer usage. | |
|
|
||||||
| | | |
|
|
||||||
| | Select *Timing* to include information about the startup time and the amount of time | |
|
|
||||||
| | spent in each node of the query. | |
|
|
||||||
| | | |
|
|
||||||
| | * Add a check next to *Auto-Rollback* to instruct the server to automatically roll back a | |
|
| | * Add a check next to *Auto-Rollback* to instruct the server to automatically roll back a | |
|
||||||
| | transaction if an error occurs during the transaction. | |
|
| | transaction if an error occurs during the transaction. | |
|
||||||
| | | |
|
| | | |
|
||||||
| | * Add a check next to *Auto-Commit* to instruct the server to automatically commit each | |
|
| | * Add a check next to *Auto-Commit* to instruct the server to automatically commit each | |
|
||||||
| | transaction. Any changes made by the transaction will be visible to others, and | |
|
| | transaction. Any changes made by the transaction will be visible to others, and | |
|
||||||
| | durable in the event of a crash. | |
|
| | durable in the event of a crash. | |
|
||||||
+----------------------+---------------------------------------------------------------------------------------------------+-------------+
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
| *Stop* | Click the *Stop* icon to cancel the execution of the currently running query. | |
|
| *Explain* | Click the *Explain* icon to view an explanation plan for the current query. The result of the | F7 |
|
||||||
+----------------------+---------------------------------------------------------------------------------------------------+-------------+
|
| | EXPLAIN is displayed graphically on the *Explain* tab of the output panel, and in text | |
|
||||||
| *Clear query window* | Use options on the *Clear* drop-down menu to erase display contents: | |
|
| | form on the *Data Output* tab. | |
|
||||||
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
|
| *Explain analyze* | Click the *Explain analyze* icon to invoke an EXPLAIN ANALYZE command on the current query. | Shift+F7 |
|
||||||
|
| | | |
|
||||||
|
| | Navigate through the *Explain Options* menu to select options for the EXPLAIN command: | |
|
||||||
|
| | | |
|
||||||
|
| | * Select *Verbose* to display additional information regarding the query plan. | |
|
||||||
|
| | | |
|
||||||
|
| | * Select *Costs* to include information on the estimated startup and total cost of each | |
|
||||||
|
| | plan node, as well as the estimated number of rows and the estimated width of each | |
|
||||||
|
| | row. | |
|
||||||
|
| | | |
|
||||||
|
| | * Select *Buffers* to include information on buffer usage. | |
|
||||||
|
| | | |
|
||||||
|
| | * Select *Timing* to include information about the startup time and the amount of time | |
|
||||||
|
| | spent in each node of the query. | |
|
||||||
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
|
| *Commit* | Click the *Commit* icon to commit the transaction. | Shift+CTRL+M |
|
||||||
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
|
| *Rollback* | Click the *Rollback* icon to rollback the transaction. | Shift+CTRL+R |
|
||||||
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
|
| *Clear* | Use options on the *Clear* drop-down menu to erase display contents: | Accesskey + L |
|
||||||
| | | |
|
| | | |
|
||||||
| | * Select *Clear Query Window* to erase the content of the SQL Editor panel. | |
|
| | * Select *Clear Query Window* to erase the content of the SQL Editor panel. | |
|
||||||
| | | |
|
| | | |
|
||||||
| | | |
|
| | * Select *Clear History* to erase the content of the *History* tab. | |
|
||||||
| | * Select *Explain analyze* to invoke an EXPLAIN ANALYZE command on the current query. | Shift+F7 |
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
| | | |
|
|
||||||
| | the SQL editor panel or the *History* tab. | |
|
|
||||||
+----------------------+---------------------------------------------------------------------------------------------------+-------------+
|
|
||||||
| *Download as CSV* | Click the *Download as CSV* icon to download the result set of the current query to a | F8 |
|
| *Download as CSV* | Click the *Download as CSV* icon to download the result set of the current query to a | F8 |
|
||||||
| | comma-separated list. You can specify the CSV settings through | |
|
| | comma-separated list. You can specify the CSV settings through | |
|
||||||
| | *Preferences -> SQL Editor -> CSV output* dialogue. | |
|
| | *Preferences -> SQL Editor -> CSV output* dialogue. | |
|
||||||
+----------------------+---------------------------------------------------------------------------------------------------+-------------+
|
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
|
||||||
|
|
||||||
|
|
||||||
**The SQL Editor Panel**
|
**The SQL Editor Panel**
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ Features
|
|||||||
|
|
||||||
| `Feature #1825 <https://redmine.postgresql.org/issues/1825>`_ - Install a script to start pgAdmin (pgadmin4) from the command line when installed from the Python wheel.
|
| `Feature #1825 <https://redmine.postgresql.org/issues/1825>`_ - Install a script to start pgAdmin (pgadmin4) from the command line when installed from the Python wheel.
|
||||||
| `Feature #2233 <https://redmine.postgresql.org/issues/2233>`_ - Add a "scratch pad" to the Query Tool to hold text snippets whilst editing.
|
| `Feature #2233 <https://redmine.postgresql.org/issues/2233>`_ - Add a "scratch pad" to the Query Tool to hold text snippets whilst editing.
|
||||||
|
| `Feature #2418 <https://redmine.postgresql.org/issues/2418>`_ - Add Commit and Rollback buttons to the Query Tool.
|
||||||
| `Feature #3439 <https://redmine.postgresql.org/issues/3439>`_ - Allow X-FRAME-OPTIONS to be set for security. Default to SAMEORIGIN.
|
| `Feature #3439 <https://redmine.postgresql.org/issues/3439>`_ - Allow X-FRAME-OPTIONS to be set for security. Default to SAMEORIGIN.
|
||||||
| `Feature #3559 <https://redmine.postgresql.org/issues/3559>`_ - Automatically expand child nodes as well as the selected node on the treeview if there is only one.
|
| `Feature #3559 <https://redmine.postgresql.org/issues/3559>`_ - Automatically expand child nodes as well as the selected node on the treeview if there is only one.
|
||||||
| `Feature #3886 <https://redmine.postgresql.org/issues/3886>`_ - Include multiple versions of the PG utilties in containers.
|
| `Feature #3886 <https://redmine.postgresql.org/issues/3886>`_ - Include multiple versions of the PG utilties in containers.
|
||||||
|
|||||||
@@ -181,6 +181,8 @@ function keyboardShortcutsQueryTool(
|
|||||||
let nextPanelKeys = sqlEditorController.preferences.move_next;
|
let nextPanelKeys = sqlEditorController.preferences.move_next;
|
||||||
let previousPanelKeys = sqlEditorController.preferences.move_previous;
|
let previousPanelKeys = sqlEditorController.preferences.move_previous;
|
||||||
let toggleCaseKeys = sqlEditorController.preferences.toggle_case;
|
let toggleCaseKeys = sqlEditorController.preferences.toggle_case;
|
||||||
|
let commitKeys = sqlEditorController.preferences.commit_transaction;
|
||||||
|
let rollbackKeys = sqlEditorController.preferences.rollback_transaction;
|
||||||
|
|
||||||
if (this.validateShortcutKeys(executeKeys, event)) {
|
if (this.validateShortcutKeys(executeKeys, event)) {
|
||||||
this._stopEventPropagation(event);
|
this._stopEventPropagation(event);
|
||||||
@@ -197,6 +199,18 @@ function keyboardShortcutsQueryTool(
|
|||||||
} else if (this.validateShortcutKeys(toggleCaseKeys, event)) {
|
} else if (this.validateShortcutKeys(toggleCaseKeys, event)) {
|
||||||
this._stopEventPropagation(event);
|
this._stopEventPropagation(event);
|
||||||
queryToolActions.toggleCaseOfSelectedText(sqlEditorController);
|
queryToolActions.toggleCaseOfSelectedText(sqlEditorController);
|
||||||
|
} else if (this.validateShortcutKeys(commitKeys, event)) {
|
||||||
|
// If transaction buttons are disabled then no need to execute commit.
|
||||||
|
if (!sqlEditorController.is_transaction_buttons_disabled) {
|
||||||
|
this._stopEventPropagation(event);
|
||||||
|
queryToolActions.executeCommit(sqlEditorController);
|
||||||
|
}
|
||||||
|
} else if (this.validateShortcutKeys(rollbackKeys, event)) {
|
||||||
|
// If transaction buttons are disabled then no need to execute rollback.
|
||||||
|
if (!sqlEditorController.is_transaction_buttons_disabled) {
|
||||||
|
this._stopEventPropagation(event);
|
||||||
|
queryToolActions.executeRollback(sqlEditorController);
|
||||||
|
}
|
||||||
} else if ((
|
} else if ((
|
||||||
(this.isMac() && event.metaKey) ||
|
(this.isMac() && event.metaKey) ||
|
||||||
(!this.isMac() && event.ctrlKey)
|
(!this.isMac() && event.ctrlKey)
|
||||||
|
|||||||
@@ -81,6 +81,12 @@ class ExecuteQuery {
|
|||||||
} else {
|
} else {
|
||||||
self.loadingScreen.hide();
|
self.loadingScreen.hide();
|
||||||
self.enableSQLEditorButtons();
|
self.enableSQLEditorButtons();
|
||||||
|
// Enable/Disable commit and rollback button.
|
||||||
|
if (result.data.data.transaction_status == 2 || result.data.data.transaction_status == 3) {
|
||||||
|
self.enableTransactionButtons();
|
||||||
|
} else {
|
||||||
|
self.disableTransactionButtons();
|
||||||
|
}
|
||||||
self.sqlServerObject.update_msg_history(false, httpMessageData.data.result);
|
self.sqlServerObject.update_msg_history(false, httpMessageData.data.result);
|
||||||
if ('notifies' in httpMessageData.data)
|
if ('notifies' in httpMessageData.data)
|
||||||
self.sqlServerObject.update_notifications(httpMessageData.data.notifies);
|
self.sqlServerObject.update_notifications(httpMessageData.data.notifies);
|
||||||
@@ -114,6 +120,13 @@ class ExecuteQuery {
|
|||||||
})
|
})
|
||||||
).then(
|
).then(
|
||||||
(httpMessage) => {
|
(httpMessage) => {
|
||||||
|
// Enable/Disable commit and rollback button.
|
||||||
|
if (httpMessage.data.data.transaction_status == 2 || httpMessage.data.data.transaction_status == 3) {
|
||||||
|
self.enableTransactionButtons();
|
||||||
|
} else {
|
||||||
|
self.disableTransactionButtons();
|
||||||
|
}
|
||||||
|
|
||||||
if (ExecuteQuery.isQueryFinished(httpMessage)) {
|
if (ExecuteQuery.isQueryFinished(httpMessage)) {
|
||||||
self.loadingScreen.setMessage('Loading data from the database server and rendering...');
|
self.loadingScreen.setMessage('Loading data from the database server and rendering...');
|
||||||
|
|
||||||
@@ -184,6 +197,7 @@ class ExecuteQuery {
|
|||||||
this.sqlServerObject.rows_affected = 0;
|
this.sqlServerObject.rows_affected = 0;
|
||||||
this.sqlServerObject._init_polling_flags();
|
this.sqlServerObject._init_polling_flags();
|
||||||
this.disableSQLEditorButtons();
|
this.disableSQLEditorButtons();
|
||||||
|
this.disableTransactionButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
static prepareAnalyzeSql(sqlStatement, analyzeSql) {
|
static prepareAnalyzeSql(sqlStatement, analyzeSql) {
|
||||||
@@ -247,6 +261,15 @@ class ExecuteQuery {
|
|||||||
this.sqlServerObject.disable_tool_buttons(true);
|
this.sqlServerObject.disable_tool_buttons(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enableTransactionButtons() {
|
||||||
|
this.sqlServerObject.disable_transaction_buttons(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
disableTransactionButtons() {
|
||||||
|
this.sqlServerObject.special_sql = undefined;
|
||||||
|
this.sqlServerObject.disable_transaction_buttons(true);
|
||||||
|
}
|
||||||
|
|
||||||
static wasConnectionLostToPythonServer(httpResponse) {
|
static wasConnectionLostToPythonServer(httpResponse) {
|
||||||
return _.isUndefined(httpResponse) || _.isUndefined(httpResponse.data);
|
return _.isUndefined(httpResponse) || _.isUndefined(httpResponse.data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,6 +141,18 @@ let queryToolActions = {
|
|||||||
codeMirrorObj.replaceSelection(selectedText.toUpperCase());
|
codeMirrorObj.replaceSelection(selectedText.toUpperCase());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
executeCommit: function (sqlEditorController) {
|
||||||
|
var self = this;
|
||||||
|
sqlEditorController.special_sql = 'COMMIT;';
|
||||||
|
self.executeQuery(sqlEditorController);
|
||||||
|
},
|
||||||
|
|
||||||
|
executeRollback: function (sqlEditorController) {
|
||||||
|
var self = this;
|
||||||
|
sqlEditorController.special_sql = 'ROLLBACK;';
|
||||||
|
self.executeQuery(sqlEditorController);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = queryToolActions;
|
module.exports = queryToolActions;
|
||||||
@@ -97,6 +97,14 @@ function updateUIPreferences(sqlEditor) {
|
|||||||
.attr('title',
|
.attr('title',
|
||||||
shortcut_title('Download as CSV',preferences.download_csv));
|
shortcut_title('Download as CSV',preferences.download_csv));
|
||||||
|
|
||||||
|
$el.find('#btn-commit')
|
||||||
|
.attr('title',
|
||||||
|
shortcut_title('Commit',preferences.commit_transaction));
|
||||||
|
|
||||||
|
$el.find('#btn-rollback')
|
||||||
|
.attr('title',
|
||||||
|
shortcut_title('Rollback',preferences.rollback_transaction));
|
||||||
|
|
||||||
/* Set Auto-commit and auto-rollback on query editor */
|
/* Set Auto-commit and auto-rollback on query editor */
|
||||||
if (preferences.auto_commit) {
|
if (preferences.auto_commit) {
|
||||||
$el.find('.auto-commit').removeClass('visibility-hidden');
|
$el.find('.auto-commit').removeClass('visibility-hidden');
|
||||||
|
|||||||
@@ -218,7 +218,7 @@
|
|||||||
tabindex="0" disabled >
|
tabindex="0" disabled >
|
||||||
<i class="fa fa-stop sql-icon-lg" aria-hidden="true"></i>
|
<i class="fa fa-stop sql-icon-lg" aria-hidden="true"></i>
|
||||||
</button>
|
</button>
|
||||||
<button id="btn-flash" data-test-selector="execute-refresh-button" type="button" class="btn btn-sm btn-secondary" style="width: 40px;"
|
<button id="btn-flash" data-test-selector="execute-refresh-button" type="button" class="btn btn-sm btn-secondary" style="width: 32px;"
|
||||||
title=""
|
title=""
|
||||||
tabindex="0">
|
tabindex="0">
|
||||||
<i class="fa fa-bolt sql-icon-lg" aria-hidden="true"></i>
|
<i class="fa fa-bolt sql-icon-lg" aria-hidden="true"></i>
|
||||||
@@ -287,6 +287,19 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="btn-group mr-1" role="group" aria-label="">
|
||||||
|
<button id="btn-commit" type="button" class="btn btn-sm btn-secondary"
|
||||||
|
title=""
|
||||||
|
accesskey=""
|
||||||
|
tabindex="0" disabled>
|
||||||
|
<i class="icon-commit sql-icon-lg" aria-hidden="true"></i>
|
||||||
|
</button>
|
||||||
|
<button id="btn-rollback" type="button" class="btn btn-sm btn-secondary"
|
||||||
|
title=""
|
||||||
|
tabindex="0" disabled>
|
||||||
|
<i class="icon-rollback sql-icon-lg" aria-hidden="true"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div class="btn-group mr-1" role="group" aria-label="">
|
<div class="btn-group mr-1" role="group" aria-label="">
|
||||||
<button id="btn-clear-dropdown" type="button" class="btn btn-sm btn-secondary dropdown-toggle"
|
<button id="btn-clear-dropdown" type="button" class="btn btn-sm btn-secondary dropdown-toggle"
|
||||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
|
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
|
||||||
|
|||||||
@@ -584,6 +584,7 @@ def poll(trans_id):
|
|||||||
result is not None and additional_messages:
|
result is not None and additional_messages:
|
||||||
result = additional_messages + result
|
result = additional_messages + result
|
||||||
|
|
||||||
|
transaction_status = conn.transaction_status()
|
||||||
return make_json_response(
|
return make_json_response(
|
||||||
data={
|
data={
|
||||||
'status': status, 'result': result,
|
'status': status, 'result': result,
|
||||||
@@ -598,7 +599,8 @@ def poll(trans_id):
|
|||||||
'types': types,
|
'types': types,
|
||||||
'client_primary_key': client_primary_key,
|
'client_primary_key': client_primary_key,
|
||||||
'has_oids': has_oids,
|
'has_oids': has_oids,
|
||||||
'oids': oids
|
'oids': oids,
|
||||||
|
'transaction_status': transaction_status,
|
||||||
},
|
},
|
||||||
encoding=conn.python_encoding
|
encoding=conn.python_encoding
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -297,6 +297,26 @@ input.editor-checkbox:focus {
|
|||||||
background-image: url('../img/disconnect.svg');
|
background-image: url('../img/disconnect.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-commit, .icon-rollback {
|
||||||
|
display: inline-block;
|
||||||
|
align-content: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
height: 18px;
|
||||||
|
width: 18px;
|
||||||
|
background-size: 22px !important;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position-x: center;
|
||||||
|
background-position-y: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-commit {
|
||||||
|
background-image: url('../img/commit.svg') !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-rollback {
|
||||||
|
background-image: url('../img/rollback.svg') !important;
|
||||||
|
}
|
||||||
|
|
||||||
.ajs-body .warn-header {
|
.ajs-body .warn-header {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><defs><style>.cls-1{fill:#222222;}</style></defs><title>commit</title><path class="cls-1" d="M51.89,28.51a21.22,21.22,0,0,0-6.3-2.1,45.22,45.22,0,0,0-8.67-.78,45.12,45.12,0,0,0-8.66.78,21.22,21.22,0,0,0-6.3,2.1c-1.54.89-2.32,1.85-2.32,2.88v2.88c0,1,.78,2,2.32,2.88a20.92,20.92,0,0,0,6.3,2.11,46,46,0,0,0,8.66.77,46.07,46.07,0,0,0,8.67-.77,20.92,20.92,0,0,0,6.3-2.11q2.31-1.32,2.31-2.88V31.39Q54.2,29.85,51.89,28.51Z"/><path class="cls-1" d="M36.92,51.56a49.08,49.08,0,0,1-10-1,19.79,19.79,0,0,1-7.32-2.86v3.82c0,1,.78,2,2.32,2.88a20.92,20.92,0,0,0,6.3,2.11,46,46,0,0,0,8.66.77,46.07,46.07,0,0,0,8.67-.77,20.92,20.92,0,0,0,6.3-2.11q2.31-1.32,2.31-2.88V47.74a19.67,19.67,0,0,1-7.31,2.86A49.11,49.11,0,0,1,36.92,51.56Z"/><path class="cls-1" d="M36.92,42.92a49.08,49.08,0,0,1-10-1,19.79,19.79,0,0,1-7.32-2.86v3.82c0,1,.78,2,2.32,2.88a20.92,20.92,0,0,0,6.3,2.11,46,46,0,0,0,8.66.77,46.07,46.07,0,0,0,8.67-.77,20.92,20.92,0,0,0,6.3-2.11q2.31-1.32,2.31-2.88V39.1A19.67,19.67,0,0,1,46.89,42,49.11,49.11,0,0,1,36.92,42.92Z"/><path class="cls-1" d="M25.67,12.44a11.28,11.28,0,0,1,4.23.8,11.13,11.13,0,0,1,3.6,2.28l-3.08,3.1a1.29,1.29,0,0,0-.31,1.56,1.33,1.33,0,0,0,1.32.9H41.51a1.43,1.43,0,0,0,1-.43,1.4,1.4,0,0,0,.42-1V9.56a1.34,1.34,0,0,0-.9-1.33,1.28,1.28,0,0,0-1.55.31l-2.92,2.91a17.34,17.34,0,0,0-5.51-3.52A17,17,0,0,0,19,8.05a19.15,19.15,0,0,0-3,1.6h0c-.43.3-.85.61-1.25.94l-.4.34h0a16.91,16.91,0,0,0-4.49,6,.8.8,0,0,0,0,.53.65.65,0,0,0,.31.39L14,20a.82.82,0,0,0,.6.05.72.72,0,0,0,.42-.4,11.46,11.46,0,0,1,1.12-2.11h0l.39-.54.24-.3c.18-.22.37-.44.57-.65L17.4,16l.45-.44.09-.09c.16-.15.33-.29.5-.43l.27-.2.21-.16a11.84,11.84,0,0,1,2.29-1.28A11.12,11.12,0,0,1,25.67,12.44Z"/></svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><defs><style>.cls-1{fill:#222222;}</style></defs><title>rollback</title><path class="cls-1" d="M53.89,28.51a21.22,21.22,0,0,0-6.3-2.1,45.22,45.22,0,0,0-8.67-.78,45.12,45.12,0,0,0-8.66.78,21.22,21.22,0,0,0-6.3,2.1c-1.54.89-2.32,1.85-2.32,2.88v2.88c0,1,.78,2,2.32,2.88a20.92,20.92,0,0,0,6.3,2.11,46,46,0,0,0,8.66.77,46.07,46.07,0,0,0,8.67-.77,20.92,20.92,0,0,0,6.3-2.11q2.31-1.32,2.31-2.88V31.39Q56.2,29.85,53.89,28.51Z"/><path class="cls-1" d="M38.92,51.56a49.08,49.08,0,0,1-10-1,19.79,19.79,0,0,1-7.32-2.86v3.82c0,1,.78,2,2.32,2.88a20.92,20.92,0,0,0,6.3,2.11,46,46,0,0,0,8.66.77,46.07,46.07,0,0,0,8.67-.77,20.92,20.92,0,0,0,6.3-2.11q2.31-1.32,2.31-2.88V47.74a19.67,19.67,0,0,1-7.31,2.86A49.11,49.11,0,0,1,38.92,51.56Z"/><path class="cls-1" d="M38.92,42.92a49.08,49.08,0,0,1-10-1,19.79,19.79,0,0,1-7.32-2.86v3.82c0,1,.78,2,2.32,2.88a20.92,20.92,0,0,0,6.3,2.11,46,46,0,0,0,8.66.77,46.07,46.07,0,0,0,8.67-.77,20.92,20.92,0,0,0,6.3-2.11q2.31-1.32,2.31-2.88V39.1A19.67,19.67,0,0,1,48.89,42,49.11,49.11,0,0,1,38.92,42.92Z"/><path class="cls-1" d="M25.08,12.44a11.28,11.28,0,0,0-4.23.8,11.13,11.13,0,0,0-3.6,2.28l3.08,3.1a1.29,1.29,0,0,1,.31,1.56,1.33,1.33,0,0,1-1.32.9H9.24a1.43,1.43,0,0,1-1-.43,1.4,1.4,0,0,1-.42-1V9.56a1.34,1.34,0,0,1,.9-1.33,1.28,1.28,0,0,1,1.55.31l2.92,2.91a17.34,17.34,0,0,1,5.51-3.52,17,17,0,0,1,13.1.12,19.15,19.15,0,0,1,3,1.6h0c.43.3.85.61,1.25.94l.4.34h0a16.91,16.91,0,0,1,4.49,6,.8.8,0,0,1,0,.53.65.65,0,0,1-.31.39L36.8,20a.82.82,0,0,1-.6.05.72.72,0,0,1-.42-.4,11.46,11.46,0,0,0-1.12-2.11h0q-.19-.28-.39-.54l-.24-.3c-.18-.22-.37-.44-.57-.65L33.35,16l-.45-.44-.09-.09c-.16-.15-.33-.29-.5-.43l-.27-.2-.21-.16a11.84,11.84,0,0,0-2.29-1.28A11.12,11.12,0,0,0,25.08,12.44Z"/></svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -124,6 +124,8 @@ define('tools.querytool', [
|
|||||||
// Indentation options
|
// Indentation options
|
||||||
'click #btn-indent-code': 'on_indent_code',
|
'click #btn-indent-code': 'on_indent_code',
|
||||||
'click #btn-unindent-code': 'on_unindent_code',
|
'click #btn-unindent-code': 'on_unindent_code',
|
||||||
|
'click #btn-commit': 'on_commit_transaction',
|
||||||
|
'click #btn-rollback': 'on_rollback_transaction',
|
||||||
},
|
},
|
||||||
|
|
||||||
reflectPreferences: function() {
|
reflectPreferences: function() {
|
||||||
@@ -1782,6 +1784,15 @@ define('tools.querytool', [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// Callback function for the commit button click.
|
||||||
|
on_commit_transaction: function() {
|
||||||
|
queryToolActions.executeCommit(this.handler);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Callback function for the rollback button click.
|
||||||
|
on_rollback_transaction: function() {
|
||||||
|
queryToolActions.executeRollback(this.handler);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Defining controller class for data grid, which actually
|
/* Defining controller class for data grid, which actually
|
||||||
@@ -3411,6 +3422,15 @@ define('tools.querytool', [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// This function is used to enable/disable commit/rollback buttons
|
||||||
|
disable_transaction_buttons: function(disabled) {
|
||||||
|
this.is_transaction_buttons_disabled = disabled;
|
||||||
|
if (this.is_query_tool) {
|
||||||
|
$('#btn-commit').prop('disabled', disabled);
|
||||||
|
$('#btn-rollback').prop('disabled', disabled);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// This function will fetch the sql query from the text box
|
// This function will fetch the sql query from the text box
|
||||||
// and execute the query.
|
// and execute the query.
|
||||||
execute: function(explain_prefix, shouldReconnect=false) {
|
execute: function(explain_prefix, shouldReconnect=false) {
|
||||||
@@ -3420,6 +3440,9 @@ define('tools.querytool', [
|
|||||||
self.has_more_rows = false;
|
self.has_more_rows = false;
|
||||||
self.fetching_rows = false;
|
self.fetching_rows = false;
|
||||||
|
|
||||||
|
if (!_.isUndefined(self.special_sql)) {
|
||||||
|
sql = self.special_sql;
|
||||||
|
} else {
|
||||||
/* If code is selected in the code mirror then execute
|
/* If code is selected in the code mirror then execute
|
||||||
* the selected part else execute the complete code.
|
* the selected part else execute the complete code.
|
||||||
*/
|
*/
|
||||||
@@ -3428,6 +3451,7 @@ define('tools.querytool', [
|
|||||||
sql = selected_code;
|
sql = selected_code;
|
||||||
else
|
else
|
||||||
sql = self.gridView.query_tool_obj.getValue();
|
sql = self.gridView.query_tool_obj.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
const executeQuery = new ExecuteQuery.ExecuteQuery(this, pgAdmin.Browser.UserManagement);
|
const executeQuery = new ExecuteQuery.ExecuteQuery(this, pgAdmin.Browser.UserManagement);
|
||||||
executeQuery.execute(sql, explain_prefix, shouldReconnect);
|
executeQuery.execute(sql, explain_prefix, shouldReconnect);
|
||||||
|
|||||||
@@ -571,3 +571,39 @@ def RegisterQueryToolPreferences(self):
|
|||||||
help_str=gettext('If set to True, Keywords will be displayed '
|
help_str=gettext('If set to True, Keywords will be displayed '
|
||||||
'in upper case for auto completion.')
|
'in upper case for auto completion.')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.preference.register(
|
||||||
|
'keyboard_shortcuts',
|
||||||
|
'commit_transaction',
|
||||||
|
gettext('Commit'),
|
||||||
|
'keyboardshortcut',
|
||||||
|
{
|
||||||
|
'alt': False,
|
||||||
|
'shift': True,
|
||||||
|
'control': True,
|
||||||
|
'key': {
|
||||||
|
'key_code': 77,
|
||||||
|
'char': 'm'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
category_label=gettext('Keyboard shortcuts'),
|
||||||
|
fields=shortcut_fields
|
||||||
|
)
|
||||||
|
|
||||||
|
self.preference.register(
|
||||||
|
'keyboard_shortcuts',
|
||||||
|
'rollback_transaction',
|
||||||
|
gettext('Rollback'),
|
||||||
|
'keyboardshortcut',
|
||||||
|
{
|
||||||
|
'alt': False,
|
||||||
|
'shift': True,
|
||||||
|
'control': True,
|
||||||
|
'key': {
|
||||||
|
'key_code': 82,
|
||||||
|
'char': 'r'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
category_label=gettext('Keyboard shortcuts'),
|
||||||
|
fields=shortcut_fields
|
||||||
|
)
|
||||||
@@ -48,6 +48,7 @@ class StartRunningQuery:
|
|||||||
can_edit = False
|
can_edit = False
|
||||||
can_filter = False
|
can_filter = False
|
||||||
notifies = None
|
notifies = None
|
||||||
|
trans_status = None
|
||||||
if transaction_object is not None and session_obj is not None:
|
if transaction_object is not None and session_obj is not None:
|
||||||
# set fetched row count to 0 as we are executing query again.
|
# set fetched row count to 0 as we are executing query again.
|
||||||
transaction_object.update_fetched_row_cnt(0)
|
transaction_object.update_fetched_row_cnt(0)
|
||||||
@@ -91,6 +92,7 @@ class StartRunningQuery:
|
|||||||
|
|
||||||
# Get the notifies
|
# Get the notifies
|
||||||
notifies = conn.get_notifies()
|
notifies = conn.get_notifies()
|
||||||
|
trans_status = conn.transaction_status()
|
||||||
else:
|
else:
|
||||||
status = False
|
status = False
|
||||||
result = gettext(
|
result = gettext(
|
||||||
@@ -101,7 +103,8 @@ class StartRunningQuery:
|
|||||||
'can_edit': can_edit, 'can_filter': can_filter,
|
'can_edit': can_edit, 'can_filter': can_filter,
|
||||||
'info_notifier_timeout':
|
'info_notifier_timeout':
|
||||||
self.blueprint_object.info_notifier_timeout.get(),
|
self.blueprint_object.info_notifier_timeout.get(),
|
||||||
'notifies': notifies
|
'notifies': notifies,
|
||||||
|
'transaction_status': trans_status,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,8 @@ class StartRunningQueryTest(BaseTestGenerator):
|
|||||||
can_edit=False,
|
can_edit=False,
|
||||||
can_filter=False,
|
can_filter=False,
|
||||||
info_notifier_timeout=5,
|
info_notifier_timeout=5,
|
||||||
notifies=None
|
notifies=None,
|
||||||
|
transaction_status=None
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
expect_internal_server_error_called_with=None,
|
expect_internal_server_error_called_with=None,
|
||||||
@@ -278,7 +279,8 @@ class StartRunningQueryTest(BaseTestGenerator):
|
|||||||
can_edit=True,
|
can_edit=True,
|
||||||
can_filter=True,
|
can_filter=True,
|
||||||
info_notifier_timeout=5,
|
info_notifier_timeout=5,
|
||||||
notifies=None
|
notifies=None,
|
||||||
|
transaction_status=None
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
expect_internal_server_error_called_with=None,
|
expect_internal_server_error_called_with=None,
|
||||||
@@ -322,7 +324,8 @@ class StartRunningQueryTest(BaseTestGenerator):
|
|||||||
can_edit=True,
|
can_edit=True,
|
||||||
can_filter=True,
|
can_filter=True,
|
||||||
info_notifier_timeout=5,
|
info_notifier_timeout=5,
|
||||||
notifies=None
|
notifies=None,
|
||||||
|
transaction_status=None
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
expect_internal_server_error_called_with=None,
|
expect_internal_server_error_called_with=None,
|
||||||
@@ -366,7 +369,8 @@ class StartRunningQueryTest(BaseTestGenerator):
|
|||||||
can_edit=True,
|
can_edit=True,
|
||||||
can_filter=True,
|
can_filter=True,
|
||||||
info_notifier_timeout=5,
|
info_notifier_timeout=5,
|
||||||
notifies=None
|
notifies=None,
|
||||||
|
transaction_status=None
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
expect_internal_server_error_called_with=None,
|
expect_internal_server_error_called_with=None,
|
||||||
@@ -411,7 +415,8 @@ class StartRunningQueryTest(BaseTestGenerator):
|
|||||||
can_edit=True,
|
can_edit=True,
|
||||||
can_filter=True,
|
can_filter=True,
|
||||||
info_notifier_timeout=5,
|
info_notifier_timeout=5,
|
||||||
notifies=None
|
notifies=None,
|
||||||
|
transaction_status=None
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
expect_internal_server_error_called_with=None,
|
expect_internal_server_error_called_with=None,
|
||||||
@@ -517,9 +522,11 @@ class StartRunningQueryTest(BaseTestGenerator):
|
|||||||
execute_async=MagicMock(),
|
execute_async=MagicMock(),
|
||||||
execute_void=MagicMock(),
|
execute_void=MagicMock(),
|
||||||
get_notifies=MagicMock(),
|
get_notifies=MagicMock(),
|
||||||
|
transaction_status=MagicMock(),
|
||||||
)
|
)
|
||||||
self.connection.connect.return_value = self.connection_connect_return
|
self.connection.connect.return_value = self.connection_connect_return
|
||||||
self.connection.get_notifies.return_value = None
|
self.connection.get_notifies.return_value = None
|
||||||
|
self.connection.transaction_status.return_value = None
|
||||||
self.connection.execute_async.return_value = \
|
self.connection.execute_async.return_value = \
|
||||||
self.execute_async_return_value
|
self.execute_async_return_value
|
||||||
if self.manager_connection_exception is None:
|
if self.manager_connection_exception is None:
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ describe('#callRenderAfterPoll', () => {
|
|||||||
trigger: jasmine.createSpy('SQLEditor.trigger'),
|
trigger: jasmine.createSpy('SQLEditor.trigger'),
|
||||||
update_msg_history: jasmine.createSpy('SQLEditor.update_msg_history'),
|
update_msg_history: jasmine.createSpy('SQLEditor.update_msg_history'),
|
||||||
disable_tool_buttons: jasmine.createSpy('SQLEditor.disable_tool_buttons'),
|
disable_tool_buttons: jasmine.createSpy('SQLEditor.disable_tool_buttons'),
|
||||||
|
disable_transaction_buttons: jasmine.createSpy('SQLEditor.disable_transaction_buttons'),
|
||||||
query_start_time: new Date(),
|
query_start_time: new Date(),
|
||||||
};
|
};
|
||||||
alertify = jasmine.createSpyObj('alertify', ['success']);
|
alertify = jasmine.createSpyObj('alertify', ['success']);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ describe('ExecuteQuery', () => {
|
|||||||
'initTransaction',
|
'initTransaction',
|
||||||
'handle_connection_lost',
|
'handle_connection_lost',
|
||||||
'update_notifications',
|
'update_notifications',
|
||||||
|
'disable_transaction_buttons',
|
||||||
]);
|
]);
|
||||||
sqlEditorMock.transId = 123;
|
sqlEditorMock.transId = 123;
|
||||||
sqlEditorMock.rows_affected = 1000;
|
sqlEditorMock.rows_affected = 1000;
|
||||||
@@ -112,6 +113,46 @@ describe('ExecuteQuery', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when query was successful but in transaction block', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
response = {
|
||||||
|
data: {status: 'Success', notifies: [{'pid': 100}], transaction_status: 2},
|
||||||
|
};
|
||||||
|
networkMock.onGet('/sqleditor/query_tool/poll/123').reply(200, response);
|
||||||
|
|
||||||
|
executeQuery.poll();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('enable the transaction buttons', (done) => {
|
||||||
|
setTimeout(
|
||||||
|
() => {
|
||||||
|
expect(sqlEditorMock.disable_transaction_buttons)
|
||||||
|
.toHaveBeenCalledWith(false);
|
||||||
|
done();
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when query was successful but not in transaction block', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
response = {
|
||||||
|
data: {status: 'Success', notifies: [{'pid': 100}], transaction_status: 0},
|
||||||
|
};
|
||||||
|
networkMock.onGet('/sqleditor/query_tool/poll/123').reply(200, response);
|
||||||
|
|
||||||
|
executeQuery.poll();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('disable the transaction buttons', (done) => {
|
||||||
|
setTimeout(
|
||||||
|
() => {
|
||||||
|
expect(sqlEditorMock.disable_transaction_buttons)
|
||||||
|
.toHaveBeenCalledWith(true);
|
||||||
|
done();
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when query is still running', () => {
|
describe('when query is still running', () => {
|
||||||
context('when no additional information is returned', () => {
|
context('when no additional information is returned', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|||||||
@@ -93,6 +93,22 @@ describe('the keyboard shortcuts', () => {
|
|||||||
key_code: null,
|
key_code: null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
commit_transaction: {
|
||||||
|
alt: false,
|
||||||
|
shift: true,
|
||||||
|
control: true,
|
||||||
|
key: {
|
||||||
|
key_code: 'm',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rollback_transaction: {
|
||||||
|
alt: false,
|
||||||
|
shift: true,
|
||||||
|
control: true,
|
||||||
|
key: {
|
||||||
|
key_code: 'r',
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
queryToolActionsSpy = jasmine.createSpyObj(queryToolActions, [
|
queryToolActionsSpy = jasmine.createSpyObj(queryToolActions, [
|
||||||
@@ -103,6 +119,8 @@ describe('the keyboard shortcuts', () => {
|
|||||||
'commentLineCode',
|
'commentLineCode',
|
||||||
'uncommentLineCode',
|
'uncommentLineCode',
|
||||||
'executeQuery',
|
'executeQuery',
|
||||||
|
'executeCommit',
|
||||||
|
'executeRollback',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -521,6 +539,80 @@ describe('the keyboard shortcuts', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Shift+Ctrl+C', () => {
|
||||||
|
describe('when there is not a query already running', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
event.shiftKey = true;
|
||||||
|
event.which = 'm';
|
||||||
|
event.altKey = false;
|
||||||
|
event.ctrlKey = true;
|
||||||
|
keyboardShortcuts.processEventQueryTool(
|
||||||
|
sqlEditorControllerSpy, queryToolActionsSpy, event
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should commit the transaction', () => {
|
||||||
|
expect(queryToolActionsSpy.executeCommit).toHaveBeenCalledWith(sqlEditorControllerSpy);
|
||||||
|
});
|
||||||
|
|
||||||
|
expectEventPropagationToStop();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the query is already running', () => {
|
||||||
|
it('does nothing', () => {
|
||||||
|
event.shiftKey = true;
|
||||||
|
event.which = 'm';
|
||||||
|
event.altKey = false;
|
||||||
|
event.ctrlKey = true;
|
||||||
|
|
||||||
|
sqlEditorControllerSpy.isQueryRunning.and.returnValue(true);
|
||||||
|
|
||||||
|
keyboardShortcuts.processEventQueryTool(
|
||||||
|
sqlEditorControllerSpy, queryToolActionsSpy, event
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(queryToolActionsSpy.executeCommit).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Shift+Ctrl+R', () => {
|
||||||
|
describe('when there is not a query already running', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
event.shiftKey = true;
|
||||||
|
event.which = 'r';
|
||||||
|
event.altKey = false;
|
||||||
|
event.ctrlKey = true;
|
||||||
|
keyboardShortcuts.processEventQueryTool(
|
||||||
|
sqlEditorControllerSpy, queryToolActionsSpy, event
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should rollback the transaction', () => {
|
||||||
|
expect(queryToolActionsSpy.executeRollback).toHaveBeenCalledWith(sqlEditorControllerSpy);
|
||||||
|
});
|
||||||
|
|
||||||
|
expectEventPropagationToStop();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the query is already running', () => {
|
||||||
|
it('does nothing', () => {
|
||||||
|
event.shiftKey = true;
|
||||||
|
event.which = 'r';
|
||||||
|
event.altKey = false;
|
||||||
|
event.ctrlKey = true;
|
||||||
|
|
||||||
|
sqlEditorControllerSpy.isQueryRunning.and.returnValue(true);
|
||||||
|
|
||||||
|
keyboardShortcuts.processEventQueryTool(
|
||||||
|
sqlEditorControllerSpy, queryToolActionsSpy, event
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(queryToolActionsSpy.executeRollback).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function expectEventPropagationToStop() {
|
function expectEventPropagationToStop() {
|
||||||
describe('stops all event propogation', () => {
|
describe('stops all event propogation', () => {
|
||||||
|
|
||||||
|
|||||||
@@ -521,6 +521,32 @@ describe('queryToolActions', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('executeCommit', () => {
|
||||||
|
describe('when commit action is being run from the query tool', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
setUpSpies('', '');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('calls the execute commit function', () => {
|
||||||
|
queryToolActions.executeCommit(sqlEditorController);
|
||||||
|
expect(sqlEditorController.special_sql).toEqual('COMMIT;');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('executeRollback', () => {
|
||||||
|
describe('when rollback action is being run from the query tool', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
setUpSpies('', '');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('calls the execute rollback function', () => {
|
||||||
|
queryToolActions.executeRollback(sqlEditorController);
|
||||||
|
expect(sqlEditorController.special_sql).toEqual('ROLLBACK;');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function setUpSpies(selectedQueryString, entireQueryString) {
|
function setUpSpies(selectedQueryString, entireQueryString) {
|
||||||
getValueSpy = jasmine.createSpy('getValueSpy').and.returnValue(entireQueryString);
|
getValueSpy = jasmine.createSpy('getValueSpy').and.returnValue(entireQueryString);
|
||||||
getSelectionSpy = jasmine.createSpy('getSelectionSpy').and.returnValue(selectedQueryString);
|
getSelectionSpy = jasmine.createSpy('getSelectionSpy').and.returnValue(selectedQueryString);
|
||||||
|
|||||||
Reference in new issue
Block a user