Enhance TemplateEditor with error handling and popover support
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good

- Updated TemplateEditor to display compile error messages with a Popover for better user interaction.
- Introduced a new button with an icon to trigger the Popover, improving the visibility of error details.
- Adjusted the styling of the Alert component for consistent padding in error messages.
This commit is contained in:
Tom Butcher 2026-08-10 03:57:37 +01:00
parent 41385f7c5e
commit 3ed92a141b

View File

@ -8,9 +8,10 @@ import {
Splitter,
Button,
Modal,
Segmented
Segmented,
Popover
} from 'antd'
import { LoadingOutlined } from '@ant-design/icons'
import { LoadingOutlined, CaretDownOutlined } from '@ant-design/icons'
import ExclamationOctagonIcon from '../../Icons/ExclamationOctagonIcon.jsx'
import CheckCircleIcon from '../../Icons/CheckCircleIcon.jsx'
import ObjectProperty from '../common/ObjectProperty.jsx'
@ -32,7 +33,37 @@ const TemplateEditor = ({
//const isMobile = useMediaQuery({ maxWidth: 768 })
const handlePreviewMessage = useCallback((message, isError) => {
setPreviewMessage(message)
if (isError) {
setPreviewMessage(
<Flex gap={'small'} align={'center'} justify={'space-between'}>
Compile error.
<Popover
content={message}
trigger={['hover', 'click']}
placement='bottomRight'
arrow={false}
overlayStyle={{ width: '560px' }}
>
<Button
type={'text'}
size={'small'}
icon={
<CaretDownOutlined
style={{
marginLeft: '0.5px',
marginBottom: '2.5px',
fontSize: '12.5px'
}}
/>
}
/>
</Popover>
</Flex>
)
} else {
setPreviewMessage(message)
}
setPreviewError(isError)
}, [])
@ -67,7 +98,7 @@ const TemplateEditor = ({
<Alert
message={previewMessage}
showIcon
style={{ padding: '4px 8px' }}
style={{ padding: '4px 5px 4px 8px' }}
icon={
previewError ? (
<ExclamationOctagonIcon />