diff --git a/frontend/src/components/navigation/RegionSelect.tsx b/frontend/src/components/navigation/RegionSelect.tsx new file mode 100644 index 000000000..008c7ea3a --- /dev/null +++ b/frontend/src/components/navigation/RegionSelect.tsx @@ -0,0 +1,141 @@ +import { useRouter } from "next/router"; +import { faCheck } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; + +import { Modal, ModalContent, ModalTrigger, Select, SelectItem } from "@app/components/v2"; + +enum Region { + US = "us", + EU = "eu" +} + +const regions = [ + { + value: Region.US, + label: "United States", + location: "Virginia, USA", + flag: ( + + + + + + + + + + ) + }, + { + value: Region.EU, + label: "Europe", + location: "Frankfurt, Germany", + flag: ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) + } +]; + +export const RegionSelect = () => { + const router = useRouter(); + + const handleRegionSelect = (value: Region) => { + router.push(`https://${value}.infisical.com/${router.pathname}`); + }; + + const [subdomain, domain] = window.location.host.split("."); + + // only display region select for cloud + if (!domain?.match(/infisical/)) return null; + + // default to US if not eu + const currentRegion = subdomain === Region.EU ? regions[1] : regions[0]; + + return ( +
+ + + + + + + {regions.map(({ value, label, location, flag }) => ( +
+

+ {flag} + {value.toUpperCase()} Region +

+
    +
  • + Fastest + option if you are based in {value === Region.US ? "the" : ""} {label} +
  • +
  • + Data + storage compliance for this region +
  • +
  • + Hosted + in {location} +
  • +
+
+ ))} +
+
+
+ ); +}; diff --git a/frontend/src/components/signup/InitialSignupStep.tsx b/frontend/src/components/signup/InitialSignupStep.tsx index 3a7c6db04..fd63f33f0 100644 --- a/frontend/src/components/signup/InitialSignupStep.tsx +++ b/frontend/src/components/signup/InitialSignupStep.tsx @@ -4,6 +4,7 @@ import { faGithub, faGitlab, faGoogle } from "@fortawesome/free-brands-svg-icons import { faEnvelope } from "@fortawesome/free-regular-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { RegionSelect } from "@app/components/navigation/RegionSelect"; import { useServerConfig } from "@app/context"; import { LoginMethod } from "@app/hooks/api/admin/types"; @@ -25,6 +26,7 @@ export default function InitialSignupStep({

{t("signup.initial-title")}

+ {shouldDisplaySignupMethod(LoginMethod.GOOGLE) && (
-
- )} - {shouldDisplayLoginMethod(LoginMethod.GITHUB) && ( -
- -
- )} - {shouldDisplayLoginMethod(LoginMethod.GITLAB) && ( -
- -
- )} + {shouldDisplayLoginMethod(LoginMethod.SAML) && ( -
+
)} +
+ {shouldDisplayLoginMethod(LoginMethod.GOOGLE) && ( + + { + const callbackPort = queryParams.get("callback_port"); + + window.open( + `/api/v1/sso/redirect/google${ + callbackPort ? `?callback_port=${callbackPort}` : "" + }` + ); + window.close(); + }} + className="h-10 w-full bg-mineshaft-600" + > + + + + )} + {shouldDisplayLoginMethod(LoginMethod.GITHUB) && ( + + { + const callbackPort = queryParams.get("callback_port"); + + window.open( + `/api/v1/sso/redirect/github${ + callbackPort ? `?callback_port=${callbackPort}` : "" + }` + ); + + window.close(); + }} + className="h-10 w-full bg-mineshaft-600" + > + + + + )} + {shouldDisplayLoginMethod(LoginMethod.GITLAB) && ( + + { + const callbackPort = queryParams.get("callback_port"); + + window.open( + `/api/v1/sso/redirect/gitlab${ + callbackPort ? `?callback_port=${callbackPort}` : "" + }` + ); + + window.close(); + }} + className="h-10 w-full bg-mineshaft-600" + > + + + + )} +
{(!config.enabledLoginMethods || (shouldDisplayLoginMethod(LoginMethod.EMAIL) && config.enabledLoginMethods.length > 1)) && (
@@ -316,7 +326,7 @@ export const InitialStep = ({ setStep, email, setEmail, password, setPassword }: />
)} -
+