-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scan pages sequentially and visualize current scan state
- Loading branch information
Showing
4 changed files
with
162 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { Selectable } from '../../../components/selectable'; | ||
import { IconLandscapeHillsCogs } from '../../../components/svg/landscape-hills-cogs'; | ||
|
||
/** | ||
* Screen with site scan summary. | ||
*/ | ||
export function SiteScanComplete() { | ||
return ( | ||
<div className="site-scan"> | ||
<Selectable> | ||
<div className="site-scan__header"> | ||
<IconLandscapeHillsCogs /> | ||
<p className="site-scan__heading"> | ||
{ __( 'Scan complete', 'amp' ) } | ||
</p> | ||
</div> | ||
<p> | ||
{ __( 'Site scan found issues on your site. Proceed to the next step to follow recommendations for choosing a template mode.', 'amp' ) } | ||
</p> | ||
</Selectable> | ||
</div> | ||
); | ||
} |
53 changes: 53 additions & 0 deletions
53
assets/src/onboarding-wizard/pages/site-scan/in-progress.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
import { useContext } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { SiteScan as SiteScanContext } from '../../../components/site-scan-context-provider'; | ||
import { Selectable } from '../../../components/selectable'; | ||
import { IconLandscapeHillsCogs } from '../../../components/svg/landscape-hills-cogs'; | ||
import { ProgressBar } from '../../../components/progress-bar'; | ||
|
||
/** | ||
* Screen for visualizing a site scan progress state. | ||
*/ | ||
export function SiteScanInProgress() { | ||
const { | ||
currentlyScannedUrlIndex, | ||
scannableUrls, | ||
siteScanComplete, | ||
} = useContext( SiteScanContext ); | ||
|
||
return ( | ||
<div className="site-scan"> | ||
<Selectable> | ||
<div className="site-scan__header"> | ||
<IconLandscapeHillsCogs /> | ||
<p className="site-scan__heading"> | ||
{ __( 'Please wait a minute…', 'amp' ) } | ||
</p> | ||
</div> | ||
<p> | ||
{ __( 'Site scan is checking if there are AMP compatibility issues with your active theme and plugins. We’ll then recommend how to use the AMP plugin.', 'amp' ) } | ||
</p> | ||
<ProgressBar value={ siteScanComplete | ||
? 100 | ||
: ( currentlyScannedUrlIndex / scannableUrls.length * 100 ) | ||
} /> | ||
<p> | ||
{ sprintf( | ||
// translators: 1: currently scanned URL index; 2: scannable URLs count; 3: scanned page type. | ||
__( 'Scanning %1$d/%2$d URLs: Checking %3$s…', 'amp' ), | ||
currentlyScannedUrlIndex + 1, | ||
scannableUrls.length, | ||
scannableUrls[ currentlyScannedUrlIndex ]?.type, | ||
) } | ||
</p> | ||
</Selectable> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,49 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { useContext, useEffect } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './style.scss'; | ||
import { Navigation } from '../../components/navigation-context-provider'; | ||
import { Selectable } from '../../../components/selectable'; | ||
import { IconLandscapeHillsCogs } from '../../../components/svg/landscape-hills-cogs'; | ||
import { SiteScan as SiteScanContext } from '../../../components/site-scan-context-provider'; | ||
import { SiteScanComplete } from './complete'; | ||
import { SiteScanInProgress } from './in-progress'; | ||
|
||
/** | ||
* Screen for visualizing a site scan. | ||
*/ | ||
export function SiteScan() { | ||
const { setCanGoForward } = useContext( Navigation ); | ||
const { | ||
canScanSite, | ||
startSiteScan, | ||
siteScanComplete, | ||
} = useContext( SiteScanContext ); | ||
|
||
/** | ||
* Start site scan. | ||
*/ | ||
useEffect( () => { | ||
if ( canScanSite ) { | ||
startSiteScan(); | ||
} | ||
}, [ canScanSite, startSiteScan ] ); | ||
|
||
/** | ||
* Allow moving forward. | ||
*/ | ||
useEffect( () => { | ||
// @todo: Allow moving forward once the scan is complete. | ||
if ( true ) { | ||
if ( siteScanComplete ) { | ||
setCanGoForward( true ); | ||
} | ||
}, [ setCanGoForward ] ); | ||
}, [ setCanGoForward, siteScanComplete ] ); | ||
|
||
if ( siteScanComplete ) { | ||
return <SiteScanComplete />; | ||
} | ||
|
||
return ( | ||
<div className="site-scan"> | ||
<Selectable> | ||
<div className="site-scan__header"> | ||
<IconLandscapeHillsCogs /> | ||
<p className="site-scan__heading"> | ||
{ __( 'Please wait a minute ...', 'amp' ) } | ||
</p> | ||
</div> | ||
<p> | ||
{ __( 'Site scan is checking if there are AMP compatibility issues with your active theme and plugins. We’ll then recommend how to use the AMP plugin.', 'amp' ) } | ||
</p> | ||
</Selectable> | ||
</div> | ||
); | ||
return <SiteScanInProgress />; | ||
} |