Files
pgadmin4/web/pgadmin/tools/debugger/static/js/components/Stack.jsx
Yogesh Mahajan 102e0a9839 - Update MUI v4 to v5
- Remove the SCSS dependency completely and use MUI for theming.
- Update - date-fns, @date-io, notistack. Remove - popper.js, sass-loader.
- Cleanup webpack config.
- Port PSQL tool to use MUI themes instead of SCSS theme.
- Theme change will reflect realtime without refreshing pgAdmin.
2024-04-09 08:21:14 +05:30

85 lines
2.6 KiB
JavaScript

/////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2024, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////
import _ from 'lodash';
import clsx from 'clsx';
import gettext from 'sources/gettext';
import React, { useState } from 'react';
import { makeStyles } from '@mui/styles';
import TableContainer from '@mui/material/TableContainer';
import Paper from '@mui/material/Paper';
import { DebuggerEventsContext } from './DebuggerComponent';
import { DEBUGGER_EVENTS } from '../DebuggerConstants';
import { commonTableStyles } from '../../../../../static/js/Theme';
import { InputText } from '../../../../../static/js/components/FormComponents';
const useStyles = makeStyles(() => ({
table: {
minWidth: 650,
},
summaryContainer: {
flexGrow: 1,
minHeight: 0,
overflow: 'auto',
maxHeight: '100%'
},
container: {
maxHeight: '100%'
}
}));
export function Stack() {
const classes = useStyles();
const tableClasses = commonTableStyles();
const eventBus = React.useContext(DebuggerEventsContext);
const [stackData, setStackData] = useState([]);
const [disableFrameSelection, setDisableFrameSelection] = useState(false);
React.useEffect(() => {
eventBus.registerListener(DEBUGGER_EVENTS.SET_STACK, (stackValues) => {
setStackData(stackValues);
});
eventBus.registerListener(DEBUGGER_EVENTS.GET_TOOL_BAR_BUTTON_STATUS, (status) => {
setDisableFrameSelection(status.disabled);
});
}, []);
return (
<Paper variant="outlined" elevation={0} className={classes.summaryContainer}>
<TableContainer className={classes.container}>
<table className={clsx(tableClasses.table)} aria-label="sticky table">
<thead>
<tr>
<th>{gettext('Name')}</th>
<th>{gettext('Value')}</th>
<th>{gettext('Line No.')}</th>
</tr>
</thead>
<tbody>
{stackData?.map((row, index) => (
<tr key={_.uniqueId('c')}>
<td>
{row.targetname}
</td>
<td>{row.args}</td>
<td>
<InputText data-test='stack-select-frame' value={row.linenumber} readonly={true} disabled={disableFrameSelection} onClick={() => { if(!disableFrameSelection)eventBus.fireEvent(DEBUGGER_EVENTS.SET_FRAME, index);}}></InputText>
</td>
</tr>
))}
</tbody>
</table>
</TableContainer>
</Paper>
);
}