PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / 2.0.25
Advanced Ads – Ad Manager & AdSense v2.0.25
2.0.25 2.0.24 2.0.23 2.0.22 2.0.21 1.38.0 1.39.0 1.39.1 1.39.2 1.39.3 1.39.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.40.0 1.40.1 1.40.2 1.41.0 1.42.0 1.42.1 1.42.2 1.43.0 1.44.0 1.44.1 1.45.0 1.45.1 1.46.0 1.47.0 1.47.1 1.47.2 1.47.3 1.47.4 1.47.5 1.48.0 1.48.1 1.49.0 1.5.0 1.5.0.1 1.5.1 1.5.2 1.5.2.1 1.5.4 1.5.4.1 1.5.5 1.50.0 1.51.0 1.51.1 1.51.2 1.51.3 1.52.0 1.52.1 1.52.2 1.52.3 1.52.4 1.53.0 1.53.1 1.53.2 1.54.0 1.54.1 1.55.0 1.56.0 1.56.1 1.56.2 1.56.3 1.56.4 1.6 1.6.1 1.6.10 1.6.10.1 1.6.10.2 1.6.11 1.6.11.1 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.17.1 1.6.17.2 1.6.2 1.6.2.1 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.6.1 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.6.8.3 1.6.9 1.6.9.1 1.6.9.2 1.6.9.3 1.6.9.4 1.7 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.1.1 1.7.1.2 1.7.1.3 1.7.1.4 1.7.1.5 1.7.10 trunk 1.7.11 1.0.1 1.7.12 1.0.2 1.7.13 1.0.3 1.7.14 1.1.0 1.7.15 1.1.1 1.7.16 1.1.2 1.7.17 1.1.3 1.7.18 1.10 1.7.19 1.10.1 1.7.2 1.10.10 1.7.2.1 1.10.11 1.7.20 1.10.12 1.7.21 1.10.2 1.7.22 1.10.3 1.7.23 1.10.4 1.7.24 1.10.5 1.7.25 1.10.6 1.7.3 1.10.7 1.7.4 1.10.8 1.7.4.1 1.10.9 1.7.4.2 1.11 1.7.4.3 1.11.1 1.7.4.4 1.11.2 1.7.4.5 1.12 1.7.5 1.13 1.7.5.1 1.13.1 1.7.6 1.13.2 1.7.7 1.13.3 1.7.8 1.13.4 1.7.9 1.13.5 1.7.9.1 1.13.6 1.7.9.2 1.13.7 1.7.9.3 1.13.8 1.8 1.14 1.8.1 1.14.1 1.8.10 1.14.10 1.8.11 1.14.11 1.8.12 1.14.2 1.8.13 1.14.3 1.8.14 1.14.4 1.8.15 1.14.5 1.8.16 1.14.6 1.8.17 1.14.7 1.8.18 1.14.8 1.8.19 1.14.9 1.8.2 1.15 1.8.20 1.16 1.8.21 1.16.1 1.8.22 1.17 1.8.23 1.17.1 1.8.24 1.17.10 1.8.25 1.17.10-rc.1 1.8.26 1.17.11 1.8.27 1.17.12 1.8.28 1.17.12-rc.1 1.8.29 1.17.2 1.8.3 1.17.3 1.8.30 1.17.4 1.8.4 1.17.5 1.8.5 1.17.6 1.8.6 1.17.7 1.8.7 1.17.8 1.8.8 1.17.9 1.8.9 1.17.9-beta.1 1.9 1.18.0 2.0.0 1.19.0 2.0.1 1.19.1 2.0.10 1.2 2.0.11 1.2.1 2.0.12 1.2.2 2.0.13 1.2.3 2.0.14 1.2.4 2.0.15 1.2.5 2.0.16 1.2.6 2.0.17 1.2.7 2.0.18 1.20.0 2.0.19 1.20.0-rc.1 2.0.2 1.20.0-rc.2 2.0.20 1.20.1 2.0.3 1.20.2 2.0.4 1.20.3 2.0.5 1.21.0 2.0.6 1.21.1 2.0.7 1.22.0 2.0.8 1.22.1 2.0.9 1.22.2 1.23.0 1.23.1 1.23.2 1.24.0 1.24.1 1.24.2 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.29.0 1.29.1 1.3 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.30.0 1.30.1 1.30.2 1.30.2-rc.1 1.30.3 1.30.4 1.30.4-rc.1 1.30.5 1.31.0 1.31.1 1.32.0 1.32.0-rc.1 1.33.0 1.33.1 1.33.2 1.34.0 1.35.0 1.35.1 1.36.0 1.36.1 1.36.2 1.36.3 1.37.0 1.37.1 1.37.2
advanced-ads / src / admin / screen-licenses / components / AddonsList.jsx
advanced-ads / src / admin / screen-licenses / components Last commit date
AddonRowActions.jsx 1 week ago AddonsList.jsx 1 week ago AllAccessAddonsSummary.jsx 1 week ago AutoUpdateModal.jsx 1 week ago DownloadActivateButton.jsx 1 week ago EmptyState.jsx 1 week ago FeatureList.jsx 1 week ago LicenseField.jsx 1 week ago LicenseItem.jsx 1 week ago LicenseNotices.jsx 1 week ago LicenseStatus.jsx 1 week ago Loader.jsx 1 week ago PricingModal.jsx 1 week ago PricingTable.jsx 1 week ago PricingTableItem.jsx 1 week ago SitesModal.jsx 1 week ago
AddonsList.jsx
219 lines
1 /**
2 * External Dependencies
3 */
4 import { __, sprintf } from '@wordpress/i18n';
5 import { ChevronDown } from 'lucide-react';
6 import { useId, useState } from '@wordpress/element';
7 import { useSelect } from '@wordpress/data';
8
9 /**
10 * Internal Dependencies
11 */
12 import { getIncludedAddonsForLicense } from '../addon-catalog';
13 import {
14 getLicenseNameForKey,
15 isAddonLicensedByKey,
16 isAddonManagedByOtherLicense,
17 isAllAccessBundleName,
18 isLicenseAppliedOnThisSite,
19 isRichLicenseEntitled,
20 } from '../utils';
21 import { STORE_NAME } from '@admin/store';
22 import { AddonRowActions } from './AddonRowActions';
23
24 function AddonItem( {
25 addon,
26 licenseKey,
27 licenses,
28 isApplied,
29 canUseAddonActions,
30 managedByOtherLicense,
31 managingLicenseName,
32 licenseAppliedOnSite,
33 noticesContext,
34 addonInstallStates,
35 installingAddonId,
36 failedAddonIds,
37 onInstallStart,
38 onInstallEnd,
39 } ) {
40 const { id, title, description, icon, learnMore, manualUrl, downloadUrl } =
41 addon;
42
43 return (
44 <div className="relative border border-border bg-white p-3 rounded-lg flex flex-wrap flex-row gap-3 md:items-center">
45 <div className="flex items-center justify-center p-2 size-8 bg-gray-200 rounded-lg grow-0">
46 <img src={ icon } alt="" className="size-4" />
47 </div>
48 <div className="shrink-0 flex-1">
49 <strong>{ title }</strong>
50 <p className="flex flex-wrap items-center gap-x-1 m-0 mt-1 text-gray-500">
51 { description }
52 <a
53 href={ learnMore }
54 target="_blank"
55 rel="noopener noreferrer"
56 className="no-underline"
57 >
58 { __( 'Learn more', 'advanced-ads' ) }
59 </a>
60 <span>|</span>
61 <a
62 href={ manualUrl }
63 target="_blank"
64 rel="noopener noreferrer"
65 className="no-underline"
66 >
67 { __( 'Manual', 'advanced-ads' ) }
68 </a>
69 </p>
70 </div>
71 <div className="basis-full sm:basis-auto sm:ml-auto">
72 <AddonRowActions
73 addonId={ id }
74 licenseKey={ licenseKey }
75 licenses={ licenses }
76 downloadUrl={ downloadUrl }
77 isApplied={ isApplied }
78 disabled={ ! canUseAddonActions }
79 managedByOtherLicense={ managedByOtherLicense }
80 managingLicenseName={ managingLicenseName }
81 licenseAppliedOnSite={ licenseAppliedOnSite }
82 addonInstallStates={ addonInstallStates }
83 noticesContext={ noticesContext }
84 isInstalling={ installingAddonId === id }
85 installFailed={ failedAddonIds.has( id ) }
86 onInstallStart={ onInstallStart }
87 onInstallEnd={ onInstallEnd }
88 />
89 </div>
90 </div>
91 );
92 }
93
94 export function AddonsList( {
95 license,
96 allLicenses = [],
97 appliedAddonKeyMap = {},
98 currentHostname = '',
99 noticesContext,
100 canUseAddonActions = false,
101 } ) {
102 const addonsId = useId();
103 const [ addOnsOpen, setAddOnsOpen ] = useState( true );
104 const [ installingAddonId, setInstallingAddonId ] = useState( '' );
105 const [ failedAddonIds, setFailedAddonIds ] = useState( () => new Set() );
106
107 const addonInstallStates = useSelect(
108 ( select ) => select( STORE_NAME ).getAddonInstallStates(),
109 []
110 );
111
112 if ( ! isAllAccessBundleName( license?.name ) ) {
113 return null;
114 }
115
116 const includedAddons = getIncludedAddonsForLicense( license );
117 if ( ! includedAddons.length ) {
118 return null;
119 }
120
121 const licenseKey = String( license?.licenseKey ?? '' );
122 const licenseAppliedOnSite = isLicenseAppliedOnThisSite(
123 license,
124 allLicenses,
125 currentHostname,
126 appliedAddonKeyMap,
127 addonInstallStates
128 );
129
130 function handleInstallStart( addonId ) {
131 setInstallingAddonId( addonId );
132 }
133
134 function handleInstallEnd( addonId, failed ) {
135 setInstallingAddonId( '' );
136 if ( failed ) {
137 setFailedAddonIds( ( prev ) => new Set( prev ).add( addonId ) );
138 } else {
139 setFailedAddonIds( ( prev ) => {
140 const next = new Set( prev );
141 next.delete( addonId );
142 return next;
143 } );
144 }
145 }
146
147 return (
148 <div className="mt-6 xl:ml-30">
149 <button
150 type="button"
151 id={ addonsId }
152 className="is-ghost"
153 onClick={ () => setAddOnsOpen( ( open ) => ! open ) }
154 aria-expanded={ addOnsOpen }
155 >
156 { sprintf(
157 /* translators: %d: Number of included add-ons. */
158 __( 'Included add-ons (%d)', 'advanced-ads' ),
159 includedAddons.length
160 ) }
161 <ChevronDown
162 className={ `h-4 w-4 shrink-0 transition-transform ${
163 addOnsOpen ? 'rotate-180' : ''
164 }` }
165 strokeWidth={ 2 }
166 aria-hidden
167 />
168 </button>
169 { addOnsOpen ? (
170 <section
171 className="mt-6 space-y-6"
172 aria-labelledby={ addonsId }
173 >
174 { includedAddons.map( ( addon ) => {
175 const isLicensedByThisKey = isAddonLicensedByKey(
176 addon.id,
177 licenseKey,
178 appliedAddonKeyMap
179 );
180 const managedByOther = isAddonManagedByOtherLicense(
181 addon.id,
182 licenseKey,
183 appliedAddonKeyMap
184 );
185 const managingKey = managedByOther
186 ? String(
187 appliedAddonKeyMap?.[ addon.id ] ?? ''
188 )
189 : '';
190
191 return (
192 <AddonItem
193 key={ addon.id }
194 addon={ addon }
195 licenseKey={ licenseKey }
196 licenses={ allLicenses }
197 isApplied={ isLicensedByThisKey }
198 canUseAddonActions={ canUseAddonActions }
199 managedByOtherLicense={ managedByOther }
200 managingLicenseName={ getLicenseNameForKey(
201 managingKey,
202 allLicenses
203 ) }
204 licenseAppliedOnSite={ licenseAppliedOnSite }
205 noticesContext={ noticesContext }
206 addonInstallStates={ addonInstallStates }
207 installingAddonId={ installingAddonId }
208 failedAddonIds={ failedAddonIds }
209 onInstallStart={ handleInstallStart }
210 onInstallEnd={ handleInstallEnd }
211 />
212 );
213 } ) }
214 </section>
215 ) : null }
216 </div>
217 );
218 }
219