File size: 1,106 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { FormLabel } from '@automattic/components';
import { FormToggle } from '@wordpress/components';
import { sprintf } from '@wordpress/i18n';
import { useI18n } from '@wordpress/react-i18n';
import FormFieldset from 'calypso/components/forms/form-fieldset';

import './style.scss';

interface AutomatedDeploymentsToggleProps {
	onChange( value: boolean ): void;
	value: boolean;
	hasWorkflowPath: boolean;
}

export const AutomatedDeploymentsToggle = ( {
	onChange,
	value,
	hasWorkflowPath,
}: AutomatedDeploymentsToggleProps ) => {
	const { __ } = useI18n();

	return (
		<FormFieldset>
			<FormLabel htmlFor="is-automated">{ __( 'Automatic deployments' ) }</FormLabel>
			<div className="automated-deployments-toggle-switch">
				<FormToggle id="is-automated" onChange={ () => onChange( ! value ) } checked={ value } />
				{
					// Translators: %(condition)s is the when we are going to deploy the changes
					sprintf( __( 'Deploy changes on %(condition)s' ), {
						condition: hasWorkflowPath ? __( 'workflow run completion' ) : __( 'push' ),
					} )
				}
			</div>
		</FormFieldset>
	);
};