From 8bad40170fc88d8de3248dd2fdbf2d00a2e8fb57 Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Mon, 13 May 2024 14:00:21 +0200 Subject: [PATCH] Add check for supported enginers to import CaptureStep --- client/blocks/import/capture/index.tsx | 7 ++++++- client/lib/importer/importer-config.tsx | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/client/blocks/import/capture/index.tsx b/client/blocks/import/capture/index.tsx index 58a02ee79faca..5fad33078de2c 100644 --- a/client/blocks/import/capture/index.tsx +++ b/client/blocks/import/capture/index.tsx @@ -4,6 +4,7 @@ import { useEffect } from '@wordpress/element'; import { useTranslate } from 'i18n-calypso'; import React, { useRef, useState } from 'react'; import { useAnalyzeUrlQuery } from 'calypso/data/site-profiler/use-analyze-url-query'; +import { isSupportedImporterEngine } from 'calypso/lib/importer/importer-config'; import { triggerMigrationStartingEvent } from 'calypso/my-sites/migrate/helpers'; import { useSelector } from 'calypso/state'; import { getCurrentUser, getCurrentUserCountryCode } from 'calypso/state/current-user/selectors'; @@ -99,7 +100,11 @@ export const CaptureStep: React.FunctionComponent< StepProps > = ( { break; default: - stepSectionName = 'preview'; + if ( ! isSupportedImporterEngine( urlData.platform ) ) { + stepSectionName = 'not'; + } else { + stepSectionName = 'preview'; + } break; } diff --git a/client/lib/importer/importer-config.tsx b/client/lib/importer/importer-config.tsx index a483efc5b6c79..3d80a92025faa 100644 --- a/client/lib/importer/importer-config.tsx +++ b/client/lib/importer/importer-config.tsx @@ -327,4 +327,10 @@ export function getImporterByKey( return filter( getImporters( args ), ( importer ) => importer.key === key )[ 0 ]; } +export function isSupportedImporterEngine( engine: string ): boolean { + const allImporters = getImporters(); + + return allImporters.some( ( importer ) => importer.engine === engine ); +} + export default getConfig;