File size: 1,943 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { __experimentalText as Text, Button } from '@wordpress/components';
import { plus } from '@wordpress/icons';
import { useTranslate } from 'i18n-calypso';
import { useSiteHasEligiblePlugins } from './hooks/use-site-has-eligible-plugins';

interface Props {
	pluginsUrl: string;
	canCreateSchedules: boolean;
	onCreateNewSchedule?: () => void;
}
export const ScheduleListEmpty = ( props: Props ) => {
	const translate = useTranslate();

	const { pluginsUrl, onCreateNewSchedule, canCreateSchedules } = props;
	const { siteHasEligiblePlugins } = useSiteHasEligiblePlugins();

	return (
		<div className="empty-state">
			<Text as="p">
				{ ( () => {
					if ( ! siteHasEligiblePlugins && canCreateSchedules ) {
						return translate(
							'To set up schedules to update your plugins, first you need to install plugins that are not managed by the plugin provider.'
						);
					} else if ( ! canCreateSchedules ) {
						return translate( 'This site is unable to schedule auto-updates for plugins.' );
					}
					return translate(
						"Take control of your site's maintenance by choosing when your plugins update—whatever day and time is most convenient. Enjoy hassle-free automatic updates with our built-in rollback feature, reverting any flawed updates for added peace of mind."
					);
				} )() }
			</Text>
			{ ( () => {
				if ( ! siteHasEligiblePlugins && canCreateSchedules ) {
					return (
						<Button
							__next40pxDefaultSize
							variant={ canCreateSchedules ? 'primary' : 'secondary' }
							href={ pluginsUrl }
						>
							{ translate( 'Explore plugins' ) }
						</Button>
					);
				}
				return (
					<Button
						__next40pxDefaultSize
						icon={ plus }
						variant={ canCreateSchedules ? 'primary' : 'secondary' }
						onClick={ onCreateNewSchedule }
						disabled={ ! canCreateSchedules }
					>
						{ translate( 'Add new schedule' ) }
					</Button>
				);
			} )() }
		</div>
	);
};