From 84db458390bf70ea640885bda90fa5d1c6cb8a8d Mon Sep 17 00:00:00 2001 From: Allen Benny <48691514+officiallygod@users.noreply.github.com> Date: Thu, 2 Mar 2023 12:18:47 +0530 Subject: [PATCH 1/6] Basic Dynamic Exit Link --- includes/Data/Brands.php | 2 ++ src/OnboardingSPA/components/Button/NavCardButton/index.js | 4 ++-- src/OnboardingSPA/components/ExitToWordPress/index.js | 4 ++-- src/OnboardingSPA/components/Header/step-navigation.js | 4 ++-- src/OnboardingSPA/components/SkipButton/index.js | 4 ++-- src/constants.js | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/includes/Data/Brands.php b/includes/Data/Brands.php index f7add3595..78cf67bcc 100644 --- a/includes/Data/Brands.php +++ b/includes/Data/Brands.php @@ -29,6 +29,7 @@ public static function get_brands() { 'accountUrl' => 'https://my.bluehost.com', 'domainsUrl' => 'https://my.bluehost.com/hosting/app?lil=1#/domains', 'emailUrl' => 'https://my.bluehost.com/hosting/app?lil=1#/email-office', + 'dashboardUrl' => '?page=bluehost', 'phoneNumbers' => array( 'sales' => '844-303-1730', 'support' => '888-401-4678', @@ -82,6 +83,7 @@ public static function get_brands() { 'accountUrl' => 'https://my.bluehost.in', 'domainsUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/domains', 'emailUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/email-office', + 'dashboardUrl' => '?page=bluehost', 'hireExpertsInfo' => array( 'defaultLink' => 'https://www.bluehost.in/solutions/full-service', 'utmParameters' => array( diff --git a/src/OnboardingSPA/components/Button/NavCardButton/index.js b/src/OnboardingSPA/components/Button/NavCardButton/index.js index 3872897af..1af6ee87e 100644 --- a/src/OnboardingSPA/components/Button/NavCardButton/index.js +++ b/src/OnboardingSPA/components/Button/NavCardButton/index.js @@ -4,7 +4,7 @@ import { store as nfdOnboardingStore } from '../../../store'; import Button from '../../Button'; import { setFlow } from '../../../utils/api/flow'; -import { wpAdminPage, bluehostDashboardPage } from '../../../../constants'; +import { wpAdminPage, dashboardPage } from '../../../../constants'; /** * Navigation Button Component on Card @@ -37,7 +37,7 @@ const NavCardButton = ( { text, disabled } ) => { //Redirect to Admin Page for normal customers // and Bluehost Dashboard for ecommerce customers const exitLink = exitToWordpressForEcommerce() - ? bluehostDashboardPage + ? dashboardPage : wpAdminPage; window.location.replace( exitLink ); } diff --git a/src/OnboardingSPA/components/ExitToWordPress/index.js b/src/OnboardingSPA/components/ExitToWordPress/index.js index 09285f463..eaac7078c 100644 --- a/src/OnboardingSPA/components/ExitToWordPress/index.js +++ b/src/OnboardingSPA/components/ExitToWordPress/index.js @@ -9,7 +9,7 @@ import classNames from 'classnames'; import { setFlow } from '../../utils/api/flow'; import { store as nfdOnboardingStore } from '../../store'; import { getSettings, setSettings } from '../../utils/api/settings'; -import { wpAdminPage, bluehostDashboardPage } from '../../../constants'; +import { wpAdminPage, dashboardPage } from '../../../constants'; /** * Self-contained button and confirmation modal for exiting Onboarding page. @@ -90,7 +90,7 @@ const ExitToWordPress = ( { //Redirect to Admin Page for normal customers // and Bluehost Dashboard for ecommerce customers const exitLink = exitToWordpressForEcommerce() - ? bluehostDashboardPage + ? dashboardPage : wpAdminPage; window.location.replace( exitLink ); } diff --git a/src/OnboardingSPA/components/Header/step-navigation.js b/src/OnboardingSPA/components/Header/step-navigation.js index 6ac1fc434..17fba34e0 100644 --- a/src/OnboardingSPA/components/Header/step-navigation.js +++ b/src/OnboardingSPA/components/Header/step-navigation.js @@ -6,7 +6,7 @@ import { Icon, chevronLeft, chevronRight } from '@wordpress/icons'; import { __ } from '@wordpress/i18n'; import { setFlow } from '../../utils/api/flow'; import { store as nfdOnboardingStore } from '../../store'; -import { wpAdminPage, bluehostDashboardPage } from '../../../constants'; +import { wpAdminPage, dashboardPage } from '../../../constants'; /** * Back step Navigation button. @@ -61,7 +61,7 @@ async function saveDataAndExit( currentData ) { //Redirect to Admin Page for normal customers // and Bluehost Dashboard for ecommerce customers const exitLink = exitToWordpressForEcommerce() - ? bluehostDashboardPage + ? dashboardPage : wpAdminPage; window.location.replace( exitLink ); } diff --git a/src/OnboardingSPA/components/SkipButton/index.js b/src/OnboardingSPA/components/SkipButton/index.js index 995b71d7d..ee5989187 100644 --- a/src/OnboardingSPA/components/SkipButton/index.js +++ b/src/OnboardingSPA/components/SkipButton/index.js @@ -7,7 +7,7 @@ import { useLocation, useNavigate } from 'react-router-dom'; import { setFlow } from '../../utils/api/flow'; import { store as nfdOnboardingStore } from '../../store'; import { getSettings, setSettings } from '../../utils/api/settings'; -import { wpAdminPage, bluehostDashboardPage } from '../../../constants'; +import { wpAdminPage, dashboardPage } from '../../../constants'; /** * Interface Text Inputs with standard design. @@ -56,7 +56,7 @@ const SkipButton = () => { // Redirect to Admin Page for normal customers // and Bluehost Dashboard for ecommerce customers const exitLink = exitToWordpressForEcommerce() - ? bluehostDashboardPage + ? dashboardPage : wpAdminPage; window.location.replace( exitLink ); } diff --git a/src/constants.js b/src/constants.js index 36d2121d0..b8008b7a9 100644 --- a/src/constants.js +++ b/src/constants.js @@ -10,7 +10,7 @@ export const onboardingRestRoute = 'newfold-onboarding/v1'; export const wpRestBase = `${ wpRestURL }/${ wpRestRoute }`; export const onboardingRestBase = `${ wpRestURL }/${ onboardingRestRoute }`; export const wpAdminPage = `${ wpAdminUrl }index.php`; -export const bluehostDashboardPage = `${ wpAdminPage }?page=bluehost`; +export const dashboardPage = `${ wpAdminPage }${ window?.nfdOnboarding?.currentBrand?.dashboardUrl }`; export const NFD_ONBOARDING_EVENT_PREFIX = 'nfd-module-onboarding-event'; export const VIEW_NAV_PRIMARY = 'nav-primary'; export const VIEW_NAV_DESIGN = 'nav-design'; From edb0d6c8d104f0de5eb85ee00dc272ade4170c79 Mon Sep 17 00:00:00 2001 From: Allen Benny <48691514+officiallygod@users.noreply.github.com> Date: Thu, 2 Mar 2023 15:57:36 +0530 Subject: [PATCH 2/6] Linting JS --- .../components/ExitToWordPress/index.js | 18 +++++++--------- .../components/Header/step-navigation.js | 21 ++++++++++--------- .../components/SkipButton/index.js | 16 +++++++------- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/OnboardingSPA/components/ExitToWordPress/index.js b/src/OnboardingSPA/components/ExitToWordPress/index.js index eaac7078c..dd6827da8 100644 --- a/src/OnboardingSPA/components/ExitToWordPress/index.js +++ b/src/OnboardingSPA/components/ExitToWordPress/index.js @@ -15,7 +15,8 @@ import { wpAdminPage, dashboardPage } from '../../../constants'; * Self-contained button and confirmation modal for exiting Onboarding page. * * @param {*} param0 - * @return + * + * @return {WPComponent} ExitToWordPress Component */ const ExitToWordPress = ( { buttonText = __( 'Exit to WordPress', 'wp-module-onboarding' ), @@ -62,7 +63,7 @@ const ExitToWordPress = ( { ); } - async function syncSocialSettingsFinish( currentData ) { + async function syncSocialSettingsFinish() { const initialData = await getSettings(); const result = await setSettings( currentData?.data?.socialData ); if ( result?.error !== null ) { @@ -71,19 +72,18 @@ const ExitToWordPress = ( { return result?.body; } - async function saveData( path, currentData ) { + async function saveData( path ) { if ( currentData ) { currentData.hasExited = new Date().getTime(); // If Social Data is changed then sync it if ( path?.includes( 'basic-info' ) ) { - const socialData = await syncSocialSettingsFinish( - currentData - ); + const socialData = await syncSocialSettingsFinish(); // If Social Data is changed then Sync that also to the store - if ( socialData && currentData?.data ) + if ( socialData && currentData?.data ) { currentData.data.socialData = socialData; + } } setFlow( currentData ); } @@ -125,9 +125,7 @@ const ExitToWordPress = ( { diff --git a/src/OnboardingSPA/components/Header/step-navigation.js b/src/OnboardingSPA/components/Header/step-navigation.js index 17fba34e0..d967552d9 100644 --- a/src/OnboardingSPA/components/Header/step-navigation.js +++ b/src/OnboardingSPA/components/Header/step-navigation.js @@ -12,7 +12,8 @@ import { wpAdminPage, dashboardPage } from '../../../constants'; * Back step Navigation button. * * @param {*} param0 - * @return + * + * @return {WPComponent} Back Component */ const Back = ( { path } ) => { const navigate = useNavigate(); @@ -34,7 +35,8 @@ const Back = ( { path } ) => { * Next step naigation button * * @param {*} param0 - * @return + * + * @return {WPComponent} Next Component */ const Next = ( { path } ) => { /* [TODO]: some sense of isStepComplete to enable/disable */ @@ -69,14 +71,13 @@ async function saveDataAndExit( currentData ) { /** * Finish step navigation button. * - * @param root0 - * @param root0.currentData - * @param root0.saveDataAndExit - * @return + * @param {*} param0 + * + * @return {WPComponent} Finish Component */ -const Finish = ( { currentData, saveDataAndExit } ) => ( +const Finish = ( { currentData, saveDataAndExitFunc } ) => ( @@ -89,7 +89,7 @@ const SkipButton = () => { * check if this is the last step */ const exitToWordpressForEcommerce = () => { - if ( window.nfdOnboarding.currentFlow == 'ecommerce' ) { + if ( window.nfdOnboarding.currentFlow === 'ecommerce' ) { return true; } return false; From 4aa1db71dfd32355107c271c1ca8c9129d388dfd Mon Sep 17 00:00:00 2001 From: Allen Benny <48691514+officiallygod@users.noreply.github.com> Date: Thu, 2 Mar 2023 16:05:39 +0530 Subject: [PATCH 3/6] Added missing semicolons --- src/constants.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/constants.js b/src/constants.js index b8008b7a9..60ab9792f 100644 --- a/src/constants.js +++ b/src/constants.js @@ -39,14 +39,14 @@ export const THEME_STATUS_NOT_ACTIVE = 'inactive'; export const THEME_STATUS_INSTALLING = 'installing'; export const THEME_STATUS_ACTIVE = 'activated'; export const THEME_STATUS_FAILURE = 'failed'; -export const THEME_INSTALL_WAIT_TIMEOUT = 30000 +export const THEME_INSTALL_WAIT_TIMEOUT = 30000; -export const ECOMMERCE_STEPS_PLUGIN = 'woocommerce' +export const ECOMMERCE_STEPS_PLUGIN = 'woocommerce'; export const PLUGIN_STATUS_INIT = 'init'; export const PLUGIN_STATUS_NOT_ACTIVE = 'inactive'; export const PLUGIN_STATUS_INSTALLING = 'installing'; export const PLUGIN_STATUS_ACTIVE = 'activated'; -export const PLUGIN_INSTALL_WAIT_TIMEOUT = 30000 +export const PLUGIN_INSTALL_WAIT_TIMEOUT = 30000; /** * All views for the component. From f01af135d41bd8eeab718bd909e7a2c4a5c91a35 Mon Sep 17 00:00:00 2001 From: Allen Benny <48691514+officiallygod@users.noreply.github.com> Date: Thu, 2 Mar 2023 17:35:26 +0530 Subject: [PATCH 4/6] Undefined Case --- src/constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.js b/src/constants.js index 60ab9792f..ec263a14d 100644 --- a/src/constants.js +++ b/src/constants.js @@ -10,7 +10,7 @@ export const onboardingRestRoute = 'newfold-onboarding/v1'; export const wpRestBase = `${ wpRestURL }/${ wpRestRoute }`; export const onboardingRestBase = `${ wpRestURL }/${ onboardingRestRoute }`; export const wpAdminPage = `${ wpAdminUrl }index.php`; -export const dashboardPage = `${ wpAdminPage }${ window?.nfdOnboarding?.currentBrand?.dashboardUrl }`; +export const dashboardPage = `${ wpAdminPage }${ window?.nfdOnboarding?.currentBrand?.dashboardUrl ?? '' }`; export const NFD_ONBOARDING_EVENT_PREFIX = 'nfd-module-onboarding-event'; export const VIEW_NAV_PRIMARY = 'nav-primary'; export const VIEW_NAV_DESIGN = 'nav-design'; From 5a4793520fa8148701ae300558d58d88e542b0e8 Mon Sep 17 00:00:00 2001 From: Allen Benny <48691514+officiallygod@users.noreply.github.com> Date: Thu, 2 Mar 2023 18:33:15 +0530 Subject: [PATCH 5/6] Renamed Components --- includes/Data/Brands.php | 4 ++-- src/OnboardingSPA/components/Button/NavCardButton/index.js | 4 ++-- src/OnboardingSPA/components/ExitToWordPress/index.js | 4 ++-- src/OnboardingSPA/components/Header/step-navigation.js | 4 ++-- src/OnboardingSPA/components/SkipButton/index.js | 4 ++-- src/constants.js | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/includes/Data/Brands.php b/includes/Data/Brands.php index 78cf67bcc..946c1357d 100644 --- a/includes/Data/Brands.php +++ b/includes/Data/Brands.php @@ -29,7 +29,7 @@ public static function get_brands() { 'accountUrl' => 'https://my.bluehost.com', 'domainsUrl' => 'https://my.bluehost.com/hosting/app?lil=1#/domains', 'emailUrl' => 'https://my.bluehost.com/hosting/app?lil=1#/email-office', - 'dashboardUrl' => '?page=bluehost', + 'pluginDashboardPage' => \admin_url('admin.php?page=bluehost'), 'phoneNumbers' => array( 'sales' => '844-303-1730', 'support' => '888-401-4678', @@ -83,7 +83,7 @@ public static function get_brands() { 'accountUrl' => 'https://my.bluehost.in', 'domainsUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/domains', 'emailUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/email-office', - 'dashboardUrl' => '?page=bluehost', + 'pluginDashboardPage' => \admin_url('admin.php?page=bluehost'), 'hireExpertsInfo' => array( 'defaultLink' => 'https://www.bluehost.in/solutions/full-service', 'utmParameters' => array( diff --git a/src/OnboardingSPA/components/Button/NavCardButton/index.js b/src/OnboardingSPA/components/Button/NavCardButton/index.js index 1af6ee87e..b99d4c537 100644 --- a/src/OnboardingSPA/components/Button/NavCardButton/index.js +++ b/src/OnboardingSPA/components/Button/NavCardButton/index.js @@ -4,7 +4,7 @@ import { store as nfdOnboardingStore } from '../../../store'; import Button from '../../Button'; import { setFlow } from '../../../utils/api/flow'; -import { wpAdminPage, dashboardPage } from '../../../../constants'; +import { wpAdminPage, pluginDashboardPage } from '../../../../constants'; /** * Navigation Button Component on Card @@ -37,7 +37,7 @@ const NavCardButton = ( { text, disabled } ) => { //Redirect to Admin Page for normal customers // and Bluehost Dashboard for ecommerce customers const exitLink = exitToWordpressForEcommerce() - ? dashboardPage + ? pluginDashboardPage : wpAdminPage; window.location.replace( exitLink ); } diff --git a/src/OnboardingSPA/components/ExitToWordPress/index.js b/src/OnboardingSPA/components/ExitToWordPress/index.js index dd6827da8..d8c52fa74 100644 --- a/src/OnboardingSPA/components/ExitToWordPress/index.js +++ b/src/OnboardingSPA/components/ExitToWordPress/index.js @@ -9,7 +9,7 @@ import classNames from 'classnames'; import { setFlow } from '../../utils/api/flow'; import { store as nfdOnboardingStore } from '../../store'; import { getSettings, setSettings } from '../../utils/api/settings'; -import { wpAdminPage, dashboardPage } from '../../../constants'; +import { wpAdminPage, pluginDashboardPage } from '../../../constants'; /** * Self-contained button and confirmation modal for exiting Onboarding page. @@ -90,7 +90,7 @@ const ExitToWordPress = ( { //Redirect to Admin Page for normal customers // and Bluehost Dashboard for ecommerce customers const exitLink = exitToWordpressForEcommerce() - ? dashboardPage + ? pluginDashboardPage : wpAdminPage; window.location.replace( exitLink ); } diff --git a/src/OnboardingSPA/components/Header/step-navigation.js b/src/OnboardingSPA/components/Header/step-navigation.js index d967552d9..dc71ec939 100644 --- a/src/OnboardingSPA/components/Header/step-navigation.js +++ b/src/OnboardingSPA/components/Header/step-navigation.js @@ -6,7 +6,7 @@ import { Icon, chevronLeft, chevronRight } from '@wordpress/icons'; import { __ } from '@wordpress/i18n'; import { setFlow } from '../../utils/api/flow'; import { store as nfdOnboardingStore } from '../../store'; -import { wpAdminPage, dashboardPage } from '../../../constants'; +import { wpAdminPage, pluginDashboardPage } from '../../../constants'; /** * Back step Navigation button. @@ -63,7 +63,7 @@ async function saveDataAndExit( currentData ) { //Redirect to Admin Page for normal customers // and Bluehost Dashboard for ecommerce customers const exitLink = exitToWordpressForEcommerce() - ? dashboardPage + ? pluginDashboardPage : wpAdminPage; window.location.replace( exitLink ); } diff --git a/src/OnboardingSPA/components/SkipButton/index.js b/src/OnboardingSPA/components/SkipButton/index.js index 3bd457d9f..a2caba16e 100644 --- a/src/OnboardingSPA/components/SkipButton/index.js +++ b/src/OnboardingSPA/components/SkipButton/index.js @@ -7,7 +7,7 @@ import { useLocation, useNavigate } from 'react-router-dom'; import { setFlow } from '../../utils/api/flow'; import { store as nfdOnboardingStore } from '../../store'; import { getSettings, setSettings } from '../../utils/api/settings'; -import { wpAdminPage, dashboardPage } from '../../../constants'; +import { wpAdminPage, pluginDashboardPage } from '../../../constants'; /** * Interface Text Inputs with standard design. @@ -56,7 +56,7 @@ const SkipButton = () => { // Redirect to Admin Page for normal customers // and Bluehost Dashboard for ecommerce customers const exitLink = exitToWordpressForEcommerce() - ? dashboardPage + ? pluginDashboardPage : wpAdminPage; window.location.replace( exitLink ); } diff --git a/src/constants.js b/src/constants.js index ec263a14d..f37ec96b2 100644 --- a/src/constants.js +++ b/src/constants.js @@ -10,7 +10,7 @@ export const onboardingRestRoute = 'newfold-onboarding/v1'; export const wpRestBase = `${ wpRestURL }/${ wpRestRoute }`; export const onboardingRestBase = `${ wpRestURL }/${ onboardingRestRoute }`; export const wpAdminPage = `${ wpAdminUrl }index.php`; -export const dashboardPage = `${ wpAdminPage }${ window?.nfdOnboarding?.currentBrand?.dashboardUrl ?? '' }`; +export const pluginDashboardPage = `${ window.nfdOnboarding.currentBrand?.pluginDashboardPage ?? wpAdminPage }`; export const NFD_ONBOARDING_EVENT_PREFIX = 'nfd-module-onboarding-event'; export const VIEW_NAV_PRIMARY = 'nav-primary'; export const VIEW_NAV_DESIGN = 'nav-design'; From 0a9f452a83a948e39a213ca87dd959e0a1dd44c4 Mon Sep 17 00:00:00 2001 From: Allen Benny <48691514+officiallygod@users.noreply.github.com> Date: Thu, 2 Mar 2023 18:34:44 +0530 Subject: [PATCH 6/6] Update Brands.php --- includes/Data/Brands.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/Data/Brands.php b/includes/Data/Brands.php index 946c1357d..0477310e3 100644 --- a/includes/Data/Brands.php +++ b/includes/Data/Brands.php @@ -29,7 +29,7 @@ public static function get_brands() { 'accountUrl' => 'https://my.bluehost.com', 'domainsUrl' => 'https://my.bluehost.com/hosting/app?lil=1#/domains', 'emailUrl' => 'https://my.bluehost.com/hosting/app?lil=1#/email-office', - 'pluginDashboardPage' => \admin_url('admin.php?page=bluehost'), + 'pluginDashboardPage' => \admin_url( 'admin.php?page=bluehost' ), 'phoneNumbers' => array( 'sales' => '844-303-1730', 'support' => '888-401-4678', @@ -83,7 +83,7 @@ public static function get_brands() { 'accountUrl' => 'https://my.bluehost.in', 'domainsUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/domains', 'emailUrl' => 'https://my.bluehost.in/hosting/app?lil=1#/email-office', - 'pluginDashboardPage' => \admin_url('admin.php?page=bluehost'), + 'pluginDashboardPage' => \admin_url( 'admin.php?page=bluehost' ), 'hireExpertsInfo' => array( 'defaultLink' => 'https://www.bluehost.in/solutions/full-service', 'utmParameters' => array(