2021-12-22 06:56:21 -06:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2022-01-04 02:24:25 -06:00
|
|
|
// Copyright (C) 2013 - 2022, The pgAdmin Development Team
|
2021-12-22 06:56:21 -06:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
2021-09-20 02:32:41 -05:00
|
|
|
|
|
|
|
import React from 'react';
|
2022-03-30 01:36:59 -05:00
|
|
|
import {
|
|
|
|
useTable,
|
|
|
|
useRowSelect,
|
|
|
|
useSortBy,
|
|
|
|
useResizeColumns,
|
|
|
|
useFlexLayout,
|
|
|
|
useGlobalFilter,
|
|
|
|
useExpanded,
|
|
|
|
} from 'react-table';
|
|
|
|
import { VariableSizeList } from 'react-window';
|
2021-09-20 02:32:41 -05:00
|
|
|
import { makeStyles } from '@material-ui/core/styles';
|
|
|
|
import clsx from 'clsx';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
2022-03-30 01:36:59 -05:00
|
|
|
import { Checkbox, Box } from '@material-ui/core';
|
|
|
|
import { InputText } from './FormComponents';
|
|
|
|
import FormView from 'sources/SchemaView';
|
|
|
|
import _ from 'lodash';
|
|
|
|
import gettext from 'sources/gettext';
|
|
|
|
|
2022-02-02 23:43:39 -06:00
|
|
|
/* eslint-disable react/display-name */
|
2021-09-20 02:32:41 -05:00
|
|
|
const useStyles = makeStyles((theme) => ({
|
|
|
|
root: {
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'column',
|
|
|
|
height: '100%',
|
|
|
|
...theme.mixins.panelBorder,
|
|
|
|
backgroundColor: theme.palette.background.default,
|
|
|
|
},
|
|
|
|
autoResizer: {
|
|
|
|
height: '100% !important',
|
|
|
|
width: '100% !important',
|
|
|
|
},
|
2022-01-24 02:43:02 -06:00
|
|
|
fixedSizeList: {
|
|
|
|
direction: 'ltr',
|
|
|
|
overflowX: 'hidden !important',
|
2022-03-30 01:36:59 -05:00
|
|
|
overflow: 'overlay !important',
|
|
|
|
},
|
|
|
|
customHeader:{
|
2022-04-04 07:12:42 -05:00
|
|
|
marginTop: '8px',
|
2022-03-30 01:36:59 -05:00
|
|
|
marginLeft: '4px'
|
|
|
|
},
|
|
|
|
searchBox: {
|
|
|
|
marginBottom: '5px',
|
|
|
|
display: 'flex',
|
|
|
|
background: theme.palette.background.default
|
|
|
|
},
|
2022-04-04 07:12:42 -05:00
|
|
|
warning: {
|
|
|
|
backgroundColor: theme.palette.warning.main + '!important'
|
|
|
|
},
|
|
|
|
alert: {
|
|
|
|
backgroundColor: theme.palette.error.main + '!important'
|
|
|
|
},
|
|
|
|
|
2022-03-30 01:36:59 -05:00
|
|
|
tableContentWidth: {
|
|
|
|
width: 'calc(100% - 3px)',
|
|
|
|
},
|
|
|
|
searchPadding: {
|
|
|
|
flex: 2.5
|
|
|
|
},
|
|
|
|
searchInput: {
|
|
|
|
flex: 1,
|
|
|
|
marginTop: 8,
|
|
|
|
borderLeft: 'none',
|
|
|
|
paddingLeft: 5,
|
|
|
|
marginRight: 8,
|
|
|
|
marginBottom: 8,
|
|
|
|
|
2022-01-24 02:43:02 -06:00
|
|
|
},
|
2021-09-20 02:32:41 -05:00
|
|
|
table: {
|
2022-03-30 01:36:59 -05:00
|
|
|
flexGrow: 1,
|
|
|
|
minHeight: 0,
|
2021-09-20 02:32:41 -05:00
|
|
|
borderSpacing: 0,
|
|
|
|
width: '100%',
|
|
|
|
overflow: 'hidden',
|
2022-01-24 02:43:02 -06:00
|
|
|
borderRadius: theme.shape.borderRadius,
|
2022-03-30 01:36:59 -05:00
|
|
|
border: '1px solid'+ theme.palette.grey[400]
|
2022-01-24 02:43:02 -06:00
|
|
|
},
|
2022-03-30 01:36:59 -05:00
|
|
|
pgTableHeadar: {
|
|
|
|
display: 'flex',
|
|
|
|
flexGrow: 1,
|
|
|
|
overflow: 'hidden !important',
|
|
|
|
height: '100% !important',
|
|
|
|
flexDirection: 'column'
|
|
|
|
},
|
|
|
|
|
|
|
|
expandedForm: {
|
|
|
|
...theme.mixins.panelBorder,
|
|
|
|
margin: '8px',
|
|
|
|
paddingBottom: '12px',
|
|
|
|
marginRight: '15px',
|
2021-09-20 02:32:41 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
tableCell: {
|
|
|
|
margin: 0,
|
|
|
|
padding: theme.spacing(0.5),
|
|
|
|
...theme.mixins.panelBorder.bottom,
|
|
|
|
...theme.mixins.panelBorder.right,
|
|
|
|
position: 'relative',
|
|
|
|
overflow: 'hidden',
|
2022-03-30 01:36:59 -05:00
|
|
|
height: '35px',
|
2021-09-20 02:32:41 -05:00
|
|
|
textOverflow: 'ellipsis',
|
|
|
|
whiteSpace: 'nowrap',
|
2022-01-24 02:43:02 -06:00
|
|
|
backgroundColor: theme.otherVars.tableBg,
|
2022-04-04 07:12:42 -05:00
|
|
|
userSelect: 'text'
|
2021-09-20 02:32:41 -05:00
|
|
|
},
|
|
|
|
selectCell: {
|
2022-03-30 01:36:59 -05:00
|
|
|
textAlign: 'center',
|
2022-04-04 07:12:42 -05:00
|
|
|
minWidth: 20
|
2021-09-20 02:32:41 -05:00
|
|
|
},
|
|
|
|
tableCellHeader: {
|
|
|
|
fontWeight: theme.typography.fontWeightBold,
|
|
|
|
padding: theme.spacing(1, 0.5),
|
|
|
|
textAlign: 'left',
|
|
|
|
overflowY: 'auto',
|
|
|
|
overflowX: 'hidden',
|
|
|
|
alignContent: 'center',
|
2022-01-24 02:43:02 -06:00
|
|
|
backgroundColor: theme.otherVars.tableBg,
|
2021-09-20 02:32:41 -05:00
|
|
|
...theme.mixins.panelBorder.bottom,
|
|
|
|
...theme.mixins.panelBorder.right,
|
2022-01-24 02:43:02 -06:00
|
|
|
...theme.mixins.panelBorder.top,
|
|
|
|
...theme.mixins.panelBorder.left,
|
2021-09-20 02:32:41 -05:00
|
|
|
},
|
|
|
|
resizer: {
|
|
|
|
display: 'inline-block',
|
|
|
|
width: '5px',
|
|
|
|
height: '100%',
|
|
|
|
position: 'absolute',
|
|
|
|
right: 0,
|
|
|
|
top: 0,
|
|
|
|
transform: 'translateX(50%)',
|
|
|
|
zIndex: 1,
|
|
|
|
touchAction: 'none',
|
|
|
|
},
|
|
|
|
cellIcon: {
|
2022-01-24 02:43:02 -06:00
|
|
|
paddingLeft: '1.8em',
|
|
|
|
paddingTop: '0.35em',
|
|
|
|
height: 35,
|
|
|
|
backgroundPosition: '1%',
|
2022-03-30 01:36:59 -05:00
|
|
|
},
|
|
|
|
emptyPanel: {
|
|
|
|
minHeight: '100%',
|
|
|
|
minWidth: '100%',
|
|
|
|
background: theme.palette.background.default,
|
|
|
|
overflow: 'auto',
|
|
|
|
padding: '7.5px',
|
|
|
|
},
|
|
|
|
panelIcon: {
|
|
|
|
width: '80%',
|
|
|
|
margin: '0 auto',
|
|
|
|
marginTop: '25px !important',
|
|
|
|
position: 'relative',
|
|
|
|
textAlign: 'center',
|
|
|
|
},
|
|
|
|
panelMessage: {
|
|
|
|
marginLeft: '0.5rem',
|
|
|
|
fontSize: '0.875rem',
|
|
|
|
},
|
|
|
|
expandedIconCell: {
|
|
|
|
backgroundColor: theme.palette.grey[400],
|
|
|
|
...theme.mixins.panelBorder.top,
|
|
|
|
borderBottom: 'none',
|
|
|
|
},
|
|
|
|
btnCell: {
|
|
|
|
padding: theme.spacing(0.5, 0),
|
|
|
|
textAlign: 'center',
|
|
|
|
},
|
|
|
|
}));
|
2021-09-20 02:32:41 -05:00
|
|
|
|
2022-03-30 01:36:59 -05:00
|
|
|
export default function PgTable({ columns, data, isSelectRow, offset=105, ...props }) {
|
2021-09-20 02:32:41 -05:00
|
|
|
// Use the state and functions returned from useTable to build your UI
|
|
|
|
const classes = useStyles();
|
2022-03-30 01:36:59 -05:00
|
|
|
const [searchVal, setSearchVal] = React.useState('');
|
|
|
|
const tableRef = React.useRef();
|
|
|
|
const rowHeights = React.useRef({});
|
|
|
|
const rowRef = React.useRef({});
|
|
|
|
|
2022-04-04 07:12:42 -05:00
|
|
|
// Reset Search vakue in tab changed.
|
|
|
|
React.useEffect(()=>{
|
|
|
|
setSearchVal('');
|
|
|
|
},[columns]);
|
2022-03-30 01:36:59 -05:00
|
|
|
function getRowHeight(index, size) {
|
|
|
|
return rowHeights.current[index] + size || 35;
|
|
|
|
}
|
|
|
|
|
|
|
|
const setRowHeight = React.useCallback((index, size) => {
|
|
|
|
if(tableRef.current) {
|
|
|
|
tableRef.current.resetAfterIndex(index);
|
|
|
|
if (!(rowHeights.current.hasOwnProperty(index))){
|
|
|
|
rowHeights.current = { ...rowHeights.current, [index]: size };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, []);
|
|
|
|
|
2021-09-20 02:32:41 -05:00
|
|
|
const defaultColumn = React.useMemo(
|
|
|
|
() => ({
|
|
|
|
minWidth: 150,
|
|
|
|
}),
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
|
|
|
|
const IndeterminateCheckbox = React.forwardRef(
|
|
|
|
({ indeterminate, ...rest }, ref) => {
|
|
|
|
const defaultRef = React.useRef();
|
|
|
|
const resolvedRef = ref || defaultRef;
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
resolvedRef.current.indeterminate = indeterminate;
|
|
|
|
}, [resolvedRef, indeterminate]);
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Checkbox
|
|
|
|
color="primary"
|
2022-03-30 01:36:59 -05:00
|
|
|
ref={resolvedRef} {...rest}
|
|
|
|
/>
|
2021-09-20 02:32:41 -05:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
IndeterminateCheckbox.displayName = 'SelectCheckbox';
|
|
|
|
|
|
|
|
IndeterminateCheckbox.propTypes = {
|
|
|
|
indeterminate: PropTypes.bool,
|
|
|
|
rest: PropTypes.func,
|
|
|
|
getToggleAllRowsSelectedProps: PropTypes.func,
|
|
|
|
row: PropTypes.object,
|
|
|
|
};
|
|
|
|
|
|
|
|
const {
|
|
|
|
getTableProps,
|
|
|
|
getTableBodyProps,
|
|
|
|
headerGroups,
|
|
|
|
rows,
|
|
|
|
prepareRow,
|
|
|
|
selectedFlatRows,
|
2022-03-30 01:36:59 -05:00
|
|
|
state: { selectedRowIds, expanded },
|
2021-09-30 00:26:51 -05:00
|
|
|
setGlobalFilter,
|
2022-03-30 01:36:59 -05:00
|
|
|
setHiddenColumns,
|
2021-09-20 02:32:41 -05:00
|
|
|
} = useTable(
|
|
|
|
{
|
|
|
|
columns,
|
|
|
|
data,
|
|
|
|
defaultColumn,
|
|
|
|
isSelectRow,
|
|
|
|
},
|
|
|
|
useGlobalFilter,
|
|
|
|
useSortBy,
|
2022-03-30 01:36:59 -05:00
|
|
|
useExpanded,
|
2021-09-20 02:32:41 -05:00
|
|
|
useRowSelect,
|
|
|
|
useResizeColumns,
|
|
|
|
useFlexLayout,
|
2022-03-30 01:36:59 -05:00
|
|
|
(hooks) => {
|
|
|
|
hooks.visibleColumns.push((CLOUMNS) => {
|
2021-09-20 02:32:41 -05:00
|
|
|
if (isSelectRow) {
|
|
|
|
return [
|
|
|
|
// Let's make a column for selection
|
|
|
|
{
|
|
|
|
id: 'selection',
|
|
|
|
// The header can use the table's getToggleAllRowsSelectedProps method
|
|
|
|
// to render a checkbox
|
2022-04-04 07:12:42 -05:00
|
|
|
Header: ({ getToggleAllRowsSelectedProps, toggleRowSelected, isAllRowsSelected, rows }) => {
|
|
|
|
|
|
|
|
const modifiedOnChange = (event) => {
|
|
|
|
rows.forEach((row) => {
|
|
|
|
//check each row if it is not disabled
|
|
|
|
!(!_.isUndefined(row.original.canDrop) && !(row.original.canDrop)) && toggleRowSelected(row.id, event.currentTarget.checked);
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
let allTableRows = 0;
|
|
|
|
let selectedTableRows = 0;
|
|
|
|
rows.forEach((row) => {
|
|
|
|
row.isSelected && selectedTableRows++;
|
|
|
|
(_.isUndefined(row.original.canDrop) || row.original.canDrop) && allTableRows++;
|
|
|
|
});
|
|
|
|
const disabled = allTableRows === 0;
|
|
|
|
const checked =
|
|
|
|
(isAllRowsSelected ||
|
|
|
|
allTableRows === selectedTableRows) &&
|
|
|
|
!disabled;
|
|
|
|
return(
|
|
|
|
<div className={classes.selectCell}>
|
|
|
|
<IndeterminateCheckbox {...getToggleAllRowsSelectedProps()
|
|
|
|
}
|
|
|
|
onChange={modifiedOnChange}
|
|
|
|
checked={checked}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);},
|
2021-09-20 02:32:41 -05:00
|
|
|
// The cell can use the individual row's getToggleRowSelectedProps method
|
|
|
|
// to the render a checkbox
|
|
|
|
Cell: ({ row }) => (
|
|
|
|
<div className={classes.selectCell}>
|
2022-04-04 07:12:42 -05:00
|
|
|
<IndeterminateCheckbox {...row.getToggleRowSelectedProps()}
|
|
|
|
disabled={!_.isUndefined(row.original.canDrop) ? !(row.original.canDrop) : false}
|
|
|
|
/>
|
2021-09-20 02:32:41 -05:00
|
|
|
</div>
|
|
|
|
),
|
|
|
|
sortble: false,
|
2022-03-30 01:36:59 -05:00
|
|
|
width: 30,
|
2022-04-04 07:12:42 -05:00
|
|
|
maxWidth: 30,
|
|
|
|
minWidth: 0
|
2021-09-20 02:32:41 -05:00
|
|
|
},
|
|
|
|
...CLOUMNS,
|
|
|
|
];
|
|
|
|
} else {
|
|
|
|
return [...CLOUMNS];
|
|
|
|
}
|
|
|
|
});
|
2022-01-24 02:43:02 -06:00
|
|
|
hooks.useInstanceBeforeDimensions.push(({ headerGroups }) => {
|
2021-09-20 02:32:41 -05:00
|
|
|
// fix the parent group of the selection button to not be resizable
|
2022-01-24 02:43:02 -06:00
|
|
|
const selectionGroupHeader = headerGroups[0].headers[0];
|
2021-09-20 02:32:41 -05:00
|
|
|
selectionGroupHeader.resizable = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2022-03-30 01:36:59 -05:00
|
|
|
React.useEffect(()=>{
|
|
|
|
tableRef.current?.resetAfterIndex(0);
|
|
|
|
},[expanded]);
|
|
|
|
|
|
|
|
|
2021-09-30 00:26:51 -05:00
|
|
|
React.useEffect(() => {
|
|
|
|
setHiddenColumns(
|
|
|
|
columns
|
|
|
|
.filter((column) => {
|
2022-03-30 01:36:59 -05:00
|
|
|
if (column.isVisible === undefined || column.isVisible === true) {
|
2021-09-30 00:26:51 -05:00
|
|
|
return false;
|
|
|
|
}
|
2022-01-18 03:19:54 -06:00
|
|
|
return true;
|
2021-09-30 00:26:51 -05:00
|
|
|
}
|
|
|
|
)
|
|
|
|
.map((column) => column.accessor)
|
|
|
|
);
|
|
|
|
}, [setHiddenColumns, columns]);
|
|
|
|
|
2021-09-20 02:32:41 -05:00
|
|
|
React.useEffect(() => {
|
|
|
|
if (props.setSelectedRows) {
|
|
|
|
props.setSelectedRows(selectedFlatRows);
|
|
|
|
}
|
|
|
|
}, [selectedRowIds]);
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
if (props.getSelectedRows) {
|
|
|
|
props.getSelectedRows(selectedFlatRows);
|
|
|
|
}
|
|
|
|
}, [selectedRowIds]);
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
2022-03-30 01:36:59 -05:00
|
|
|
setGlobalFilter(searchVal || undefined);
|
|
|
|
}, [searchVal]);
|
2021-09-20 02:32:41 -05:00
|
|
|
|
|
|
|
const RenderRow = React.useCallback(
|
|
|
|
({ index, style }) => {
|
|
|
|
const row = rows[index];
|
|
|
|
prepareRow(row);
|
|
|
|
return (
|
2022-03-30 01:36:59 -05:00
|
|
|
<div className={classes.tableContentWidth} style={style} key={row.id}>
|
|
|
|
<div {...row.getRowProps()} className={classes.tr}>
|
|
|
|
{row.cells.map((cell) => {
|
|
|
|
let classNames = [classes.tableCell];
|
|
|
|
if(typeof(cell.column.id) == 'string' && cell.column.id.startsWith('btn-')) {
|
|
|
|
classNames.push(classes.btnCell);
|
|
|
|
}
|
|
|
|
if(cell.column.id == 'btn-edit' && row.isExpanded) {
|
|
|
|
classNames.push(classes.expandedIconCell);
|
|
|
|
}
|
2022-04-04 07:12:42 -05:00
|
|
|
if (row.original.row_type === 'warning'){
|
|
|
|
classNames.push(classes.warning);
|
|
|
|
}
|
|
|
|
if (row.original.row_type === 'alert'){
|
|
|
|
classNames.push(classes.alert);
|
|
|
|
}
|
2022-03-30 01:36:59 -05:00
|
|
|
return (
|
2022-04-04 07:12:42 -05:00
|
|
|
<div key={cell.column.id} {...cell.getCellProps()} className={clsx(classNames, row.original.icon && row.original.icon[cell.column.id], row.original.icon[cell.column.id] && classes.cellIcon)}
|
|
|
|
title={_.isUndefined(cell.value) || _.isNull(cell.value) ? '': String(cell.value)}>
|
2022-03-30 01:36:59 -05:00
|
|
|
{cell.render('Cell')}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
{!_.isUndefined(row) && row.isExpanded && (
|
|
|
|
<Box key={row.id} className={classes.expandedForm} ref={rowRef} style={{height: rowHeights.current[index]}}>
|
|
|
|
<FormView
|
|
|
|
getInitData={() => {
|
|
|
|
/*This is intentional (SonarQube)*/
|
|
|
|
}}
|
|
|
|
viewHelperProps={{ mode: 'properties' }}
|
|
|
|
schema={props.schema[row.id]}
|
|
|
|
showFooter={false}
|
|
|
|
onDataChange={() => { }}
|
|
|
|
/>
|
|
|
|
</Box>
|
|
|
|
)}
|
2021-09-20 02:32:41 -05:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
[prepareRow, rows, selectedRowIds]
|
|
|
|
);
|
|
|
|
// Render the UI for your table
|
|
|
|
return (
|
2022-03-30 01:36:59 -05:00
|
|
|
<Box className={classes.pgTableHeadar}>
|
|
|
|
<Box className={classes.searchBox}>
|
|
|
|
{props.customHeader && (<Box className={classes.customHeader}> <props.customHeader /></Box>)}
|
|
|
|
<Box className={classes.searchPadding}></Box>
|
|
|
|
<InputText
|
|
|
|
placeholder={'Search'}
|
|
|
|
className={classes.searchInput}
|
|
|
|
value={searchVal}
|
|
|
|
onChange={(val) => {
|
|
|
|
setSearchVal(val);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Box>
|
|
|
|
<AutoSizer
|
|
|
|
className={props.type === 'panel' ? props.className : classes.autoResizer}
|
|
|
|
>
|
|
|
|
{({ height }) => (
|
|
|
|
<div {...getTableProps()} className={classes.table}>
|
|
|
|
<div>
|
|
|
|
{headerGroups.map((headerGroup) => (
|
|
|
|
<div key={''} {...headerGroup.getHeaderGroupProps()}>
|
|
|
|
{headerGroup.headers.map((column) => (
|
2022-01-24 02:43:02 -06:00
|
|
|
<div
|
2022-03-30 01:36:59 -05:00
|
|
|
key={column.id}
|
|
|
|
{...column.getHeaderProps()}
|
|
|
|
className={clsx(classes.tableCellHeader, column.className)}
|
2022-01-24 02:43:02 -06:00
|
|
|
>
|
2022-03-30 01:36:59 -05:00
|
|
|
<div
|
|
|
|
{...(column.sortble ? column.getSortByToggleProps() : {})}
|
|
|
|
>
|
|
|
|
{column.render('Header')}
|
|
|
|
<span>
|
|
|
|
{column.isSorted
|
|
|
|
? column.isSortedDesc
|
|
|
|
? ' 🔽'
|
|
|
|
: ' 🔼'
|
|
|
|
: ''}
|
|
|
|
</span>
|
|
|
|
{column.resizable && (
|
|
|
|
<div
|
|
|
|
{...column.getResizerProps()}
|
|
|
|
className={classes.resizer}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
2021-09-20 02:32:41 -05:00
|
|
|
</div>
|
2022-03-30 01:36:59 -05:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{
|
|
|
|
data.length > 0 ? (
|
|
|
|
<div {...getTableBodyProps()} >
|
|
|
|
<VariableSizeList
|
|
|
|
ref={tableRef}
|
|
|
|
className={props.type === 'dashboard' ? props.fixedSizeList : classes.fixedSizeList}
|
|
|
|
height={height - offset}
|
|
|
|
itemCount={rows.length}
|
|
|
|
itemSize={(i) => {
|
|
|
|
if (_.isUndefined(rows[i].isExpanded)) {
|
|
|
|
rows[i].isExpanded = false;
|
|
|
|
}
|
|
|
|
if (rowRef.current && rows[i].isExpanded) {
|
|
|
|
setRowHeight(i, rowRef.current.offsetHeight + 35);
|
|
|
|
}
|
|
|
|
return rows[i].isExpanded ? getRowHeight(i, 35) : 35;
|
|
|
|
}}
|
|
|
|
sorted={props?.sortOptions}
|
|
|
|
>
|
|
|
|
{RenderRow}
|
|
|
|
|
|
|
|
</VariableSizeList>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
|
|
|
|
<div className={classes.emptyPanel}>
|
|
|
|
<div className={classes.panelIcon}>
|
|
|
|
<i className="fa fa-exclamation-circle"></i>
|
|
|
|
<span className={classes.panelMessage}>{gettext('No record found')}</span>
|
2021-09-20 02:32:41 -05:00
|
|
|
</div>
|
|
|
|
|
2022-03-30 01:36:59 -05:00
|
|
|
</div>
|
|
|
|
)}
|
2021-09-20 02:32:41 -05:00
|
|
|
</div>
|
2022-03-30 01:36:59 -05:00
|
|
|
)}
|
|
|
|
</AutoSizer>
|
|
|
|
</Box>
|
2021-09-20 02:32:41 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-23 04:10:38 -05:00
|
|
|
PgTable.propTypes = {
|
2021-09-20 02:32:41 -05:00
|
|
|
stepId: PropTypes.number,
|
|
|
|
height: PropTypes.number,
|
2022-03-30 01:36:59 -05:00
|
|
|
offset: PropTypes.number,
|
|
|
|
customHeader: PropTypes.func,
|
2021-09-20 02:32:41 -05:00
|
|
|
className: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
2022-03-30 01:36:59 -05:00
|
|
|
fixedSizeList: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
|
|
children: PropTypes.oneOfType([
|
|
|
|
PropTypes.arrayOf(PropTypes.node),
|
|
|
|
PropTypes.node,
|
|
|
|
]),
|
2021-09-20 02:32:41 -05:00
|
|
|
getToggleAllRowsSelectedProps: PropTypes.func,
|
2022-04-04 07:12:42 -05:00
|
|
|
toggleRowSelected: PropTypes.func,
|
2022-02-02 23:43:39 -06:00
|
|
|
columns: PropTypes.array,
|
|
|
|
data: PropTypes.array,
|
|
|
|
isSelectRow: PropTypes.bool,
|
2022-04-04 07:12:42 -05:00
|
|
|
isAllRowsSelected: PropTypes.bool,
|
2022-02-02 23:43:39 -06:00
|
|
|
row: PropTypes.func,
|
|
|
|
setSelectedRows: PropTypes.func,
|
|
|
|
getSelectedRows: PropTypes.func,
|
|
|
|
searchText: PropTypes.string,
|
|
|
|
type: PropTypes.string,
|
2022-03-30 01:36:59 -05:00
|
|
|
sortOptions: PropTypes.array,
|
2022-04-04 07:12:42 -05:00
|
|
|
schema: PropTypes.object,
|
|
|
|
rows: PropTypes.object
|
2021-09-20 02:32:41 -05:00
|
|
|
};
|