mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
public in the privilege control should not be allowed to select the
'WITH GRANT' options.
This commit is contained in:
committed by
Ashesh Vashi
parent
8186e45844
commit
0b956813d4
@@ -152,9 +152,19 @@
|
|||||||
privileges.add(p, {silent: true});
|
privileges.add(p, {silent: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.on("change:grantee", this.granteeChanged)
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
granteeChanged: function() {
|
||||||
|
var privileges = this.get('privileges'),
|
||||||
|
grantee = this.get('grantee');
|
||||||
|
// Reset all with grant options if grantee is public.
|
||||||
|
if (grantee == 'public') {
|
||||||
|
privileges.each(function(m) {
|
||||||
|
m.set("with_grant", false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
toJSON: function(session) {
|
toJSON: function(session) {
|
||||||
if (session) {
|
if (session) {
|
||||||
return pgNode.Model.prototype.toJSON.apply(this, arguments);
|
return pgNode.Model.prototype.toJSON.apply(this, arguments);
|
||||||
@@ -231,7 +241,7 @@
|
|||||||
' </td>',
|
' </td>',
|
||||||
' <td class="renderable">',
|
' <td class="renderable">',
|
||||||
' <label>',
|
' <label>',
|
||||||
' <input type="checkbox" name="with_grant" privilege="<%- privilege_type %>" target="<%- target %>" <%= with_grant ? \'checked\' : "" %> <%= privilege ? "" : \'disabled\'%>></input>',
|
' <input type="checkbox" name="with_grant" privilege="<%- privilege_type %>" target="<%- target %>" <%= with_grant ? \'checked\' : "" %> <%= enable_with_grant ? "" : \'disabled\'%>></input>',
|
||||||
' WITH GRANT OPTION',
|
' WITH GRANT OPTION',
|
||||||
' </label>',
|
' </label>',
|
||||||
' </td>',
|
' </td>',
|
||||||
@@ -264,7 +274,9 @@
|
|||||||
d, {
|
d, {
|
||||||
'target': self.cid,
|
'target': self.cid,
|
||||||
'header': false,
|
'header': false,
|
||||||
'privilege_label': self.Labels[d.privilege_type]
|
'privilege_label': self.Labels[d.privilege_type],
|
||||||
|
'with_grant': (self.model.get('grantee') != 'public' && d.with_grant),
|
||||||
|
'enable_with_grant': (self.model.get('grantee') != 'public' && d.privilege)
|
||||||
});
|
});
|
||||||
privilege = (privilege && d.privilege);
|
privilege = (privilege && d.privilege);
|
||||||
with_grant = (with_grant && privilege && d.with_grant);
|
with_grant = (with_grant && privilege && d.with_grant);
|
||||||
@@ -279,7 +291,8 @@
|
|||||||
'privilege_label': 'ALL',
|
'privilege_label': 'ALL',
|
||||||
'privilege_type': 'ALL',
|
'privilege_type': 'ALL',
|
||||||
'privilege': privilege,
|
'privilege': privilege,
|
||||||
'with_grant': with_grant,
|
'with_grant': (self.model.get('grantee') != 'public' && with_grant),
|
||||||
|
'enable_with_grant': (self.model.get('grantee') != 'public' && privilege),
|
||||||
'header': true
|
'header': true
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -311,7 +324,8 @@
|
|||||||
checked = $el.prop('checked'),
|
checked = $el.prop('checked'),
|
||||||
$tr = $el.closest('tr'),
|
$tr = $el.closest('tr'),
|
||||||
$tbl = $tr.closest('table'),
|
$tbl = $tr.closest('table'),
|
||||||
collection = this.model.get('privileges');
|
collection = this.model.get('privileges'),
|
||||||
|
grantee = this.model.get('grantee');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the checkbox selected/deselected is for 'ALL', we will select all
|
* If the checkbox selected/deselected is for 'ALL', we will select all
|
||||||
@@ -341,8 +355,14 @@
|
|||||||
* We have clicked the ALL checkbox, we should be able to select
|
* We have clicked the ALL checkbox, we should be able to select
|
||||||
* the grant options too.
|
* the grant options too.
|
||||||
*/
|
*/
|
||||||
|
if (grantee == 'public') {
|
||||||
|
$allGrants.prop('disabled', true);
|
||||||
|
$elGrant.prop('disabled', true);
|
||||||
|
} else {
|
||||||
$allGrants.prop('disabled', false);
|
$allGrants.prop('disabled', false);
|
||||||
$elGrant.prop('disabled', false);
|
$elGrant.prop('disabled', false);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* ALL checkbox has been deselected, hence - we need to make
|
* ALL checkbox has been deselected, hence - we need to make
|
||||||
@@ -402,7 +422,7 @@
|
|||||||
$allPrivilege.prop('checked', false);
|
$allPrivilege.prop('checked', false);
|
||||||
$allGrant.prop('disabled', true);
|
$allGrant.prop('disabled', true);
|
||||||
$allGrant.prop('checked', false);
|
$allGrant.prop('checked', false);
|
||||||
} else {
|
} else if (grantee != "public") {
|
||||||
$elGrant.prop('disabled', false);
|
$elGrant.prop('disabled', false);
|
||||||
}
|
}
|
||||||
} else if (!checked) {
|
} else if (!checked) {
|
||||||
@@ -428,7 +448,7 @@
|
|||||||
$allGrant.prop('disabled', false);
|
$allGrant.prop('disabled', false);
|
||||||
$allGrant.prop('checked', true);
|
$allGrant.prop('checked', true);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (grantee != "public") {
|
||||||
$allGrant.prop('disabled', false);
|
$allGrant.prop('disabled', false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -519,7 +539,24 @@
|
|||||||
var PrivilegeCell = Backgrid.Extension.PrivilegeCell = Backgrid.Cell.extend({
|
var PrivilegeCell = Backgrid.Extension.PrivilegeCell = Backgrid.Cell.extend({
|
||||||
className: "edit-cell",
|
className: "edit-cell",
|
||||||
formatter: PrivilegeCellFormatter,
|
formatter: PrivilegeCellFormatter,
|
||||||
editor: PrivilegeCellEditor
|
editor: PrivilegeCellEditor,
|
||||||
|
|
||||||
|
initialize: function (options) {
|
||||||
|
var self = this;
|
||||||
|
Backgrid.Cell.prototype.initialize.apply(this, arguments);
|
||||||
|
|
||||||
|
self.model.on("change:grantee", function () {
|
||||||
|
if (!self.$el.hasClass("editor")) {
|
||||||
|
/*
|
||||||
|
* Add time out before render; As we might want to wait till model
|
||||||
|
* is updated by PrivilegeRoleModel:granteeChanged.
|
||||||
|
*/
|
||||||
|
setTimeout(function() {
|
||||||
|
self.render();
|
||||||
|
},10);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return PrivilegeRoleModel;
|
return PrivilegeRoleModel;
|
||||||
|
|||||||
Reference in New Issue
Block a user