Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
Properties.jsx93 linesDownload Raw Back to properties
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 React from 'react';11import CollectionNodeProperties from './CollectionNodeProperties';12import ErrorBoundary from '../../static/js/helpers/ErrorBoundary';13import withStandardTabInfo from '../../static/js/helpers/withStandardTabInfo';14import { BROWSER_PANELS } from '../../browser/static/js/constants';15import ObjectNodeProperties from './ObjectNodeProperties';16import EmptyPanelMessage from '../../static/js/components/EmptyPanelMessage';17import gettext from 'sources/gettext';18import { Box } from '@mui/material';19import { makeStyles } from '@mui/styles';20import { usePgAdmin } from '../../static/js/BrowserComponent';21import PropTypes from 'prop-types';22import _ from 'lodash';23 24const useStyles = makeStyles((theme) => ({25  root: {26    height: '100%',27    background: theme.otherVars.emptySpaceBg,28    display: 'flex',29    flexDirection: 'column'30  },31}));32 33function Properties(props) {34  const isCollection = props.nodeData?._type?.startsWith('coll-') || props.nodeData?._type == 'dbms_job_scheduler';35  const classes = useStyles();36  const pgAdmin = usePgAdmin();37  let noPropertyMsg = '';38 39  if (!props.node) {40    noPropertyMsg = gettext('Please select an object in the tree view.');41  } else if (!_.isUndefined(props.node.hasProperties) && !props.node.hasProperties) {42    noPropertyMsg = gettext('No information is available for the selected object.');43  }44 45  if(noPropertyMsg) {46    return (47      <Box className={classes.root}>48        <Box margin={'4px auto'}>49          <EmptyPanelMessage text={noPropertyMsg} />50        </Box>51      </Box>52    );53  }54 55  if(isCollection) {56    return (57      <Box className={classes.root}>58        <ErrorBoundary>59          <CollectionNodeProperties60            {...props}61          />62        </ErrorBoundary>63      </Box>64    );65  } else {66    return (67      <Box className={classes.root}>68        <ErrorBoundary>69          <ObjectNodeProperties70            {...props}71            actionType='properties'72            formType="tab"73            onEdit={()=>{74              pgAdmin.Browser.Node.callbacks.show_obj_properties.call(75                props.node, {action: 'edit'}76              );77            }}78          />79        </ErrorBoundary>80      </Box>81    );82  }83}84 85Properties.propTypes = {86  node: PropTypes.func,87  treeNodeInfo: PropTypes.object,88  nodeData: PropTypes.object,89  nodeItem: PropTypes.object,90};91 92export default withStandardTabInfo(Properties, BROWSER_PANELS.PROPERTIES);93 
codekingpro/portable-devtools · Team Ai