feature/IO-2916-Remove-Beta-Switch-AIO - Remove Beta Switch
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -18,7 +18,6 @@ import { checkUserSession } from "../redux/user/user.actions";
|
|||||||
import { selectBodyshop, selectCurrentEula, selectCurrentUser } from "../redux/user/user.selectors";
|
import { selectBodyshop, selectCurrentEula, selectCurrentUser } from "../redux/user/user.selectors";
|
||||||
import PrivateRoute from "../components/PrivateRoute";
|
import PrivateRoute from "../components/PrivateRoute";
|
||||||
import "./App.styles.scss";
|
import "./App.styles.scss";
|
||||||
import handleBeta from "../utils/handleBeta";
|
|
||||||
import Eula from "../components/eula/eula.component";
|
import Eula from "../components/eula/eula.component";
|
||||||
import InstanceRenderMgr from "../utils/instanceRenderMgr";
|
import InstanceRenderMgr from "../utils/instanceRenderMgr";
|
||||||
import ProductFruitsWrapper from "./ProductFruitsWrapper.jsx";
|
import ProductFruitsWrapper from "./ProductFruitsWrapper.jsx";
|
||||||
@@ -108,8 +107,6 @@ export function App({ bodyshop, checkUserSession, currentUser, online, setOnline
|
|||||||
return <LoadingSpinner message={t("general.labels.loggingin")} />;
|
return <LoadingSpinner message={t("general.labels.loggingin")} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleBeta();
|
|
||||||
|
|
||||||
if (!online) {
|
if (!online) {
|
||||||
return (
|
return (
|
||||||
<Result
|
<Result
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import Icon, {
|
|||||||
FileFilled,
|
FileFilled,
|
||||||
HomeFilled,
|
HomeFilled,
|
||||||
ImportOutlined,
|
ImportOutlined,
|
||||||
InfoCircleOutlined,
|
|
||||||
LineChartOutlined,
|
LineChartOutlined,
|
||||||
PaperClipOutlined,
|
PaperClipOutlined,
|
||||||
PhoneOutlined,
|
PhoneOutlined,
|
||||||
@@ -27,8 +26,8 @@ import Icon, {
|
|||||||
UserOutlined
|
UserOutlined
|
||||||
} from "@ant-design/icons";
|
} from "@ant-design/icons";
|
||||||
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
||||||
import { Layout, Menu, Switch, Tooltip } from "antd";
|
import { Layout, Menu } from "antd";
|
||||||
import React, { useEffect, useState } from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { BsKanban } from "react-icons/bs";
|
import { BsKanban } from "react-icons/bs";
|
||||||
import { FaCalendarAlt, FaCarCrash, FaCreditCard, FaFileInvoiceDollar, FaTasks } from "react-icons/fa";
|
import { FaCalendarAlt, FaCarCrash, FaCreditCard, FaFileInvoiceDollar, FaTasks } from "react-icons/fa";
|
||||||
@@ -43,7 +42,6 @@ import { selectRecentItems, selectSelectedHeader } from "../../redux/application
|
|||||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
import { signOutStart } from "../../redux/user/user.actions";
|
import { signOutStart } from "../../redux/user/user.actions";
|
||||||
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
|
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
|
||||||
import { checkBeta, handleBeta, setBeta } from "../../utils/handleBeta";
|
|
||||||
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
||||||
import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
|
import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
|
||||||
|
|
||||||
@@ -115,20 +113,9 @@ function Header({
|
|||||||
names: ["ImEXPay", "DmsAp", "Simple_Inventory"],
|
names: ["ImEXPay", "DmsAp", "Simple_Inventory"],
|
||||||
splitKey: bodyshop && bodyshop.imexshopid
|
splitKey: bodyshop && bodyshop.imexshopid
|
||||||
});
|
});
|
||||||
const [betaSwitch, setBetaSwitch] = useState(false);
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const isBeta = checkBeta();
|
|
||||||
setBetaSwitch(isBeta);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const betaSwitchChange = (checked) => {
|
|
||||||
setBeta(checked);
|
|
||||||
setBetaSwitch(checked);
|
|
||||||
handleBeta();
|
|
||||||
};
|
|
||||||
|
|
||||||
const accountingChildren = [];
|
const accountingChildren = [];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -695,31 +682,6 @@ function Header({
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
InstanceRenderManager({
|
|
||||||
executeFunction: true,
|
|
||||||
args: [],
|
|
||||||
imex: () => {
|
|
||||||
menuItems.push({
|
|
||||||
key: "beta-switch",
|
|
||||||
id: "header-beta-switch",
|
|
||||||
style: { marginLeft: "auto" },
|
|
||||||
label: (
|
|
||||||
<Tooltip
|
|
||||||
title={`A more modern ${InstanceRenderManager({
|
|
||||||
imex: t("titles.imexonline"),
|
|
||||||
rome: t("titles.romeonline"),
|
|
||||||
promanager: t("titles.promanager")
|
|
||||||
})} is ready for you to try! You can switch back at any time.`}
|
|
||||||
>
|
|
||||||
<InfoCircleOutlined />
|
|
||||||
<span style={{ marginRight: 8 }}>Try the new app</span>
|
|
||||||
<Switch checked={betaSwitch} onChange={betaSwitchChange} />
|
|
||||||
</Tooltip>
|
|
||||||
)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout.Header>
|
<Layout.Header>
|
||||||
<Menu
|
<Menu
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { getFirestore } from "firebase/firestore";
|
|||||||
import { getMessaging, getToken, onMessage } from "firebase/messaging";
|
import { getMessaging, getToken, onMessage } from "firebase/messaging";
|
||||||
import { store } from "../redux/store";
|
import { store } from "../redux/store";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { checkBeta } from "../utils/handleBeta";
|
|
||||||
|
|
||||||
const config = JSON.parse(import.meta.env.VITE_APP_FIREBASE_CONFIG);
|
const config = JSON.parse(import.meta.env.VITE_APP_FIREBASE_CONFIG);
|
||||||
initializeApp(config);
|
initializeApp(config);
|
||||||
@@ -88,7 +87,7 @@ export const logImEXEvent = (eventName, additionalParams, stateProp = null) => {
|
|||||||
operationName: eventName,
|
operationName: eventName,
|
||||||
variables: additionalParams,
|
variables: additionalParams,
|
||||||
dbevent: false,
|
dbevent: false,
|
||||||
env: checkBeta() ? "beta" : "master"
|
env: "master"
|
||||||
});
|
});
|
||||||
// console.log(
|
// console.log(
|
||||||
// "%c[Analytics]",
|
// "%c[Analytics]",
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
export const BETA_KEY = "betaSwitchImex";
|
|
||||||
|
|
||||||
export const checkBeta = () => {
|
|
||||||
const cookie = document.cookie.split("; ").find((row) => row.startsWith(BETA_KEY));
|
|
||||||
return cookie ? cookie.split("=")[1] === "true" : false;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const setBeta = (value) => {
|
|
||||||
const domain = window.location.hostname.split(".").slice(-2).join(".");
|
|
||||||
document.cookie = `${BETA_KEY}=${value}; path=/; domain=.${domain}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const handleBeta = () => {
|
|
||||||
if (window.location.hostname.startsWith("localhost")) {
|
|
||||||
console.log("Not on beta or test, so no need to handle beta.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const isBeta = checkBeta();
|
|
||||||
const currentHostName = window.location.hostname;
|
|
||||||
|
|
||||||
// Determine if the host name starts with "beta" or "www.beta"
|
|
||||||
const isBetaHost = currentHostName.startsWith("beta.");
|
|
||||||
const isBetaHostWithWWW = currentHostName.startsWith("www.beta.");
|
|
||||||
|
|
||||||
if (isBeta) {
|
|
||||||
// If beta is on and we are not on a beta domain, redirect to the beta version
|
|
||||||
if (!isBetaHost && !isBetaHostWithWWW) {
|
|
||||||
const newHostName = currentHostName.startsWith("www.")
|
|
||||||
? `www.beta.${currentHostName.replace(/^www\./, "")}`
|
|
||||||
: `beta.${currentHostName}`;
|
|
||||||
const href = `${window.location.protocol}//${newHostName}${window.location.pathname}${window.location.search}${window.location.hash}`;
|
|
||||||
window.location.replace(href);
|
|
||||||
}
|
|
||||||
// Otherwise, if beta is on and we're already on a beta domain, stay there
|
|
||||||
} else {
|
|
||||||
// If beta is off and we are on a beta domain, redirect to the non-beta version
|
|
||||||
if (isBetaHost || isBetaHostWithWWW) {
|
|
||||||
const newHostName = currentHostName.replace(/^www\.beta\./, "www.").replace(/^beta\./, "");
|
|
||||||
const href = `${window.location.protocol}//${newHostName}${window.location.pathname}${window.location.search}${window.location.hash}`;
|
|
||||||
window.location.replace(href);
|
|
||||||
}
|
|
||||||
// Otherwise, if beta is off and we're not on a beta domain, stay there
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default handleBeta;
|
|
||||||
Reference in New Issue
Block a user