import { ApolloProvider } from '@apollo/client'; import { module } from 'angular'; import classNames from 'classnames'; import React from 'react'; import { react2angular } from 'react2angular'; import type { Application } from '../../application'; import { createApolloClient } from '../graphql/client'; import { FetchApplicationManagementDataDocument, useFetchApplicationManagementStatusQuery, useToggleManagementMutation, } from '../graphql/graphql-sdk'; import { withErrorBoundary } from '../../presentation/SpinErrorBoundary'; import { ValidationMessage } from '../../presentation/forms/validation'; import { logger } from '../../utils'; import { getDocsUrl } from '../utils/defaults'; import { Spinner } from '../../widgets/spinners/Spinner'; import './ManagedResourceConfig.less'; export interface IManagedResourceConfigProps { application: Application; } const logClick = (label: string, application: string) => logger.log({ category: 'Managed Resource Config', action: `${label} clicked`, data: { label: application }, }); const getManagementStatus = (paused: boolean) => { if (paused) { return ( <>
Resource management is paused.

Spinnaker is configured to manage some of this application's resources, but management has been paused. When resumed, Spinnaker will take action to make each resource match its desired state.

); } else { return ( <>

🌈 Spinnaker is managing some resources.

If you need to temporarily stop Spinnaker from managing resources — for example, if something is wrong and manual intervention is required — you can pause management and resume it later. Pausing affects all managed resources within this application.

); } }; const ManagedResourceConfigInternal = ({ application }: IManagedResourceConfigProps) => { const appName = application.name; const { data, loading } = useFetchApplicationManagementStatusQuery({ variables: { appName } }); const [toggleManagement, { loading: pausePending, error: pauseFailed }] = useToggleManagementMutation({ refetchQueries: [{ query: FetchApplicationManagementDataDocument, variables: { appName } }], }); if (loading) { return ; } if (!data) return null; const paused = Boolean(data?.application?.isPaused); const iconClass = paused ? 'fa-play' : 'fa-pause'; return (
{getManagementStatus(paused)} {pauseFailed && (
)}
Not sure what this means?{' '} logClick('Documentation', application.name)} href={getDocsUrl('root')}> Check out our documentation
); }; const ManagedResourceConfig = (props: IManagedResourceConfigProps) => { const { client } = React.useMemo(createApolloClient, []); return ( ); }; export const MANAGED_RESOURCE_CONFIG = 'spinnaker.core.managedResourceConfig.component'; module(MANAGED_RESOURCE_CONFIG, []).component( 'managedResourceConfig', react2angular(withErrorBoundary(ManagedResourceConfig, 'managedResourceConfig'), ['application']), );