Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRESS0-1877 | Added Migration flow to Tools page #63

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
changes
ramyakrishnai committed Aug 20, 2024
commit 593c99b31ec4b5381c2724c5b050f538e6d8bb85
5 changes: 5 additions & 0 deletions includes/Services/InstaMigrateService.php
Original file line number Diff line number Diff line change
@@ -25,6 +25,11 @@ class InstaMigrateService {
*/
private $insta_api_key = '';

/**
* Retry count
*
* @var $count
*/
private $count = 0;
/**
* Set required api keys for insta to initiate the migration
52 changes: 16 additions & 36 deletions includes/import-tools-changes.js
Original file line number Diff line number Diff line change
@@ -28,42 +28,7 @@ node.setAttribute("id", "migration-progress-modal")

document.getElementById("wpbody-content").appendChild(node)

// load a pop up when user clicks on run importer for wordpress migration tool
document.querySelector('a[href*="import=site_migration_wordpress_importer"]')?.addEventListener('click', function(e) {
e.preventDefault();
document.getElementById("migration-progress-modal").style.display = "flex";

fetch(
nfdplugin.restApiUrl + "/newfold-migration/v1/migrate/connect&_locale=user",
{
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': nfdplugin.restApiNonce,
},
}
)
.then((response) => response.json())
.then(res => {
document.getElementById("migration-progress-modal").style.display = "none";
if(res?.success){
window.open(res?.data?.redirect_url, "_self")
}
// else{
// document.getElementsByClassName("wrap")[0];
// // alert("please try again in sometime. Thanks!")
// }
})
.catch(err => console.error(err))

});


let params = new URLSearchParams(document.location.search);
let canMigrateSite = params.get("migrate");

if(canMigrateSite === "true"){
console.log("helloo")
function startMigration(){
document.getElementById("migration-progress-modal").style.display = "flex";

fetch(
@@ -87,4 +52,19 @@ if(canMigrateSite === "true"){
// // alert("please try again in sometime. Thanks!")
// }
})
}
// load a pop up when user clicks on run importer for wordpress migration tool
document.querySelector('a[href*="import=site_migration_wordpress_importer"]')?.addEventListener('click', function(e) {
e.preventDefault();
startMigration();

});


// trigger migration when user lands on tools page with migrate param
const params = new URLSearchParams(document.location.search);
const canMigrateSite = params.get("migrate");

if(canMigrateSite === "true"){
startMigration()
}