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