@@ -108,6 +108,8 @@ export function siteScanReducer( state, action ) {
108108 ...state ,
109109 status : STATUS_REQUEST_SCANNABLE_URLS ,
110110 forceStandardMode : action ?. forceStandardMode ?? false ,
111+ currentlyScannedUrlIndexes : [ ] ,
112+ urlIndexesPendingScan : [ ] ,
111113 } ;
112114 }
113115 case ACTION_SCANNABLE_URLS_RECEIVE : {
@@ -195,16 +197,18 @@ export function siteScanReducer( state, action ) {
195197/**
196198 * Context provider for site scanning.
197199 *
198- * @param {Object } props Component props.
199- * @param {?any } props.children Component children.
200- * @param {boolean } props.fetchCachedValidationErrors Whether to fetch cached validation errors on mount.
201- * @param {boolean } props.resetOnOptionsChange Whether to reset scanner and refetch scannable URLs whenever AMP options are changed.
202- * @param {string } props.scannableUrlsRestPath The REST path for interacting with the scannable URL resources.
203- * @param {string } props.validateNonce The AMP validate nonce.
200+ * @param {Object } props Component props.
201+ * @param {?any } props.children Component children.
202+ * @param {boolean } props.fetchCachedValidationErrors Whether to fetch cached validation errors on mount.
203+ * @param {boolean } props.refetchPluginSuppressionOnScanComplete Whether to refetch plugin suppression data when site scan is complete.
204+ * @param {boolean } props.resetOnOptionsChange Whether to reset scanner and refetch scannable URLs whenever AMPoptions are changed.
205+ * @param {string } props.scannableUrlsRestPath The REST path for interacting with the scannable URL resources.
206+ * @param {string } props.validateNonce The AMP validate nonce.
204207 */
205208export function SiteScanContextProvider ( {
206209 children,
207210 fetchCachedValidationErrors = false ,
211+ refetchPluginSuppressionOnScanComplete = false ,
208212 resetOnOptionsChange = false ,
209213 scannableUrlsRestPath,
210214 validateNonce,
@@ -301,7 +305,6 @@ export function SiteScanContextProvider( {
301305 */
302306 useEffect ( ( ) => {
303307 if ( resetOnOptionsChange && Object . keys ( savedOptions ) . length > 0 ) {
304- dispatch ( { type : ACTION_SCAN_CANCEL } ) ;
305308 dispatch ( { type : ACTION_SCANNABLE_URLS_REQUEST } ) ;
306309 }
307310 } , [ resetOnOptionsChange , savedOptions ] ) ;
@@ -316,6 +319,25 @@ export function SiteScanContextProvider( {
316319 }
317320 } , [ savedOptions ?. suppressed_plugins , status ] ) ;
318321
322+ /**
323+ * Once the site scan is complete, refetch the plugin suppression data so
324+ * that the suppressed table is updated with the latest validation errors.
325+ */
326+ useEffect ( ( ) => {
327+ if ( status !== STATUS_REFETCHING_PLUGIN_SUPPRESSION ) {
328+ return ;
329+ }
330+
331+ if ( refetchPluginSuppressionOnScanComplete ) {
332+ refetchPluginSuppression ( ) ;
333+ }
334+
335+ dispatch ( {
336+ type : ACTION_SET_STATUS ,
337+ status : STATUS_COMPLETED ,
338+ } ) ;
339+ } , [ refetchPluginSuppression , refetchPluginSuppressionOnScanComplete , status ] ) ;
340+
319341 /**
320342 * Delay concurrent validation requests.
321343 */
@@ -344,20 +366,6 @@ export function SiteScanContextProvider( {
344366 } ;
345367 } , [ shouldDelayValidationRequest ] ) ;
346368
347- /**
348- * Once the site scan is complete, refetch the plugin suppression data so
349- * that the suppressed table is updated with the latest validation errors.
350- */
351- useEffect ( ( ) => {
352- if ( status === STATUS_REFETCHING_PLUGIN_SUPPRESSION ) {
353- refetchPluginSuppression ( ) ;
354- dispatch ( {
355- type : ACTION_SET_STATUS ,
356- status : STATUS_COMPLETED ,
357- } ) ;
358- }
359- } , [ refetchPluginSuppression , status ] ) ;
360-
361369 /**
362370 * Fetch scannable URLs from the REST endpoint.
363371 */
@@ -484,6 +492,7 @@ export function SiteScanContextProvider( {
484492 value = { {
485493 cancelSiteScan,
486494 fetchScannableUrls,
495+ forceStandardMode,
487496 hasSiteScanResults,
488497 isBusy : [ STATUS_IDLE , STATUS_IN_PROGRESS ] . includes ( status ) ,
489498 isCancelled : status === STATUS_CANCELLED ,
@@ -511,6 +520,7 @@ export function SiteScanContextProvider( {
511520SiteScanContextProvider . propTypes = {
512521 children : PropTypes . any ,
513522 fetchCachedValidationErrors : PropTypes . bool ,
523+ refetchPluginSuppressionOnScanComplete : PropTypes . bool ,
514524 resetOnOptionsChange : PropTypes . bool ,
515525 scannableUrlsRestPath : PropTypes . string ,
516526 validateNonce : PropTypes . string ,
0 commit comments