2024-11-28 07:55:32 +04:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
import Button from '@mui/material/Button'
|
|
|
|
|
import Dialog from '@mui/material/Dialog'
|
|
|
|
|
import DialogActions from '@mui/material/DialogActions'
|
|
|
|
|
import DialogContent from '@mui/material/DialogContent'
|
|
|
|
|
import DialogTitle from '@mui/material/DialogTitle'
|
|
|
|
|
import useMediaQuery from '@mui/material/useMediaQuery'
|
2025-07-23 17:41:15 +04:00
|
|
|
import IconButton from '@mui/material/IconButton'
|
|
|
|
|
import Typography from '@mui/material/Typography'
|
|
|
|
|
import Box from '@mui/material/Box'
|
|
|
|
|
import Chip from '@mui/material/Chip'
|
|
|
|
|
import CloseIcon from '@mui/icons-material/Close'
|
|
|
|
|
import CompareArrowsIcon from '@mui/icons-material/CompareArrows'
|
2024-11-28 07:55:32 +04:00
|
|
|
import {useTheme} from '@mui/material/styles'
|
|
|
|
|
import VersionComparison from './version-comparison.js'
|
|
|
|
|
|
2026-01-24 23:35:48 +04:00
|
|
|
export default function VersionDialog({versionData, versionCompare, isOpen, setIsOpen, onVoteSuccess}) {
|
2024-11-28 07:55:32 +04:00
|
|
|
const theme = useTheme()
|
|
|
|
|
const fullScreen = useMediaQuery(theme.breakpoints.down('md'))
|
|
|
|
|
|
|
|
|
|
const handleClose = () => {
|
|
|
|
|
setIsOpen(false)
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-23 17:41:15 +04:00
|
|
|
const outdated = versionCompare?.outdated || false
|
|
|
|
|
const versionName = versionData?.name || 'Version inconnue'
|
|
|
|
|
|
2024-11-28 07:55:32 +04:00
|
|
|
return (
|
|
|
|
|
<Dialog
|
|
|
|
|
fullScreen={fullScreen}
|
2025-07-23 17:41:15 +04:00
|
|
|
maxWidth='lg'
|
2024-11-28 07:55:32 +04:00
|
|
|
open={isOpen}
|
|
|
|
|
aria-labelledby='comparaison-des-versions'
|
|
|
|
|
onClose={handleClose}
|
|
|
|
|
>
|
2025-07-23 17:41:15 +04:00
|
|
|
<DialogTitle id='comparaison-des-versions'>
|
|
|
|
|
<Box sx={{display: 'flex', justifyContent: 'space-between', alignItems: 'center'}}>
|
|
|
|
|
<Box sx={{display: 'flex', alignItems: 'center', gap: 2}}>
|
|
|
|
|
<CompareArrowsIcon color='primary' />
|
|
|
|
|
<Typography variant='h6' component='span'>
|
|
|
|
|
Comparaison: {versionName}
|
|
|
|
|
</Typography>
|
|
|
|
|
<Chip
|
|
|
|
|
label={outdated ? 'Obsolète' : 'Active'}
|
|
|
|
|
color={outdated ? 'error' : 'success'}
|
|
|
|
|
size='small'
|
|
|
|
|
variant='outlined'
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
<IconButton
|
|
|
|
|
edge='end'
|
|
|
|
|
color='inherit'
|
|
|
|
|
aria-label='fermer'
|
|
|
|
|
onClick={handleClose}
|
|
|
|
|
>
|
|
|
|
|
<CloseIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Box>
|
2024-11-28 07:55:32 +04:00
|
|
|
</DialogTitle>
|
2025-07-23 17:41:15 +04:00
|
|
|
|
|
|
|
|
<DialogContent sx={{minHeight: '60vh'}}>
|
2026-01-24 23:35:48 +04:00
|
|
|
<VersionComparison versionData={versionData} versionCompare={versionCompare} onVoteSuccess={onVoteSuccess} />
|
2024-11-28 07:55:32 +04:00
|
|
|
</DialogContent>
|
2025-07-23 17:41:15 +04:00
|
|
|
|
|
|
|
|
<DialogActions sx={{px: 3, py: 2}}>
|
|
|
|
|
<Button
|
|
|
|
|
variant='contained'
|
|
|
|
|
color='error'
|
|
|
|
|
onClick={handleClose}
|
|
|
|
|
>
|
2024-11-28 07:55:32 +04:00
|
|
|
Fermer
|
|
|
|
|
</Button>
|
|
|
|
|
</DialogActions>
|
|
|
|
|
</Dialog>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VersionDialog.propTypes = {
|
2024-12-17 05:45:16 +04:00
|
|
|
versionData: PropTypes.object,
|
|
|
|
|
versionCompare: PropTypes.shape({
|
2024-11-28 07:55:32 +04:00
|
|
|
outdated: PropTypes.bool.isRequired,
|
|
|
|
|
mainHash: PropTypes.string.isRequired,
|
|
|
|
|
current: PropTypes.object.isRequired,
|
|
|
|
|
main: PropTypes.object.isRequired
|
|
|
|
|
}).isRequired,
|
|
|
|
|
isOpen: PropTypes.bool.isRequired,
|
2026-01-24 23:35:48 +04:00
|
|
|
setIsOpen: PropTypes.func.isRequired,
|
|
|
|
|
onVoteSuccess: PropTypes.func
|
2024-11-28 07:55:32 +04:00
|
|
|
}
|