Files
pgadmin4/web/pgadmin/static/js/ToolErrorView.jsx
T
Yogesh Mahajan 82730da392 Fixed following issues reported while testing application restore changes: #8901
1. Preserve updated tab titles on session restore
2. Ensure query tools opened via the 'Generate Script' are editable.
3. On restore, ensure the query content is correctly loaded into the query tool when it is opened from tools like ERD.
2025-07-17 16:28:57 +05:30

38 lines
1.2 KiB
React

import PropTypes from 'prop-types';
import React from 'react';
import gettext from 'sources/gettext';
import { LAYOUT_EVENTS } from './helpers/Layout';
import { styled } from '@mui/material/styles';
import { FormHelperText, Box } from '@mui/material';
import HTMLReactParse from 'html-react-parser';
import { useApplicationState } from '../../settings/static/ApplicationStateProvider';
const StyledBox = styled(Box)(({theme}) => ({
color: theme.palette.text.primary,
margin: '24px auto 12px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: '100%',
}));
export default function ToolErrorView({error, panelId, panelDocker}){
const { deleteToolData } = useApplicationState();
panelDocker.eventBus.registerListener(LAYOUT_EVENTS.CLOSING, (id)=>{
if(panelId == id) {
panelDocker.close(panelId, true);
deleteToolData(panelId);
}
});
let err_msg = gettext(`An error occurred while opening the tool: ${error}`);
return (<StyledBox>
<FormHelperText variant="outlined" error= {true} style={{marginLeft: '4px'}} >{HTMLReactParse(err_msg)}</FormHelperText>
</StyledBox>);
}
ToolErrorView.propTypes = {
error: PropTypes.string,
panelId: PropTypes.string,
panelDocker: PropTypes.object,
};