import type { FormikProps } from 'formik'; import React from 'react'; import type { Application } from '../../application'; import type { IServerGroupCommand } from '../../serverGroup'; import { toggleResourcePause } from './toggleResourceManagement'; export interface IDeployingIntoManagedClusterWarningProps { app: Application; formik: FormikProps; } export const DeployingIntoManagedClusterWarning = ({ app, formik }: IDeployingIntoManagedClusterWarningProps) => { const [userPaused, setUserPaused] = React.useState(false); const command = formik.values; const pauseResource = React.useCallback(() => { const { resourceSummary, backingData } = formik.values; if (!resourceSummary) return; toggleResourcePause(resourceSummary, app).then( () => { backingData.managedResources = app.getDataSource('managedResources')?.data?.resources; setUserPaused(true); formik.setFieldValue('resourceSummary', null); }, () => {}, ); }, [app, formik]); if (!command.resourceSummary && !userPaused) { return null; } if (userPaused) { return (
Resource management has been paused.
); } return (

🌈 Spinnaker is managing this resource.

Any changes you make to this cluster will be overridden in favor of the desired state.

If you need to manually deploy a new version of this server group, you should pause management.

); };