Enables pgAdmin to retrieve user permissions in case of nested roles which helps to terminate the session for AWS RDS. Fixes #6641

pull/57/head
Yogesh Mahajan 2021-08-24 17:01:06 +05:30 committed by Akshay Joshi
parent 008a458fe9
commit c7fd1ae535
4 changed files with 55 additions and 16 deletions

View File

@ -22,6 +22,7 @@ Bug fixes
| `Issue #6544 <https://redmine.postgresql.org/issues/6544>`_ - Fixed width limitation issue in PSQL tool window.
| `Issue #6564 <https://redmine.postgresql.org/issues/6564>`_ - Fixed an issue where columns with sequences get altered unnecessarily with a schema diff tool.
| `Issue #6572 <https://redmine.postgresql.org/issues/6572>`_ - Partially fixes the data output panel display issue.
| `Issue #6641 <https://redmine.postgresql.org/issues/6641>`_ - Enables pgAdmin to retrieve user permissions in case of nested roles which helps to terminate the session for AWS RDS.
| `Issue #6663 <https://redmine.postgresql.org/issues/6663>`_ - Fixed no attribute '_asdict' error when connecting the database server.
| `Issue #6671 <https://redmine.postgresql.org/issues/6671>`_ - Fixed UnboundLocalError where local variable 'user_id' referenced before assignment.
| `Issue #6682 <https://redmine.postgresql.org/issues/6682>`_ - Renamed 'Auto rollback?' to 'Auto rollback on error?'.

View File

@ -47,7 +47,7 @@ import Alertify from 'pgadmin.alertifyjs';
// return json editor element
function getJsonEditor() {
return $('<div id=\'pg-json-editor\' hidefocus\'>');
return $('<div id=\'pg-json-editor\' hidefocus>');
}
// Generate and return editor buttons
@ -396,7 +396,7 @@ import Alertify from 'pgadmin.alertifyjs';
var jsonContainer = document.getElementById('pg-json-editor');
var options = {
modes: ['code', 'form', 'tree','preview'],
onError: function (){ Alertify.alert(gettext('Please fix errors in json contents before switching mode.'));}
onError: function (){ Alertify.error(gettext('Please fix errors in json contents before switching mode.'));}
};
$editor = new JSONEditor(jsonContainer, options);
$editor.setText(data);
@ -415,7 +415,7 @@ import Alertify from 'pgadmin.alertifyjs';
var jsonContainer = document.getElementById('pg-json-editor');
var options = {
modes: ['code', 'form', 'tree','preview'],
onError: function (){Alertify.alert(gettext('Please fix errors in json contents before switching mode.'));}
onError: function (){Alertify.error(gettext('Please fix errors in json contents before switching mode.'));}
};
if(jsonContainer) {
$editor = new JSONEditor(jsonContainer, options);
@ -628,6 +628,7 @@ import Alertify from 'pgadmin.alertifyjs';
this.position = function(position) {
calculateEditorPosition(position, $wrapper);
position.top = Math.max(position.top, 0);
$wrapper
.css('top', position.top)
.css('left', position.left);
@ -645,26 +646,30 @@ import Alertify from 'pgadmin.alertifyjs';
this.loadValue = function(item) {
var data = defaultValue = item[args.column.field];
tmpdata = data;
if(args.column.column_type_internal === 'jsonb' && !Array.isArray(data)) {
data = JSONBigNumber.stringify(JSONBigNumber.parse(data), null, 4);
if(args.column.column_type_internal === 'jsonb' && !Array.isArray(data) && data != null) {
data = JSONBigNumber.stringify(JSONBigNumber.parse(data), null, 2);
} else if (Array.isArray(data)) {
var temp = [];
$.each(data, function(i, val) {
if (typeof val === 'object') {
temp.push(JSONBigNumber.stringify(val, null, 4));
temp.push(JSONBigNumber.stringify(val, null,2));
} else {
temp.push(val);
}
});
data = '[' + temp.join() + ']';
}
/* if data is string then convert to json*/
if (typeof data === 'string')
data = JSON.parse(data);
/* set editor content to empty if value is null*/
if (_.isNull(data)){
defaultValue = '';
data = '';
}
/* Create editor if required & set data*/
require.ensure(['jsoneditor'], function(require) {
var JSONEditor = require('jsoneditor');
var jsonContainer = document.getElementById('pg-json-editor');
jsonContainer.setAttribute('readonly', true);
let options = {
modes: ['code', 'form', 'tree', 'preview'],
onEditable: function() {
@ -673,7 +678,7 @@ import Alertify from 'pgadmin.alertifyjs';
};
if(jsonContainer) {
$editor = new JSONEditor(jsonContainer, options);
$editor.set(data);
$editor.setText(data);
}
}, function(error){
throw(error);

View File

@ -162,6 +162,11 @@ div.jsoneditor-tree button.jsoneditor-button:focus {
background-color: $color-bg;
}
/* Ace editor code background readonly*/
#pg-json-editor[readonly] .ace-jsoneditor .ace_scroller{
background-color: $color-gray-light;
opacity: $btn-disabled-opacity;
}
/* Ace editor hide indent guide */
.ace-jsoneditor .ace_indent-guide {
@ -188,7 +193,6 @@ div.jsoneditor-tree button.jsoneditor-button:focus {
background-color:$color-bg !important;
}
/* /* font setting all other mode */
/* form, tree, code, preview, schema-error */
div.jsoneditor-default,
@ -206,6 +210,19 @@ div.jsoneditor-tree{
background-color:$color-bg;
}
/* read only mode */
#pg-json-editor[readonly] {
& div.jsoneditor-tree,
& div.jsoneditor td,
& div.jsoneditor-readonly,
& div.jsoneditor-value,
& div.jsoneditor-field,
& div.jsoneditor-tree button.jsoneditor-button:focus {
background-color: $color-gray-light !important;
opacity: 0.85;
}
}
div.jsoneditor td.jsoneditor-tree {
vertical-align: middle;
}
@ -332,6 +349,19 @@ div.jsoneditor-value[contenteditable=true]:hover
color: $color-fg !important;
}
/* Replace help text */
.pico-modal-contents p{
visibility: hidden;
display: flex;
margin-bottom: -1rem;
}
.pico-modal-contents p::after{
visibility: visible;
position: absolute;
content: "Enter a JMESPath query to filter, sort, or transform the JSON data.";
display: block;
}
/* Fields */
.jsoneditor-modal,

View File

@ -605,11 +605,14 @@ WHERE db.datname = current_database()""")
can_create_role,
CASE WHEN roles.rolsuper THEN true
ELSE roles.rolcreatedb END as can_create_db,
CASE WHEN 'pg_signal_backend'=ANY(ARRAY(
SELECT pg_catalog.pg_roles.rolname FROM
pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles ON
(m.roleid = pg_catalog.pg_roles.oid) WHERE
m.member = roles.oid)) THEN True
CASE WHEN 'pg_signal_backend'=ANY(ARRAY(WITH RECURSIVE cte AS (
SELECT pg_roles.oid,pg_roles.rolname FROM pg_roles
WHERE pg_roles.oid = roles.oid
UNION ALL
SELECT m.roleid,pgr.rolname FROM cte cte_1
JOIN pg_auth_members m ON m.member = cte_1.oid
JOIN pg_roles pgr ON pgr.oid = m.roleid)
SELECT rolname FROM cte)) THEN True
ELSE False END as can_signal_backend
FROM
pg_catalog.pg_roles as roles