Added support to launch PSQL for the connected database server. Fixes #2341

This commit is contained in:
Nikhil Mohite
2021-05-25 20:12:57 +05:30
committed by Akshay Joshi
parent 37dece2cd8
commit 3ddf941cd7
53 changed files with 2267 additions and 27 deletions

View File

@@ -64,6 +64,14 @@ define([
priority: 997, label: gettext('Search Objects...'),
icon: 'fa fa-search',
}]);
// show psql tool same as query tool.
pgAdmin.Browser.add_menus([{
name: 'show_psql_tool', node: this.type, module: this,
applies: ['context'], callback: 'show_psql_tool',
priority: 998, label: gettext('PSQL Tool (Beta)'),
icon: 'fas fa-terminal',
}]);
}
}
},
@@ -498,6 +506,13 @@ define([
pgAdmin.SearchObjects.show_search_objects('', pgAdmin.Browser.tree.selected());
}
},
show_psql_tool: function(args) {
var input = args || {},
t = pgBrowser.tree,
i = input.item || t.selected(),
d = i && i.length == 1 ? t.itemData(i) : undefined;
pgBrowser.psql.psql_tool(d, i, true);
},
});
return pgBrowser.Collection;

View File

@@ -209,6 +209,16 @@ define('pgadmin.browser.node', [
priority: 997, label: gettext('Search Objects...'),
icon: 'fa fa-search', enable: enable,
}]);
if(pgAdmin['enable_psql']) {
// show psql tool same as query tool.
pgAdmin.Browser.add_menus([{
name: 'show_psql_tool', node: this.type, module: this,
applies: ['context'], callback: 'show_psql_tool',
priority: 998, label: gettext('PSQL Tool (Beta)'),
icon: 'fas fa-terminal',
}]);
}
}
// This will add options of scripts eg:'CREATE Script'
@@ -903,6 +913,15 @@ define('pgadmin.browser.node', [
pgAdmin.DataGrid.show_query_tool('', i);
},
// Callback to render psql tool.
show_psql_tool: function(args) {
var input = args || {},
t = pgBrowser.tree,
i = input.item || t.selected(),
d = i && i.length == 1 ? t.itemData(i) : undefined;
pgBrowser.psql.psql_tool(d, i, true);
},
// Logic to change the server background colour
// There is no way of applying CSS to parent element so we have to
// do it via JS code only

View File

@@ -56,9 +56,23 @@ let _defaultToolBarButtons = [
toggleClass: '',
parentClass: 'pg-toolbar-btn btn-primary-icon',
enabled: false,
},
}
];
if(pgAdmin['enable_psql']) {
_defaultToolBarButtons.push({
label: gettext('PSQL Tool'),
ariaLabel: gettext('PSQL Tool'),
btnClass: 'fas fa-terminal',
text: '',
toggled: false,
toggleClass: '',
parentClass: 'pg-toolbar-btn btn-primary-icon pg-toolbar-psql',
enabled: false,
});
}
// Place holder for non default tool bar buttons.
let _otherToolbarButtons = [];
@@ -105,6 +119,13 @@ export function initializeToolbar(panel, wcDocker) {
pgAdmin.DataGrid.show_filtered_row({mnuid: 4}, pgAdmin.Browser.tree.selected());
else if ('name' in data && data.name === gettext('Search objects'))
pgAdmin.SearchObjects.show_search_objects('', pgAdmin.Browser.tree.selected());
else if ('name' in data && data.name === gettext('PSQL Tool')){
var input = {},
t = pgAdmin.Browser.tree,
i = input.item || t.selected(),
d = i && i.length == 1 ? t.itemData(i) : undefined;
pgAdmin.Browser.psql.psql_tool(d, i, true);
}
});
}

View File

@@ -53,3 +53,9 @@ samp,
border-width: 1px;
font-size: 1.15em;
}
.pg-toolbar-psql {
padding-top: 0em;
font-size: inherit;
align-items: center;
}