AddonRowActions.jsx
6 days ago
AddonsList.jsx
6 days ago
AllAccessAddonsSummary.jsx
6 days ago
AutoUpdateModal.jsx
6 days ago
DownloadActivateButton.jsx
6 days ago
EmptyState.jsx
6 days ago
FeatureList.jsx
6 days ago
LicenseField.jsx
6 days ago
LicenseItem.jsx
6 days ago
LicenseNotices.jsx
6 days ago
LicenseStatus.jsx
6 days ago
Loader.jsx
6 days ago
PricingModal.jsx
6 days ago
PricingTable.jsx
6 days ago
PricingTableItem.jsx
6 days ago
SitesModal.jsx
6 days ago
AutoUpdateModal.jsx
83 lines
| 1 | /** |
| 2 | * WordPress Dependencies |
| 3 | */ |
| 4 | import { __ } from '@wordpress/i18n'; |
| 5 | import { Modal, ToggleControl } from '@wordpress/components'; |
| 6 | |
| 7 | /** |
| 8 | * Internal Dependencies |
| 9 | */ |
| 10 | import { LICENSE_ADDON_CATALOG } from '../addon-catalog'; |
| 11 | |
| 12 | /** |
| 13 | * @param {Object} props |
| 14 | * @param {Array} props.toggles Rows: { addonId, label?, enabled }. |
| 15 | * @param {Function} props.onToggle ( addonId, enabled ) => void. |
| 16 | * @param {string} [props.savingId] Add-on id currently saving. |
| 17 | * @param {Function} props.onClose Close handler. |
| 18 | */ |
| 19 | export function AutoUpdateModal( { toggles, onToggle, savingId = '', onClose } ) { |
| 20 | const isSingle = toggles.length === 1; |
| 21 | |
| 22 | return ( |
| 23 | <Modal |
| 24 | title={ __( 'Plugin auto-updates', 'advanced-ads' ) } |
| 25 | size="small" |
| 26 | onRequestClose={ onClose } |
| 27 | shouldCloseOnEscape={ true } |
| 28 | shouldCloseOnClickOutside={ false } |
| 29 | className="advads-modal mt-auto w-lg max-w-lg" |
| 30 | overlayClassName="bg-black/50 backdrop-blur-[1px]" |
| 31 | > |
| 32 | <div className="space-y-4"> |
| 33 | { toggles.map( ( toggle ) => { |
| 34 | const { addonId, enabled } = toggle; |
| 35 | const label = |
| 36 | toggle.label ?? |
| 37 | LICENSE_ADDON_CATALOG[ addonId ]?.title ?? |
| 38 | ( addonId === 'main' |
| 39 | ? __( 'Advanced Ads', 'advanced-ads' ) |
| 40 | : addonId ); |
| 41 | const isSaving = savingId === addonId; |
| 42 | |
| 43 | return ( |
| 44 | <ToggleControl |
| 45 | key={ addonId } |
| 46 | checked={ enabled } |
| 47 | disabled={ isSaving } |
| 48 | label={ |
| 49 | isSingle |
| 50 | ? __( |
| 51 | 'Enable plugin auto-updates', |
| 52 | 'advanced-ads' |
| 53 | ) |
| 54 | : label |
| 55 | } |
| 56 | help={ |
| 57 | isSingle |
| 58 | ? __( |
| 59 | "When enabled, updates are automatically installed. When off, you'll be notified when updates are available to install.", |
| 60 | 'advanced-ads' |
| 61 | ) |
| 62 | : undefined |
| 63 | } |
| 64 | onChange={ ( checked ) => |
| 65 | onToggle( addonId, checked ) |
| 66 | } |
| 67 | /> |
| 68 | ); |
| 69 | } ) } |
| 70 | </div> |
| 71 | <div className="flex justify-end mt-4"> |
| 72 | <button |
| 73 | type="button" |
| 74 | className="button advads-button-secondary" |
| 75 | onClick={ onClose } |
| 76 | > |
| 77 | { __( 'Close', 'advanced-ads' ) } |
| 78 | </button> |
| 79 | </div> |
| 80 | </Modal> |
| 81 | ); |
| 82 | } |
| 83 |