diff --git a/web/pgadmin/static/js/keyboard_shortcuts.js b/web/pgadmin/static/js/keyboard_shortcuts.js
index a5c8e13..0cce737 100644
--- a/web/pgadmin/static/js/keyboard_shortcuts.js
+++ b/web/pgadmin/static/js/keyboard_shortcuts.js
@@ -181,6 +181,8 @@ function keyboardShortcutsQueryTool(
let nextPanelKeys = sqlEditorController.preferences.move_next;
let previousPanelKeys = sqlEditorController.preferences.move_previous;
let toggleCaseKeys = sqlEditorController.preferences.toggle_case;
+ let commitKeys = sqlEditorController.preferences.commit_transaction;
+ let rollbackKeys = sqlEditorController.preferences.rollback_transaction;
if (this.validateShortcutKeys(executeKeys, event)) {
this._stopEventPropagation(event);
@@ -197,6 +199,12 @@ function keyboardShortcutsQueryTool(
} else if (this.validateShortcutKeys(toggleCaseKeys, event)) {
this._stopEventPropagation(event);
queryToolActions.toggleCaseOfSelectedText(sqlEditorController);
+ } else if (this.validateShortcutKeys(commitKeys, event)) {
+ this._stopEventPropagation(event);
+ queryToolActions.executeCommit(sqlEditorController);
+ } else if (this.validateShortcutKeys(rollbackKeys, event)) {
+ this._stopEventPropagation(event);
+ queryToolActions.executeRollback(sqlEditorController);
} else if ((
(this.isMac() && event.metaKey) ||
(!this.isMac() && event.ctrlKey)
diff --git a/web/pgadmin/static/js/sqleditor/execute_query.js b/web/pgadmin/static/js/sqleditor/execute_query.js
index 5542177..96fa0b1 100644
--- a/web/pgadmin/static/js/sqleditor/execute_query.js
+++ b/web/pgadmin/static/js/sqleditor/execute_query.js
@@ -81,6 +81,12 @@ class ExecuteQuery {
} else {
self.loadingScreen.hide();
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);
if ('notifies' in httpMessageData.data)
self.sqlServerObject.update_notifications(httpMessageData.data.notifies);
@@ -114,6 +120,13 @@ class ExecuteQuery {
})
).then(
(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)) {
self.loadingScreen.setMessage('Loading data from the database server and rendering...');
@@ -246,6 +259,15 @@ class ExecuteQuery {
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) {
return _.isUndefined(httpResponse) || _.isUndefined(httpResponse.data);
}
diff --git a/web/pgadmin/static/js/sqleditor/query_tool_actions.js b/web/pgadmin/static/js/sqleditor/query_tool_actions.js
index f82ed9d..7739e9b 100644
--- a/web/pgadmin/static/js/sqleditor/query_tool_actions.js
+++ b/web/pgadmin/static/js/sqleditor/query_tool_actions.js
@@ -141,6 +141,18 @@ let queryToolActions = {
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;
diff --git a/web/pgadmin/static/js/sqleditor/query_tool_preferences.js b/web/pgadmin/static/js/sqleditor/query_tool_preferences.js
index 5b63988..daeefad 100644
--- a/web/pgadmin/static/js/sqleditor/query_tool_preferences.js
+++ b/web/pgadmin/static/js/sqleditor/query_tool_preferences.js
@@ -97,6 +97,14 @@ function updateUIPreferences(sqlEditor) {
.attr('title',
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 */
if (preferences.auto_commit) {
$el.find('.auto-commit').removeClass('visibility-hidden');
diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
index 5dd0bdc..067cd7a 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
@@ -218,7 +218,7 @@
tabindex="0" disabled >
-