| 1 |
import { checkIn } from '@auto-launch/functions/insights'; |
| 2 |
import { sparkles } from '@auto-launch/icons'; |
| 3 |
import { launchStrings } from '@auto-launch/strings'; |
| 4 |
import { useEffect } from '@wordpress/element'; |
| 5 |
import { cloudUpload } from '@wordpress/icons'; |
| 6 |
|
| 7 |
const migrateSearchUrl = (search) => |
| 8 |
`${window.extSharedData.adminUrl}plugin-install.php?tab=search&s=${encodeURIComponent(search)}`; |
| 9 |
|
| 10 |
export const useMigrateChoice = ({ onBuildNew }) => { |
| 11 |
const strings = launchStrings(); |
| 12 |
|
| 13 |
useEffect(() => { |
| 14 |
checkIn({ stage: 'migrate_screen' }); |
| 15 |
}, []); |
| 16 |
|
| 17 |
return { |
| 18 |
title: strings.migrateTitle, |
| 19 |
options: [ |
| 20 |
{ |
| 21 |
key: 'migrate', |
| 22 |
icon: cloudUpload, |
| 23 |
heading: strings.migrateHeading, |
| 24 |
buttonLabel: strings.migrateAction, |
| 25 |
description: strings.migrateBody, |
| 26 |
onClick: () => { |
| 27 |
checkIn({ stage: 'migrate_screen_migrate' }); |
| 28 |
window.location.assign(migrateSearchUrl(strings.migrationSearch)); |
| 29 |
}, |
| 30 |
}, |
| 31 |
{ |
| 32 |
key: 'build', |
| 33 |
icon: sparkles, |
| 34 |
heading: strings.buildHeading, |
| 35 |
highlight: true, |
| 36 |
badgeLabel: strings.buildBadge, |
| 37 |
buttonLabel: strings.buildAction, |
| 38 |
description: strings.buildBody, |
| 39 |
onClick: () => { |
| 40 |
checkIn({ stage: 'migrate_screen_build' }); |
| 41 |
onBuildNew(); |
| 42 |
}, |
| 43 |
}, |
| 44 |
], |
| 45 |
}; |
| 46 |
}; |
| 47 |
|