Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
Stack.jsx85 linesDownload Raw Back to components
1/////////////////////////////////////////////////////////////2//3// pgAdmin 4 - PostgreSQL Tools4//5// Copyright (C) 2013 - 2024, The pgAdmin Development Team6// This software is released under the PostgreSQL Licence7//8//////////////////////////////////////////////////////////////9 10import _ from 'lodash';11import clsx from 'clsx';12import gettext from 'sources/gettext';13 14import React, { useState } from 'react';15 16import { makeStyles } from '@mui/styles';17import TableContainer from '@mui/material/TableContainer';18import Paper from '@mui/material/Paper';19 20import { DebuggerEventsContext } from './DebuggerComponent';21import { DEBUGGER_EVENTS } from '../DebuggerConstants';22import { commonTableStyles } from '../../../../../static/js/Theme';23import { InputText } from '../../../../../static/js/components/FormComponents';24 25 26const useStyles = makeStyles(() => ({27  table: {28    minWidth: 650,29  },30  summaryContainer: {31    flexGrow: 1,32    minHeight: 0,33    overflow: 'auto',34    maxHeight: '100%'35  },36  container: {37    maxHeight: '100%'38  }39}));40 41export function Stack() {42  const classes = useStyles();43  const tableClasses = commonTableStyles();44  const eventBus = React.useContext(DebuggerEventsContext);45  const [stackData, setStackData] = useState([]);46  const [disableFrameSelection, setDisableFrameSelection] = useState(false);47 48  React.useEffect(() => {49    eventBus.registerListener(DEBUGGER_EVENTS.SET_STACK, (stackValues) => {50      setStackData(stackValues);51    });52    eventBus.registerListener(DEBUGGER_EVENTS.GET_TOOL_BAR_BUTTON_STATUS, (status) => {53      setDisableFrameSelection(status.disabled);54    });55  }, []);56  return (57    <Paper variant="outlined" elevation={0} className={classes.summaryContainer}>58      <TableContainer className={classes.container}>59        <table className={clsx(tableClasses.table)} aria-label="sticky table">60          <thead>61            <tr>62              <th>{gettext('Name')}</th>63              <th>{gettext('Value')}</th>64              <th>{gettext('Line No.')}</th>65            </tr>66          </thead>67          <tbody>68            {stackData?.map((row, index) => (69              <tr key={_.uniqueId('c')}>70                <td>71                  {row.targetname}72                </td>73                <td>{row.args}</td>74                <td>75                  <InputText data-test='stack-select-frame' value={row.linenumber} readonly={true} disabled={disableFrameSelection} onClick={() => { if(!disableFrameSelection)eventBus.fireEvent(DEBUGGER_EVENTS.SET_FRAME, index);}}></InputText>76                </td>77              </tr>78            ))}79          </tbody>80        </table>81      </TableContainer>82    </Paper>83  );84}85 
codekingpro/portable-devtools · Team Ai