Fixed an issue where delete button in Users data was enabled for incorrect rows. #7616

This commit is contained in:
Aditya Toshniwal 2024-06-24 10:31:47 +05:30
parent d0b2752fea
commit 44d40f0785
2 changed files with 7 additions and 6 deletions

View File

@ -45,4 +45,5 @@ Bug fixes
| `Issue #7542 <https://github.com/pgadmin-org/pgadmin4/issues/7542>`_ - Fixed incorrect sorting of size in statistics tab.
| `Issue #7555 <https://github.com/pgadmin-org/pgadmin4/issues/7555>`_ - Fixed an issue where query tool shortcuts for find/replace are not working.
| `Issue #7556 <https://github.com/pgadmin-org/pgadmin4/issues/7556>`_ - Fixed migration failure while using external database.
| `Issue #7593 <https://github.com/pgadmin-org/pgadmin4/issues/7593>`_ - Fixed an issue where query tool auto-complete stops working after connection change.
| `Issue #7593 <https://github.com/pgadmin-org/pgadmin4/issues/7593>`_ - Fixed an issue where query tool auto-complete stops working after connection change.
| `Issue #7616 <https://github.com/pgadmin-org/pgadmin4/issues/7616>`_ - Fixed an issue where delete button in Users data was enabled for incorrect rows.

View File

@ -139,7 +139,7 @@ function DataTableRow({index, row, totalRows, isResizing, isHovered, schema, sch
* If table data changes, then react-table re-renders the complete tables
* We can avoid re-render by if row data is not changed
*/
let depsMap = _.values(row.original, Object.keys(row.original).filter((k)=>!k.startsWith('btn')));
let depsMap = [JSON.stringify(row.original)];
const externalDeps = useMemo(()=>{
let retVal = [];
/* Calculate the fields which depends on the current field
@ -241,7 +241,7 @@ function DataTableRow({index, row, totalRows, isResizing, isHovered, schema, sch
drop(rowRef);
return useMemo(()=>
<PgReactTableRowContent ref={rowRef} row={row} data-handler-id={handlerId} className={isHovered ? 'DataGridView-tableRowHovered' : null} data-test='data-table-row' style={{position: 'initial'}}>
<PgReactTableRowContent ref={rowRef} data-handler-id={handlerId} className={isHovered ? 'DataGridView-tableRowHovered' : null} data-test='data-table-row' style={{position: 'initial'}}>
{row.getVisibleCells().map((cell) => {
let {modeSupported} = cell.column.field ? getFieldMetaData(cell.column.field, schemaRef.current, {}, viewHelperProps) : {modeSupported: true};
@ -347,7 +347,7 @@ export default function DataGridView({
cell: ({row})=>{
let canEditRow = true;
if(props.canEditRow) {
canEditRow = evalFunc(schemaRef.current, props.canEditRow, row || {});
canEditRow = evalFunc(schemaRef.current, props.canEditRow, row.original || {});
}
return <PgIconButton data-test="expand-row" title={gettext('Edit row')} icon={<EditRoundedIcon fontSize="small" />} className='DataGridView-gridRowButton'
onClick={()=>{
@ -376,7 +376,7 @@ export default function DataGridView({
cell: ({row}) => {
let canDeleteRow = true;
if(props.canDeleteRow) {
canDeleteRow = evalFunc(schemaRef.current, props.canDeleteRow, row || {});
canDeleteRow = evalFunc(schemaRef.current, props.canDeleteRow, row.original || {});
}
return (
@ -392,7 +392,7 @@ export default function DataGridView({
};
if (props.onDelete){
props.onDelete(row || {}, deleteRow);
props.onDelete(row.original || {}, deleteRow);
} else {
pgAdmin.Browser.notifier.confirm(
props.customDeleteTitle || gettext('Delete Row'),