Ensure that a new row should be added on top in the User Management dialog. Fixes #5817

pull/6297/head^2
Akshay Joshi 2023-05-18 13:26:47 +05:30
parent 4fd1e16bb4
commit 6949b41fb9
5 changed files with 19 additions and 8 deletions

View File

@ -30,11 +30,12 @@ Housekeeping
Bug fixes Bug fixes
********* *********
| `Issue #6253 <https://github.com/pgadmin-org/pgadmin4/issues/6253>`_ - Fix an issue in the register server when setting the role, an arbitrary SQL query can be fired. | `Issue #5817 <https://github.com/pgadmin-org/pgadmin4/issues/5817>`_ - Ensure that a new row should be added on top in the User Management dialog.
| `Issue #6003 <https://github.com/pgadmin-org/pgadmin4/issues/6003>`_ - Indicate the user if all the server's children nodes are hidden from the preferences setting. | `Issue #6003 <https://github.com/pgadmin-org/pgadmin4/issues/6003>`_ - Indicate the user if all the server's children nodes are hidden from the preferences setting.
| `Issue #6026 <https://github.com/pgadmin-org/pgadmin4/issues/6026>`_ - Tools menu should be toggled for "pause replay of wal" and "resume replay of wal". | `Issue #6026 <https://github.com/pgadmin-org/pgadmin4/issues/6026>`_ - Tools menu should be toggled for "pause replay of wal" and "resume replay of wal".
| `Issue #6080 <https://github.com/pgadmin-org/pgadmin4/issues/6080>`_ - pgAdmin icon not showing on taskbar on Windows 10. | `Issue #6080 <https://github.com/pgadmin-org/pgadmin4/issues/6080>`_ - pgAdmin icon not showing on taskbar on Windows 10.
| `Issue #6147 <https://github.com/pgadmin-org/pgadmin4/issues/6147>`_ - Heartbeat is getting logged, though no server is connected in pgAdmin. | `Issue #6147 <https://github.com/pgadmin-org/pgadmin4/issues/6147>`_ - Heartbeat is getting logged, though no server is connected in pgAdmin.
| `Issue #6221 <https://github.com/pgadmin-org/pgadmin4/issues/6221>`_ - Fix circular reference error for the multirange data types in the query tool. | `Issue #6221 <https://github.com/pgadmin-org/pgadmin4/issues/6221>`_ - Fix circular reference error for the multirange data types in the query tool.
| `Issue #6253 <https://github.com/pgadmin-org/pgadmin4/issues/6253>`_ - Fix an issue in the register server when setting the role, an arbitrary SQL query can be fired.
| `Issue #6267 <https://github.com/pgadmin-org/pgadmin4/issues/6267>`_ - Ensure the user is able to log in if the specified OAUTH2_USERNAME_CLAIM is present in the OAuth2 profile. | `Issue #6267 <https://github.com/pgadmin-org/pgadmin4/issues/6267>`_ - Ensure the user is able to log in if the specified OAUTH2_USERNAME_CLAIM is present in the OAuth2 profile.
| `Issue #6281 <https://github.com/pgadmin-org/pgadmin4/issues/6281>`_ - VarChar Field Sizes are missing from Query's Grid header. | `Issue #6281 <https://github.com/pgadmin-org/pgadmin4/issues/6281>`_ - VarChar Field Sizes are missing from Query's Grid header.

View File

@ -546,6 +546,7 @@ export default function DataGridView({
type: SCHEMA_STATE_ACTIONS.ADD_ROW, type: SCHEMA_STATE_ACTIONS.ADD_ROW,
path: accessPath, path: accessPath,
value: newRow, value: newRow,
addOnTop: props.addOnTop
}); });
}, [props.canAddRow, rows?.length]); }, [props.canAddRow, rows?.length]);
@ -682,4 +683,5 @@ DataGridView.propTypes = {
customDeleteMsg: PropTypes.string, customDeleteMsg: PropTypes.string,
canSearch: PropTypes.bool, canSearch: PropTypes.bool,
onDelete: PropTypes.func, onDelete: PropTypes.func,
addOnTop: PropTypes.bool
}; };

View File

