MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / onCheck

Function onCheck

web/pgadmin/static/js/components/Privilege.jsx:95–123  ·  view source on GitHub ↗
(e, forWithGrant)

Source from the content-addressed store, hash-verified

93 };
94
95 const onCheck = (e, forWithGrant)=>{
96 let exists = false;
97 let newValue = [];
98
99 /* Calculate the newValue by pushing all selected and ignore if unchecked */
100 (value||[]).forEach((v)=>{
101 if(v.privilege_type === e.target.name) {
102 exists = true;
103 if(forWithGrant) {
104 newValue.push({
105 ...v,
106 with_grant: e.target.checked,
107 });
108 }
109 } else {
110 newValue.push(v);
111 }
112 });
113
114 if(!exists && e.target.checked) {
115 newValue.push({
116 privilege_type: e.target.name,
117 privilege: e.target.checked,
118 with_grant: false,
119 });
120 }
121
122 onChange(newValue);
123 };
124
125 /* If all supported privs and incoming value length matches, clearly all are selected */
126 all = (realVal.length === (value || []).length);

Callers 1

PrivilegeFunction · 0.85

Calls 1

onChangeFunction · 0.50

Tested by

no test coverage detected