Skip to content

Commit

Permalink
comments are addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
ramyakrishnai committed Apr 26, 2024
1 parent f7e7d22 commit 59a266d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 33 deletions.
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'c6147259a9b626f98199');
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'e72128cbb42973f2488a');
18 changes: 4 additions & 14 deletions src/components/OnboardingList.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Card, Link, Spinner, Title } from "@newfold/ui-component-library";
import useSWRMutation from "swr/mutation";
import { OnboardingListDefinition } from "../configs/OnboardingList.config";
import { useCardManager } from "./useCardManager";
import { BH_UR_REGEX, HG_UR_REGEX } from "../constants";
import { check_url_match } from "../configs/Utility";

function OnboardingCheckListItem({ children, actions, state, ...props }) {
let manageAction = useSWRMutation(props.name, async () => {
Expand Down Expand Up @@ -62,17 +62,7 @@ function OnboardingCheckListItem({ children, actions, state, ...props }) {
);
}

const check_url_match = () => {
const brandName = (NewfoldRuntime?.sdk?.ecommerce?.brand_settings?.name).toLowerCase();
switch (brandName){
case "bluehost":
return !(BH_UR_REGEX.test(window.location.origin));
case "hostgator":
return !(HG_UR_REGEX.test(window.location.origin));
default:
return true;
}
}
const brandName = (NewfoldRuntime?.sdk?.ecommerce?.brand_settings?.name).toLowerCase();

export function OnboardingList(props) {
let [view, setView] = useState("incomplete");
Expand All @@ -90,8 +80,8 @@ export function OnboardingList(props) {
props.isMigrationCompleted ? items.slice(0, 3) : (view === "incomplete" ? incompleteItems.slice(0, 5) : completedItems);

const migration_text = {
title: check_url_match() && props.webServersUpdated ? __("Good job!", "wp-module-ecommerce") : __("One last thing to do...", "wp-module-ecommerce"),
description: check_url_match() && props.webServersUpdated ? __("Your site is now ready for public visitors!", "wp-module-ecommerce") : __("Finish this last step so your migrated site is ready for visitors.", "wp-module-ecommerce")
title: check_url_match( brandName ) && props.webServersUpdated ? __("Good job!", "wp-module-ecommerce") : __("One last thing to do...", "wp-module-ecommerce"),
description: check_url_match( brandName ) && props.webServersUpdated ? __("Your site is now ready for public visitors!", "wp-module-ecommerce") : __("Finish this last step so your migrated site is ready for visitors.", "wp-module-ecommerce")
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/OnboardingScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function OnboardingScreen({

useEffect(() => {
WordPressSdk.settings.get().then((res) => {
setIsMigrationCompleted( res.showMigrationSteps );
setIsMigrationCompleted( res.showMigrationSteps || false );
setWebServersUpdated( res.update_site_server_clicked );
if (res?.page_on_front && res?.show_on_front === "page") {
setEditUrl(
Expand Down
31 changes: 14 additions & 17 deletions src/configs/OnboardingList.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
get_tax_configured,
get_settings_list
} from "./selectors";
import { BH_UR_REGEX, HG_UR_REGEX } from "../constants";
import { check_url_match } from "./Utility";

const parsePluginStatus = (plugins) => ({
isWCActive: PluginsSdk.queries.isPlugin(plugins, ["woocommerce"], "active"),
Expand Down Expand Up @@ -68,16 +68,7 @@ const signUpYoastSEOAcademy = () => {
const brandName =
(NewfoldRuntime?.sdk?.ecommerce?.brand_settings?.name).toLowerCase();

const check_url_match = () => {
switch (brandName) {
case "bluehost":
return !(BH_UR_REGEX.test(window.location.origin));
case "hostgator":
return !(HG_UR_REGEX.test(window.location.origin));
default:
return true;
}
}


export function OnboardingListDefinition(props) {
const installJetpack = createPluginInstallAction("jetpack", 20, props);
Expand All @@ -98,15 +89,18 @@ export function OnboardingListDefinition(props) {
"wp-module-ecommerce"
),
state: {
isCompleted: (queries) => queries?.settings?.update_site_server_clicked || check_url_match(),
isCompleted: (queries) => queries?.settings?.update_site_server_clicked || check_url_match(brandName),
isMigrated: (queries) => queries?.settings?.showMigrationSteps || props.isMigrationCompleted
},
shouldRender: (state) => (state.isMigrated),
actions: {
manage: () => updateSiteServers(props.setWebServersUpdated),
},

"data-nfdhelpcenterquery": "How do I update my nameserver to BH?",
"data-nfdhelpcenterquery": __(
"How do I update my nameserver to BH?",
"wp-module-ecommerce"
),
queries: [
{ key: "settings", selector: get_settings_list }
],
Expand All @@ -118,11 +112,14 @@ export function OnboardingListDefinition(props) {
"wp-module-ecommerce"
),
state: {
isCompleted: () => check_url_match(),
isCompleted: () => check_url_match( brandName ),
isMigrated: (queries) => queries?.settings?.showMigrationSteps || props.isMigrationCompleted,
},

"data-nfdhelpcenterquery": "How do I connect my site to the Domain ?",
"data-nfdhelpcenterquery": __(
"How do I connect my site to the Domain ?",
"wp-module-ecommerce"
),
shouldRender: (state) => state.isMigrated,
actions: {
manage: updateSiteDomain,
Expand All @@ -138,7 +135,7 @@ export function OnboardingListDefinition(props) {
"wp-module-ecommerce"
),
state: {
isCompleted: (queries) => (queries?.settings?.update_site_server_clicked && check_url_match()) || check_url_match(),
isCompleted: (queries) => (queries?.settings?.update_site_server_clicked && check_url_match(brandName)) || check_url_match(brandName),
isMigrated: (queries) => queries?.settings?.showMigrationSteps,
className: () => "nfd-bg-canvas",
hideCheck: () => true,
Expand All @@ -160,7 +157,7 @@ export function OnboardingListDefinition(props) {
),
state: {
isCompleted: (queries) => false,
isMigrated: (queries) => queries?.settings?.showMigrationSteps && (queries?.settings?.update_site_server_clicked || check_url_match()),
isMigrated: (queries) => queries?.settings?.showMigrationSteps && (queries?.settings?.update_site_server_clicked || check_url_match(brandName)),
},
shouldRender: (state) => state.isMigrated && !state.isCompleted,
actions: {
Expand Down
12 changes: 12 additions & 0 deletions src/configs/Utility.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { BH_UR_REGEX, HG_UR_REGEX } from "../constants";

export const check_url_match = (brandName) => {
switch (brandName) {
case "bluehost":
return !(BH_UR_REGEX.test(window.location.origin));
case "hostgator":
return !(HG_UR_REGEX.test(window.location.origin));
default:
return true;
}
}

0 comments on commit 59a266d

Please sign in to comment.