react-code-dataset / wp-calypso /client /landing /stepper /declarative-flow /migration /helpers /index.ts
react-code-dataset / wp-calypso /client /landing /stepper /declarative-flow /migration /helpers /index.ts
Download wp-calypso/client/landing/stepper/declarative-flow/migration/helpers/index.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/declarative-flow/migration/helpers/index.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/landing/stepper/declarative-flow/migration/helpers/index.ts
-
curl -L -o index.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/declarative-flow/migration/helpers/index.ts
1.32 kB
| import { SITE_SETUP_FLOW } from '@automattic/onboarding'; | |
| import { ImporterPlatform } from 'calypso/lib/importer/types'; | |
| import { addQueryArgs } from 'calypso/lib/url'; | |
| import { getFinalImporterUrl } from '../../internals/steps-repository/import/helper'; | |
| const isWpAdminImporter = ( importerPath: string ) => | |
| importerPath.startsWith( 'http' ) || importerPath.startsWith( '/import' ); | |
| interface GoToImporterParams { | |
| platform: ImporterPlatform; | |
| siteId: string; | |
| siteSlug: string; | |
| backToFlow?: string; | |
| replaceHistory?: boolean; | |
| from?: string | null; | |
| ref?: string; | |
| } | |
| /** | |
| * @deprecated generate the full flow URL in your flow instead | |
| * @see backToFlow property | |
| */ | |
| const goTo = ( path: string, replaceHistory: boolean ) => { | |
| if ( replaceHistory ) { | |
| return window.location.replace( path ); | |
| } | |
| return window.location.assign( path ); | |
| }; | |
| export const goToImporter = ( { | |
| platform, | |
| siteId, | |
| siteSlug, | |
| replaceHistory = false, | |
| backToFlow, | |
| from, | |
| ref, | |
| }: GoToImporterParams ) => { | |
| const path = getFinalImporterUrl( siteSlug, from || '', platform, backToFlow ); | |
| if ( isWpAdminImporter( path ) ) { | |
| return goTo( path, replaceHistory ); | |
| } | |
| const stepURL = addQueryArgs( | |
| { | |
| siteId, | |
| siteSlug, | |
| ref: ref, | |
| }, | |
| `/setup/${ SITE_SETUP_FLOW }/${ path }` | |
| ); | |
| return goTo( stepURL, replaceHistory ); | |
| }; | |