import type { IReleasePlanTemplate } from 'interfaces/releasePlans'; import { ReleasePlan } from './ReleasePlan.tsx'; import { useReleasePlanPreview } from 'hooks/useReleasePlanPreview'; import { styled, Typography, Alert, Box, IconButton, Dialog, DialogActions, Button, } from '@mui/material'; import { useFeature } from 'hooks/api/getters/useFeature/useFeature'; import { useReleasePlans } from 'hooks/api/getters/useReleasePlans/useReleasePlans'; 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, height: '100%', }, })); const StyledScrollableContent = styled(Box)(({ theme }) => ({ width: theme.breakpoints.values.md, height: '100%', overflowY: 'auto', display: 'flex', flexDirection: 'column', })); const StyledHeader = styled(Box)(({ theme }) => ({ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: theme.spacing(4, 4, 2, 4), })); const StyledSubHeader = styled(Box)(({ theme }) => ({ padding: theme.spacing(0, 3, 3, 3), })); const StyledBackIcon = styled(ArrowBackIcon)(({ theme }) => ({ marginRight: theme.spacing(1), })); const StyledDialogActions = styled(DialogActions)(({ theme }) => ({ padding: theme.spacing(2, 4, 4), })); interface IReleasePlanAddDialogProps { open: boolean; setOpen: React.Dispatch>; onConfirm: () => void; template: IReleasePlanTemplate; projectId: string; featureName: string; environment: string; crProtected?: boolean; } export const ReleasePlanReviewDialog = ({ open, setOpen, onConfirm, template, projectId, featureName, environment, crProtected, }: IReleasePlanAddDialogProps) => { const { feature } = useFeature(projectId, featureName); const { releasePlans } = useReleasePlans( 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 ( Add strategy {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}. )} ); };