@ -41,7 +41,7 @@ const useStyles = makeStyles((theme)=>({
}, },
errorMargin: { errorMargin: {
/* Error footer space */ /* Error footer space */
paddingBottom: '36px', paddingBottom: '36px !important',
}, },
sqlTabInput: { sqlTabInput: {
border: 0, border: 0,
@ -278,7 +278,8 @@ export default function FormView({
canEdit: canEdit, canDelete: canDelete, canEdit: canEdit, canDelete: canDelete,
visible: visible, canAddRow: canAddRow, onDelete: field.onDelete, canSearch: field.canSearch, visible: visible, canAddRow: canAddRow, onDelete: field.onDelete, canSearch: field.canSearch,
expandEditOnAdd: field.expandEditOnAdd, expandEditOnAdd: field.expandEditOnAdd,
fixedRows: (viewHelperProps.mode == 'create' ? field.fixedRows : undefined) fixedRows: (viewHelperProps.mode == 'create' ? field.fixedRows : undefined),
addOnTop: Boolean(field.addOnTop)
}; };
if(CustomControl) { if(CustomControl) {
@ -404,9 +405,10 @@ export default function FormView({
</Box> </Box>
</>); </>);
} else { } else {
let contentClassName = [stateUtils.formErr.message ? classes.errorMargin : null];
return ( return (
<> <>
<Box height="100%" display="flex" flexDirection="column" className={className} ref={formRef}> <Box height="100%" display="flex" flexDirection="column" className={clsx(className, contentClassName)} ref={formRef}>
{Object.keys(finalTabs).map((tabName)=>{ {Object.keys(finalTabs).map((tabName)=>{
return ( return (
<React.Fragment key={tabName}>{finalTabs[tabName]}</React.Fragment> <React.Fragment key={tabName}>{finalTabs[tabName]}</React.Fragment>

View File

@ -186,15 +186,16 @@ function getChangedData(topSchema, viewHelperProps, sessData, stringify=false, i
let changed = []; let changed = [];
for(const changedRow of changeDiff.updated) { for(const changedRow of changeDiff.updated) {
let finalChangedRow = {}; let finalChangedRow = {};
let rowIndx = _.findIndex(_.get(sessVal, field.id), (r)=>r.cid==changedRow.cid); let rowIndxSess = _.findIndex(_.get(sessVal, field.id), (r)=>r.cid==changedRow.cid);
finalChangedRow = parseChanges(field.schema, _.get(origVal, [field.id, rowIndx]), _.get(sessVal, [field.id, rowIndx])); let rowIndxOrig = _.findIndex(_.get(origVal, field.id), (r)=>r.cid==changedRow.cid);
finalChangedRow = parseChanges(field.schema, _.get(origVal, [field.id, rowIndxOrig]), _.get(sessVal, [field.id, rowIndxSess]));
if(_.isEmpty(finalChangedRow)) { if(_.isEmpty(finalChangedRow)) {
continue; continue;
} }
/* If the id attr value is present, then only changed keys can be passed. /* If the id attr value is present, then only changed keys can be passed.
Otherwise, passing all the keys is useful */ Otherwise, passing all the keys is useful */
let idAttrValue = _.get(sessVal, [field.id, rowIndx, field.schema.idAttribute]); let idAttrValue = _.get(sessVal, [field.id, rowIndxSess, field.schema.idAttribute]);
if(_.isUndefined(idAttrValue)) { if(_.isUndefined(idAttrValue)) {
changed.push({ changed.push({
...changedRow, ...changedRow,
@ -409,7 +410,11 @@ const sessDataReducer = (state, action)=>{
/* Create id to identify a row uniquely, usefull when getting diff */ /* Create id to identify a row uniquely, usefull when getting diff */
cid = _.uniqueId('c'); cid = _.uniqueId('c');
action.value['cid'] = cid; action.value['cid'] = cid;
if (action.addOnTop) {
rows = [].concat(action.value).concat(_.get(data, action.path)||[]);
} else {
rows = (_.get(data, action.path)||[]).concat(action.value); rows = (_.get(data, action.path)||[]).concat(action.value);
}
_.set(data, action.path, rows); _.set(data, action.path, rows);
/* If there is any dep listeners get the changes */ /* If there is any dep listeners get the changes */
data = getDepChange(action.path, data, state, action); data = getDepChange(action.path, data, state, action);

View File

@ -239,6 +239,7 @@ class UserManagementSchema extends BaseUISchema {
{ {
id: 'userManagement', label: '', type: 'collection', schema: obj.userManagementCollObj, id: 'userManagement', label: '', type: 'collection', schema: obj.userManagementCollObj,
canAdd: true, canDelete: true, isFullTab: true, group: 'temp_user', canAdd: true, canDelete: true, isFullTab: true, group: 'temp_user',
addOnTop: true,
canDeleteRow: (row)=>{ canDeleteRow: (row)=>{
return row['id'] != current_user['id']; return row['id'] != current_user['id'];
}, },