Skip to content

Commit e0e4014

Browse files
authored
Merge pull request #6789 from ampproject/remove/onboarding-technical-brackground
Skip Technical Background step if there is no dependency support
2 parents c783807 + 2876411 commit e0e4014

File tree

2 files changed

+30
-18
lines changed

2 files changed

+30
-18
lines changed

assets/src/onboarding-wizard/components/navigation-context-provider.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { createContext, useState, useContext, useMemo } from '@wordpress/element
77
* External dependencies
88
*/
99
import PropTypes from 'prop-types';
10+
import { HAS_DEPENDENCY_SUPPORT } from 'amp-settings'; // From WP inline script.
11+
1012
/**
1113
* Internal dependencies
1214
*/
@@ -31,17 +33,16 @@ export function NavigationContextProvider( { children, pages } ) {
3133

3234
const { theme_support: themeSupport } = editedOptions;
3335

34-
const adaptedPages = useMemo( () => pages.filter( ( page ) => {
35-
if ( READER !== themeSupport && 'theme-selection' === page.slug ) {
36-
return false;
37-
}
36+
const adaptedPages = useMemo( () => pages.filter( ( page ) => (
37+
// Do not show the Technical Background step is there is no dependency support.
38+
! ( 'technical-background' === page.slug && ! HAS_DEPENDENCY_SUPPORT ) &&
3839

39-
if ( isSkipped && 'site-scan' === page.slug ) {
40-
return false;
41-
}
40+
// If Site Scan should be skipped, do not show the relevant step in the Wizard.
41+
! ( 'site-scan' === page.slug && isSkipped ) &&
4242

43-
return true;
44-
} ), [ isSkipped, pages, themeSupport ] );
43+
// Theme Selection page should be only accessible for the Reader template mode.
44+
! ( 'theme-selection' === page.slug && READER !== themeSupport )
45+
) ), [ isSkipped, pages, themeSupport ] );
4546

4647
const activePageIndex = adaptedPages.findIndex( ( adaptedPage ) => adaptedPage.slug === currentPage.slug );
4748

src/Admin/OnboardingWizardSubmenuPage.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use AMP_Options_Manager;
1212
use AMP_Validated_URL_Post_Type;
1313
use AMP_Validation_Manager;
14+
use AmpProject\AmpWP\DependencySupport;
1415
use AmpProject\AmpWP\DevTools\UserAccess;
1516
use AmpProject\AmpWP\Infrastructure\Delayed;
1617
use AmpProject\AmpWP\Infrastructure\Registerable;
@@ -72,19 +73,28 @@ final class OnboardingWizardSubmenuPage implements Delayed, Registerable, Servic
7273
*/
7374
private $loading_error;
7475

76+
/**
77+
* DependencySupport instance.
78+
*
79+
* @var DependencySupport
80+
*/
81+
private $dependency_support;
82+
7583
/**
7684
* OnboardingWizardSubmenuPage constructor.
7785
*
78-
* @param GoogleFonts $google_fonts An instance of the GoogleFonts service.
79-
* @param ReaderThemes $reader_themes An instance of the ReaderThemes class.
80-
* @param RESTPreloader $rest_preloader An instance of the RESTPreloader class.
81-
* @param LoadingError $loading_error An instance of the LoadingError class.
86+
* @param GoogleFonts $google_fonts An instance of the GoogleFonts service.
87+
* @param ReaderThemes $reader_themes An instance of the ReaderThemes class.
88+
* @param RESTPreloader $rest_preloader An instance of the RESTPreloader class.
89+
* @param LoadingError $loading_error An instance of the LoadingError class.
90+
* @param DependencySupport $dependency_support An instance of the DependencySupport class.
8291
*/
83-
public function __construct( GoogleFonts $google_fonts, ReaderThemes $reader_themes, RESTPreloader $rest_preloader, LoadingError $loading_error ) {
84-
$this->google_fonts = $google_fonts;
85-
$this->reader_themes = $reader_themes;
86-
$this->rest_preloader = $rest_preloader;
87-
$this->loading_error = $loading_error;
92+
public function __construct( GoogleFonts $google_fonts, ReaderThemes $reader_themes, RESTPreloader $rest_preloader, LoadingError $loading_error, DependencySupport $dependency_support ) {
93+
$this->google_fonts = $google_fonts;
94+
$this->reader_themes = $reader_themes;
95+
$this->rest_preloader = $rest_preloader;
96+
$this->loading_error = $loading_error;
97+
$this->dependency_support = $dependency_support;
8898
}
8999

90100
/**
@@ -250,6 +260,7 @@ public function enqueue_assets( $hook_suffix ) {
250260
'screenshot' => $theme->get_screenshot() ?: null,
251261
'url' => $theme->get( 'ThemeURI' ),
252262
],
263+
'HAS_DEPENDENCY_SUPPORT' => $this->dependency_support->has_support(),
253264
'USING_FALLBACK_READER_THEME' => $this->reader_themes->using_fallback_theme(),
254265
'SCANNABLE_URLS_REST_PATH' => '/amp/v1/scannable-urls',
255266
'SETTINGS_LINK' => $amp_settings_link,

0 commit comments

Comments
 (0)