import { useState } from 'react'; import { Modal, openModal } from '@@/modals'; import { Button } from '@@/buttons'; import { SwitchField } from '@@/form-components/SwitchField'; function UpdateIngressPrompt({ onSubmit, title, hasOneIngress, hasOnePort, }: { onSubmit: (value?: { noMatch: boolean }) => void; title: string; hasOneIngress: boolean; hasOnePort: boolean; }) { const [value, setValue] = useState(false); const rulePlural = !hasOneIngress ? 'rules' : 'rule'; const noMatchSentence = !hasOnePort ? `Service ports in this application no longer match the ingress ${rulePlural}.` : `A service port in this application no longer matches the ingress ${rulePlural} which may break ingress rule paths.`; const inputLabel = `Update ingress ${rulePlural} to match the service port changes`; return ( onSubmit()} aria-label={title}>
  • Updating the application may cause a service interruption.
  • {noMatchSentence}
); } export function confirmUpdateAppIngress( ingressesToUpdate: Array, servicePortsToUpdate: Array ) { const hasOneIngress = ingressesToUpdate.length === 1; const hasOnePort = servicePortsToUpdate.length === 1; return openModal(UpdateIngressPrompt, { title: 'Are you sure?', hasOneIngress, hasOnePort, }); }