Skip to content

Commit

Permalink
Add check for supported enginers to import CaptureStep
Browse files Browse the repository at this point in the history
  • Loading branch information
daledupreez committed May 13, 2024
1 parent f133c7c commit 8bad401
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion client/blocks/import/capture/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -99,7 +100,11 @@ export const CaptureStep: React.FunctionComponent< StepProps > = ( {
break;

default:
stepSectionName = 'preview';
if ( ! isSupportedImporterEngine( urlData.platform ) ) {
stepSectionName = 'not';
} else {
stepSectionName = 'preview';
}
break;
}

Expand Down
6 changes: 6 additions & 0 deletions client/lib/importer/importer-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 8bad401

Please sign in to comment.