import type { IReleasePlanTemplate } from 'interfaces/releasePlans'; import { ReleasePlan } from './ReleasePlan.tsx'; import { useReleasePlanPreview } from 'hooks/useReleasePlanPreview'; import { styled, Typography, Alert, Box, IconButton, Dialog, DialogContent, DialogActions, Button, } from '@mui/material'; import { useFeature } from 'hooks/api/getters/useFeature/useFeature'; import { useFeatureReleasePlans } from 'hooks/api/getters/useFeatureReleasePlans/useFeatureReleasePlans'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; import CloseIcon from '@mui/icons-material/Close'; const StyledDialog = styled(Dialog)(({ theme }) => ({ '& .MuiDialog-paper': { borderRadius: theme.shape.borderRadiusLarge, maxWidth: theme.spacing(85), }, })); const StyledDialogActions = styled(DialogActions)(({ theme }) => ({ padding: theme.spacing(2, 4, 4), })); const TopRow = styled(Box)(({ theme }) => ({ display: 'flex', justifyContent: 'space-between', marginBottom: theme.spacing(2), })); const BackButton = styled(Box)(({ theme }) => ({ display: 'flex', alignItems: 'center', cursor: 'pointer', })); const StyledBackIcon = styled(ArrowBackIcon)(({ theme }) => ({ marginRight: theme.spacing(1), color: theme.palette.primary.main, display: 'flex', alignSelf: 'center', })); const BackText = styled(Typography)(({ theme }) => ({ fontWeight: theme.typography.fontWeightMedium, display: 'flex', alignItems: 'center', lineHeight: 1, })); interface IReleasePlanAddDialogProps { open: boolean; setOpen: React.Dispatch>; onConfirm: () => void; template: IReleasePlanTemplate; projectId: string; featureName: string; environment: string; crProtected?: boolean; } export const LegacyReleasePlanReviewDialog = ({ open, setOpen, onConfirm, template, projectId, featureName, environment, crProtected, }: IReleasePlanAddDialogProps) => { const { feature } = useFeature(projectId, featureName); const { releasePlans } = useFeatureReleasePlans( projectId, featureName, environment, ); const activeReleasePlan = releasePlans[0]; const environmentData = feature?.environments.find( ({ name }) => name === environment, ); const environmentEnabled = environmentData?.enabled; const planPreview = useReleasePlanPreview( template.id, featureName, environment, ); const handleClose = () => setOpen(false); return ( Go back {activeReleasePlan && ( This feature environment currently has{' '} {activeReleasePlan.name} -{' '} {activeReleasePlan.milestones[0].name} {environmentEnabled ? ' running' : ' paused'}. Adding a new release plan will replace the existing release plan. )}
{crProtected && ( Adding release template{' '} {template?.name} to{' '} {featureName} in{' '} {environment}. )}
); };