From 0284ffc75fac6c699bbda102f2054d905937b596 Mon Sep 17 00:00:00 2001 From: Jeroen Reumkens Date: Mon, 17 Oct 2022 14:44:43 +0200 Subject: [PATCH] Removed v2 pages directory, moved all pages to root and deleted old v1 pages and middleware redirect. (#5044) * Removed v2 pages directory, moved all pages to root and deleted old v1 pages and middleware redirect. * Removed v2 from imports path. Co-authored-by: Alex van Andel --- .../v2/eventtype/AvailabilityTab.tsx | 2 +- .../v2/eventtype/EventAdvancedTab.tsx | 2 +- .../components/v2/eventtype/EventAppsTab.tsx | 2 +- .../v2/eventtype/EventLimitsTab.tsx | 2 +- .../v2/eventtype/EventRecurringTab.tsx | 2 +- .../components/v2/eventtype/EventSetupTab.tsx | 2 +- .../components/v2/eventtype/EventTeamTab.tsx | 2 +- .../v2/eventtype/EventTypeSingleLayout.tsx | 2 +- .../v2/eventtype/RecurringEventController.tsx | 2 +- apps/web/middleware.ts | 33 --- apps/web/pages/apps/[slug]/index.tsx | 48 +--- apps/web/pages/apps/[slug]/setup.tsx | 11 +- .../{v2 => }/apps/categories/[category].tsx | 0 .../pages/{v2 => }/apps/categories/index.tsx | 0 apps/web/pages/{v2 => }/apps/index.tsx | 0 .../{v2 => }/apps/installed/[category].tsx | 0 .../pages/{v2 => }/apps/installed/index.tsx | 0 apps/web/pages/auth/login.tsx | 110 ++++---- .../{v2 => }/availability/[schedule].tsx | 0 .../web/pages/{v2 => }/availability/index.tsx | 0 .../{v2 => }/availability/troubleshoot.tsx | 0 apps/web/pages/{v2 => }/bookings/[status].tsx | 0 .../{v2 => }/event-types/[type]/index.tsx | 0 apps/web/pages/{v2 => }/event-types/index.tsx | 0 .../pages/{v2 => }/settings/admin/apps.tsx | 0 .../{v2 => }/settings/admin/impersonation.tsx | 0 .../pages/{v2 => }/settings/admin/index.tsx | 0 .../pages/{v2 => }/settings/admin/users.tsx | 0 .../pages/{v2 => }/settings/billing/index.tsx | 0 .../{v2 => }/settings/developer/api-keys.tsx | 0 .../developer/webhooks/[id]/index.tsx | 0 .../settings/developer/webhooks/index.tsx | 0 .../settings/developer/webhooks/new.tsx | 0 .../settings/my-account/appearance.tsx | 0 .../settings/my-account/calendars.tsx | 0 .../settings/my-account/conferencing.tsx | 0 .../{v2 => }/settings/my-account/general.tsx | 0 .../{v2 => }/settings/my-account/profile.tsx | 0 .../{v2 => }/settings/security/password.tsx | 0 .../settings/security/two-factor-auth.tsx | 0 .../settings/teams/[id]/appearance.tsx | 0 .../{v2 => }/settings/teams/[id]/members.tsx | 0 .../{v2 => }/settings/teams/[id]/profile.tsx | 0 .../settings/teams/new/[[...step]].tsx | 0 apps/web/pages/{v2 => }/success.tsx | 0 apps/web/pages/{v2 => }/teams/index.tsx | 0 apps/web/pages/v2/apps/[slug]/index.tsx | 107 -------- apps/web/pages/v2/apps/[slug]/setup.tsx | 36 --- apps/web/pages/v2/auth/login.tsx | 241 ------------------ .../pages/{v2 => }/workflows/[workflow].tsx | 0 apps/web/pages/{v2 => }/workflows/index.tsx | 0 51 files changed, 74 insertions(+), 530 deletions(-) rename apps/web/pages/{v2 => }/apps/categories/[category].tsx (100%) rename apps/web/pages/{v2 => }/apps/categories/index.tsx (100%) rename apps/web/pages/{v2 => }/apps/index.tsx (100%) rename apps/web/pages/{v2 => }/apps/installed/[category].tsx (100%) rename apps/web/pages/{v2 => }/apps/installed/index.tsx (100%) rename apps/web/pages/{v2 => }/availability/[schedule].tsx (100%) rename apps/web/pages/{v2 => }/availability/index.tsx (100%) rename apps/web/pages/{v2 => }/availability/troubleshoot.tsx (100%) rename apps/web/pages/{v2 => }/bookings/[status].tsx (100%) rename apps/web/pages/{v2 => }/event-types/[type]/index.tsx (100%) rename apps/web/pages/{v2 => }/event-types/index.tsx (100%) rename apps/web/pages/{v2 => }/settings/admin/apps.tsx (100%) rename apps/web/pages/{v2 => }/settings/admin/impersonation.tsx (100%) rename apps/web/pages/{v2 => }/settings/admin/index.tsx (100%) rename apps/web/pages/{v2 => }/settings/admin/users.tsx (100%) rename apps/web/pages/{v2 => }/settings/billing/index.tsx (100%) rename apps/web/pages/{v2 => }/settings/developer/api-keys.tsx (100%) rename apps/web/pages/{v2 => }/settings/developer/webhooks/[id]/index.tsx (100%) rename apps/web/pages/{v2 => }/settings/developer/webhooks/index.tsx (100%) rename apps/web/pages/{v2 => }/settings/developer/webhooks/new.tsx (100%) rename apps/web/pages/{v2 => }/settings/my-account/appearance.tsx (100%) rename apps/web/pages/{v2 => }/settings/my-account/calendars.tsx (100%) rename apps/web/pages/{v2 => }/settings/my-account/conferencing.tsx (100%) rename apps/web/pages/{v2 => }/settings/my-account/general.tsx (100%) rename apps/web/pages/{v2 => }/settings/my-account/profile.tsx (100%) rename apps/web/pages/{v2 => }/settings/security/password.tsx (100%) rename apps/web/pages/{v2 => }/settings/security/two-factor-auth.tsx (100%) rename apps/web/pages/{v2 => }/settings/teams/[id]/appearance.tsx (100%) rename apps/web/pages/{v2 => }/settings/teams/[id]/members.tsx (100%) rename apps/web/pages/{v2 => }/settings/teams/[id]/profile.tsx (100%) rename apps/web/pages/{v2 => }/settings/teams/new/[[...step]].tsx (100%) rename apps/web/pages/{v2 => }/success.tsx (100%) rename apps/web/pages/{v2 => }/teams/index.tsx (100%) delete mode 100644 apps/web/pages/v2/apps/[slug]/index.tsx delete mode 100644 apps/web/pages/v2/apps/[slug]/setup.tsx delete mode 100644 apps/web/pages/v2/auth/login.tsx rename apps/web/pages/{v2 => }/workflows/[workflow].tsx (100%) rename apps/web/pages/{v2 => }/workflows/index.tsx (100%) diff --git a/apps/web/components/v2/eventtype/AvailabilityTab.tsx b/apps/web/components/v2/eventtype/AvailabilityTab.tsx index 8be0d029ab..c29fe45f59 100644 --- a/apps/web/components/v2/eventtype/AvailabilityTab.tsx +++ b/apps/web/components/v2/eventtype/AvailabilityTab.tsx @@ -1,4 +1,4 @@ -import { FormValues } from "pages/v2/event-types/[type]"; +import { FormValues } from "pages/event-types/[type]"; import { Controller, useFormContext } from "react-hook-form"; import dayjs from "@calcom/dayjs"; diff --git a/apps/web/components/v2/eventtype/EventAdvancedTab.tsx b/apps/web/components/v2/eventtype/EventAdvancedTab.tsx index 818a354821..0317af6a44 100644 --- a/apps/web/components/v2/eventtype/EventAdvancedTab.tsx +++ b/apps/web/components/v2/eventtype/EventAdvancedTab.tsx @@ -1,7 +1,7 @@ import autoAnimate from "@formkit/auto-animate"; import { EventTypeCustomInput } from "@prisma/client/"; import Link from "next/link"; -import { EventTypeSetupInfered, FormValues } from "pages/v2/event-types/[type]"; +import { EventTypeSetupInfered, FormValues } from "pages/event-types/[type]"; import { useEffect, useRef, useState } from "react"; import { Controller, useFormContext } from "react-hook-form"; import short from "short-uuid"; diff --git a/apps/web/components/v2/eventtype/EventAppsTab.tsx b/apps/web/components/v2/eventtype/EventAppsTab.tsx index f965b7e640..eea8a134da 100644 --- a/apps/web/components/v2/eventtype/EventAppsTab.tsx +++ b/apps/web/components/v2/eventtype/EventAppsTab.tsx @@ -1,4 +1,4 @@ -import { EventTypeSetupInfered, FormValues } from "pages/v2/event-types/[type]"; +import { EventTypeSetupInfered, FormValues } from "pages/event-types/[type]"; import React from "react"; import { useFormContext } from "react-hook-form"; diff --git a/apps/web/components/v2/eventtype/EventLimitsTab.tsx b/apps/web/components/v2/eventtype/EventLimitsTab.tsx index f02874fa44..670d8d71cb 100644 --- a/apps/web/components/v2/eventtype/EventLimitsTab.tsx +++ b/apps/web/components/v2/eventtype/EventLimitsTab.tsx @@ -1,6 +1,6 @@ import autoAnimate from "@formkit/auto-animate"; import * as RadioGroup from "@radix-ui/react-radio-group"; -import { EventTypeSetupInfered, FormValues } from "pages/v2/event-types/[type]"; +import { EventTypeSetupInfered, FormValues } from "pages/event-types/[type]"; import { useEffect, useRef, useState } from "react"; import { useFormContext, Controller, useWatch } from "react-hook-form"; diff --git a/apps/web/components/v2/eventtype/EventRecurringTab.tsx b/apps/web/components/v2/eventtype/EventRecurringTab.tsx index 5da6cda426..e6945ed7ea 100644 --- a/apps/web/components/v2/eventtype/EventRecurringTab.tsx +++ b/apps/web/components/v2/eventtype/EventRecurringTab.tsx @@ -1,4 +1,4 @@ -import { EventTypeSetupInfered } from "pages/v2/event-types/[type]"; +import { EventTypeSetupInfered } from "pages/event-types/[type]"; import { useState } from "react"; import getStripeAppData from "@calcom/lib/getStripeAppData"; diff --git a/apps/web/components/v2/eventtype/EventSetupTab.tsx b/apps/web/components/v2/eventtype/EventSetupTab.tsx index cdc93d15d9..9daf9fd58a 100644 --- a/apps/web/components/v2/eventtype/EventSetupTab.tsx +++ b/apps/web/components/v2/eventtype/EventSetupTab.tsx @@ -1,7 +1,7 @@ import autoAnimate from "@formkit/auto-animate"; import { zodResolver } from "@hookform/resolvers/zod"; import { isValidPhoneNumber } from "libphonenumber-js"; -import { EventTypeSetupInfered, FormValues } from "pages/v2/event-types/[type]"; +import { EventTypeSetupInfered, FormValues } from "pages/event-types/[type]"; import { useEffect, useRef, useState } from "react"; import { Controller, useForm, useFormContext } from "react-hook-form"; import { z } from "zod"; diff --git a/apps/web/components/v2/eventtype/EventTeamTab.tsx b/apps/web/components/v2/eventtype/EventTeamTab.tsx index 38fa1244ef..96a7210989 100644 --- a/apps/web/components/v2/eventtype/EventTeamTab.tsx +++ b/apps/web/components/v2/eventtype/EventTeamTab.tsx @@ -1,5 +1,5 @@ import { SchedulingType } from "@prisma/client/"; -import { EventTypeSetupInfered, FormValues } from "pages/v2/event-types/[type]"; +import { EventTypeSetupInfered, FormValues } from "pages/event-types/[type]"; import { useMemo } from "react"; import { Controller, useFormContext } from "react-hook-form"; diff --git a/apps/web/components/v2/eventtype/EventTypeSingleLayout.tsx b/apps/web/components/v2/eventtype/EventTypeSingleLayout.tsx index c914838bf5..da9b20a07d 100644 --- a/apps/web/components/v2/eventtype/EventTypeSingleLayout.tsx +++ b/apps/web/components/v2/eventtype/EventTypeSingleLayout.tsx @@ -1,6 +1,6 @@ import { TFunction } from "next-i18next"; import { useRouter } from "next/router"; -import { EventTypeSetupInfered, FormValues } from "pages/v2/event-types/[type]"; +import { EventTypeSetupInfered, FormValues } from "pages/event-types/[type]"; import { useMemo, useState } from "react"; import { Loader } from "react-feather"; import { UseFormReturn } from "react-hook-form"; diff --git a/apps/web/components/v2/eventtype/RecurringEventController.tsx b/apps/web/components/v2/eventtype/RecurringEventController.tsx index b4da5e5e5b..f81d35a6a7 100644 --- a/apps/web/components/v2/eventtype/RecurringEventController.tsx +++ b/apps/web/components/v2/eventtype/RecurringEventController.tsx @@ -1,4 +1,4 @@ -import type { FormValues } from "pages/v2/event-types/[type]"; +import type { FormValues } from "pages/event-types/[type]"; import { useState } from "react"; import { useFormContext } from "react-hook-form"; diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index 5ab3a34476..fb0d5b68a1 100644 --- a/apps/web/middleware.ts +++ b/apps/web/middleware.ts @@ -5,29 +5,6 @@ import { CONSOLE_URL, WEBAPP_URL, WEBSITE_URL } from "@calcom/lib/constants"; import { isIpInBanlist } from "@calcom/lib/getIP"; import { extendEventData, nextCollectBasicSettings } from "@calcom/lib/telemetry"; -const V2_WHITELIST = [ - "/settings/admin", - "/settings/billing", - "/settings/developer/webhooks", - "/settings/developer/api-keys", - "/settings/my-account", - "/settings/security", - "/settings/teams", - "/availability", - "/bookings", - "/event-types", - "/workflows", - "/apps", - "/teams", - "/success", - "/auth/login", -]; - -// For pages -// - which has V1 versions being modified as V2 -// - Add routing_forms to keep old links working -const V2_BLACKLIST = ["/apps/routing_forms/", "/apps/routing-forms/", "/apps/typeform/"]; - const middleware: NextMiddleware = async (req) => { const url = req.nextUrl; @@ -52,16 +29,6 @@ const middleware: NextMiddleware = async (req) => { return NextResponse.rewrite(url); } - /** Display available V2 pages */ - if ( - !V2_BLACKLIST.some((p) => url.pathname.startsWith(p)) && - V2_WHITELIST.some((p) => url.pathname.startsWith(p)) - ) { - // rewrite to the current subdomain under the pages/sites folder - url.pathname = `/v2${url.pathname}`; - return NextResponse.rewrite(url); - } - return NextResponse.next(); }; diff --git a/apps/web/pages/apps/[slug]/index.tsx b/apps/web/pages/apps/[slug]/index.tsx index 7141906f41..2b69e599a4 100644 --- a/apps/web/pages/apps/[slug]/index.tsx +++ b/apps/web/pages/apps/[slug]/index.tsx @@ -10,11 +10,9 @@ import path from "path"; import { getAppWithMetadata } from "@calcom/app-store/_appRegistry"; import prisma from "@calcom/prisma"; -import useMediaQuery from "@lib/hooks/useMediaQuery"; import { inferSSRProps } from "@lib/types/inferSSRProps"; -import App from "@components/App"; -import Slider from "@components/apps/Slider"; +import App from "@components/v2/apps/App"; const components = { a: ({ href = "", ...otherProps }: JSX.IntrinsicElements["a"]) => ( @@ -25,42 +23,11 @@ const components = { img: ({ src = "", alt = "", placeholder, ...rest }: JSX.IntrinsicElements["img"]) => ( {alt} ), - Slider: ({ items }: { items: string[] }) => { - const isTabletAndUp = useMediaQuery("(min-width: 960px)"); - return ( - - items={items} - title="Screenshots" - options={{ - perView: 1, - }} - renderItem={(item) => - isTabletAndUp ? ( - - ) : ( - - ) - } - /> - ); - }, + // @TODO: In v2 the slider isn't shown anymore. However, to ensure the v1 pages keep + // working, this component is still rendered in the MDX content. To skip them in the v2 + // content we have to render null here. In v2 the gallery is shown by directly + // using the `items` property from the MDX's meta data. + Slider: () => <>, }; function SingleAppPage({ data, source }: inferSSRProps) { @@ -68,6 +35,8 @@ function SingleAppPage({ data, source }: inferSSRProps) { ) { email={data.email} licenseRequired={data.licenseRequired} isProOnly={data.isProOnly} + images={source?.scope?.items as string[] | undefined} // tos="https://zoom.us/terms" // privacy="https://zoom.us/privacy" body={} diff --git a/apps/web/pages/apps/[slug]/setup.tsx b/apps/web/pages/apps/[slug]/setup.tsx index b472a0b974..4cd7a56216 100644 --- a/apps/web/pages/apps/[slug]/setup.tsx +++ b/apps/web/pages/apps/[slug]/setup.tsx @@ -2,9 +2,8 @@ import { GetStaticPaths, InferGetStaticPropsType } from "next"; import { useSession } from "next-auth/react"; import { useRouter } from "next/router"; -import { AppSetupPage } from "@calcom/app-store/_pages/setup"; import { getStaticProps } from "@calcom/app-store/_pages/setup/_getStaticProps"; -import Loader from "@calcom/ui/Loader"; +import { AppSetupPage } from "@calcom/app-store/_pages/v2/setup"; export default function SetupInformation(props: InferGetStaticPropsType) { const router = useRouter(); @@ -12,11 +11,7 @@ export default function SetupInformation(props: InferGetStaticPropsType - - - ); + return
; } if (status === "unauthenticated") { @@ -28,7 +23,7 @@ export default function SetupInformation(props: InferGetStaticPropsType; + return ; } export const getStaticPaths: GetStaticPaths = async () => { diff --git a/apps/web/pages/v2/apps/categories/[category].tsx b/apps/web/pages/apps/categories/[category].tsx similarity index 100% rename from apps/web/pages/v2/apps/categories/[category].tsx rename to apps/web/pages/apps/categories/[category].tsx diff --git a/apps/web/pages/v2/apps/categories/index.tsx b/apps/web/pages/apps/categories/index.tsx similarity index 100% rename from apps/web/pages/v2/apps/categories/index.tsx rename to apps/web/pages/apps/categories/index.tsx diff --git a/apps/web/pages/v2/apps/index.tsx b/apps/web/pages/apps/index.tsx similarity index 100% rename from apps/web/pages/v2/apps/index.tsx rename to apps/web/pages/apps/index.tsx diff --git a/apps/web/pages/v2/apps/installed/[category].tsx b/apps/web/pages/apps/installed/[category].tsx similarity index 100% rename from apps/web/pages/v2/apps/installed/[category].tsx rename to apps/web/pages/apps/installed/[category].tsx diff --git a/apps/web/pages/v2/apps/installed/index.tsx b/apps/web/pages/apps/installed/index.tsx similarity index 100% rename from apps/web/pages/v2/apps/installed/index.tsx rename to apps/web/pages/apps/installed/index.tsx diff --git a/apps/web/pages/auth/login.tsx b/apps/web/pages/auth/login.tsx index 4a14dcb987..4fa4f9cd1c 100644 --- a/apps/web/pages/auth/login.tsx +++ b/apps/web/pages/auth/login.tsx @@ -5,15 +5,16 @@ import Link from "next/link"; import { useRouter } from "next/router"; import { useState } from "react"; import { useForm } from "react-hook-form"; +import { FaGoogle } from "react-icons/fa"; import { getSafeRedirectUrl } from "@calcom/lib/getSafeRedirectUrl"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry"; import prisma from "@calcom/prisma"; +import { Icon } from "@calcom/ui"; import { Alert } from "@calcom/ui/Alert"; -import Button from "@calcom/ui/Button"; -import { Icon } from "@calcom/ui/Icon"; -import { EmailField, Form, PasswordField } from "@calcom/ui/form/fields"; +import { Button, EmailField, Form, PasswordField } from "@calcom/ui/v2"; +import SAMLLogin from "@calcom/ui/v2/modules/auth/SAMLLogin"; import { ErrorCode, getSession } from "@lib/auth"; import { WEBAPP_URL, WEBSITE_URL } from "@lib/config/constants"; @@ -21,9 +22,8 @@ import { hostedCal, isSAMLLoginEnabled, samlProductID, samlTenantID } from "@lib import { inferSSRProps } from "@lib/types/inferSSRProps"; import AddToHomescreen from "@components/AddToHomescreen"; -import SAMLLogin from "@components/auth/SAMLLogin"; import TwoFactor from "@components/auth/TwoFactor"; -import AuthContainer from "@components/ui/AuthContainer"; +import AuthContainer from "@components/v2/ui/AuthContainer"; import { IS_GOOGLE_LOGIN_ENABLED } from "@server/lib/constants"; import { ssrInit } from "@server/lib/ssr"; @@ -53,8 +53,7 @@ export default function Login({ const [errorMessage, setErrorMessage] = useState(null); const errorMessages: { [key: string]: string } = { - [ErrorCode.RateLimitExceeded]: t("rate_limit_exceeded"), - [ErrorCode.SecondFactorRequired]: t("2fa_enabled_instructions"), + // [ErrorCode.SecondFactorRequired]: t("2fa_enabled_instructions"), [ErrorCode.IncorrectPassword]: `${t("incorrect_password")} ${t("please_try_again")}`, [ErrorCode.UserNotFound]: t("no_account_exists"), [ErrorCode.IncorrectTwoFactorCode]: `${t("incorrect_2fa_code")} ${t("please_try_again")}`, @@ -78,12 +77,9 @@ export default function Login({ callbackUrl = safeCallbackUrl || ""; const LoginFooter = ( - - {t("dont_have_an_account")}{" "} - - {t("create_an_account")} - - + + {t("dont_have_an_account")} + ); const TwoFactorFooter = ( @@ -104,11 +100,10 @@ export default function Login({ title={t("login")} description={t("login")} showLogo - heading={twoFactorRequired ? t("2fa_code") : t("sign_in_account")} + heading={twoFactorRequired ? t("2fa_code") : t("welcome_back")} footerText={twoFactorRequired ? TwoFactorFooter : LoginFooter}>
{ setErrorMessage(null); telemetry.event(telemetryEventTypes.login, collectPageParameters()); @@ -134,51 +129,52 @@ export default function Login({ {...form.register("csrfToken")} />
-
- -
- - +
+ +
+ + +
-
- {twoFactorRequired && } + {twoFactorRequired && } - {errorMessage && } -
-
- {!twoFactorRequired && ( <> - {isGoogleLoginEnabled && ( -
+ {(isGoogleLoginEnabled || isSAMLLoginEnabled) &&
} +
+ {isGoogleLoginEnabled && ( -
- )} - {isSAMLLoginEnabled && ( - - )} + )} + {isSAMLLoginEnabled && ( + + )} +
)} diff --git a/apps/web/pages/v2/availability/[schedule].tsx b/apps/web/pages/availability/[schedule].tsx similarity index 100% rename from apps/web/pages/v2/availability/[schedule].tsx rename to apps/web/pages/availability/[schedule].tsx diff --git a/apps/web/pages/v2/availability/index.tsx b/apps/web/pages/availability/index.tsx similarity index 100% rename from apps/web/pages/v2/availability/index.tsx rename to apps/web/pages/availability/index.tsx diff --git a/apps/web/pages/v2/availability/troubleshoot.tsx b/apps/web/pages/availability/troubleshoot.tsx similarity index 100% rename from apps/web/pages/v2/availability/troubleshoot.tsx rename to apps/web/pages/availability/troubleshoot.tsx diff --git a/apps/web/pages/v2/bookings/[status].tsx b/apps/web/pages/bookings/[status].tsx similarity index 100% rename from apps/web/pages/v2/bookings/[status].tsx rename to apps/web/pages/bookings/[status].tsx diff --git a/apps/web/pages/v2/event-types/[type]/index.tsx b/apps/web/pages/event-types/[type]/index.tsx similarity index 100% rename from apps/web/pages/v2/event-types/[type]/index.tsx rename to apps/web/pages/event-types/[type]/index.tsx diff --git a/apps/web/pages/v2/event-types/index.tsx b/apps/web/pages/event-types/index.tsx similarity index 100% rename from apps/web/pages/v2/event-types/index.tsx rename to apps/web/pages/event-types/index.tsx diff --git a/apps/web/pages/v2/settings/admin/apps.tsx b/apps/web/pages/settings/admin/apps.tsx similarity index 100% rename from apps/web/pages/v2/settings/admin/apps.tsx rename to apps/web/pages/settings/admin/apps.tsx diff --git a/apps/web/pages/v2/settings/admin/impersonation.tsx b/apps/web/pages/settings/admin/impersonation.tsx similarity index 100% rename from apps/web/pages/v2/settings/admin/impersonation.tsx rename to apps/web/pages/settings/admin/impersonation.tsx diff --git a/apps/web/pages/v2/settings/admin/index.tsx b/apps/web/pages/settings/admin/index.tsx similarity index 100% rename from apps/web/pages/v2/settings/admin/index.tsx rename to apps/web/pages/settings/admin/index.tsx diff --git a/apps/web/pages/v2/settings/admin/users.tsx b/apps/web/pages/settings/admin/users.tsx similarity index 100% rename from apps/web/pages/v2/settings/admin/users.tsx rename to apps/web/pages/settings/admin/users.tsx diff --git a/apps/web/pages/v2/settings/billing/index.tsx b/apps/web/pages/settings/billing/index.tsx similarity index 100% rename from apps/web/pages/v2/settings/billing/index.tsx rename to apps/web/pages/settings/billing/index.tsx diff --git a/apps/web/pages/v2/settings/developer/api-keys.tsx b/apps/web/pages/settings/developer/api-keys.tsx similarity index 100% rename from apps/web/pages/v2/settings/developer/api-keys.tsx rename to apps/web/pages/settings/developer/api-keys.tsx diff --git a/apps/web/pages/v2/settings/developer/webhooks/[id]/index.tsx b/apps/web/pages/settings/developer/webhooks/[id]/index.tsx similarity index 100% rename from apps/web/pages/v2/settings/developer/webhooks/[id]/index.tsx rename to apps/web/pages/settings/developer/webhooks/[id]/index.tsx diff --git a/apps/web/pages/v2/settings/developer/webhooks/index.tsx b/apps/web/pages/settings/developer/webhooks/index.tsx similarity index 100% rename from apps/web/pages/v2/settings/developer/webhooks/index.tsx rename to apps/web/pages/settings/developer/webhooks/index.tsx diff --git a/apps/web/pages/v2/settings/developer/webhooks/new.tsx b/apps/web/pages/settings/developer/webhooks/new.tsx similarity index 100% rename from apps/web/pages/v2/settings/developer/webhooks/new.tsx rename to apps/web/pages/settings/developer/webhooks/new.tsx diff --git a/apps/web/pages/v2/settings/my-account/appearance.tsx b/apps/web/pages/settings/my-account/appearance.tsx similarity index 100% rename from apps/web/pages/v2/settings/my-account/appearance.tsx rename to apps/web/pages/settings/my-account/appearance.tsx diff --git a/apps/web/pages/v2/settings/my-account/calendars.tsx b/apps/web/pages/settings/my-account/calendars.tsx similarity index 100% rename from apps/web/pages/v2/settings/my-account/calendars.tsx rename to apps/web/pages/settings/my-account/calendars.tsx diff --git a/apps/web/pages/v2/settings/my-account/conferencing.tsx b/apps/web/pages/settings/my-account/conferencing.tsx similarity index 100% rename from apps/web/pages/v2/settings/my-account/conferencing.tsx rename to apps/web/pages/settings/my-account/conferencing.tsx diff --git a/apps/web/pages/v2/settings/my-account/general.tsx b/apps/web/pages/settings/my-account/general.tsx similarity index 100% rename from apps/web/pages/v2/settings/my-account/general.tsx rename to apps/web/pages/settings/my-account/general.tsx diff --git a/apps/web/pages/v2/settings/my-account/profile.tsx b/apps/web/pages/settings/my-account/profile.tsx similarity index 100% rename from apps/web/pages/v2/settings/my-account/profile.tsx rename to apps/web/pages/settings/my-account/profile.tsx diff --git a/apps/web/pages/v2/settings/security/password.tsx b/apps/web/pages/settings/security/password.tsx similarity index 100% rename from apps/web/pages/v2/settings/security/password.tsx rename to apps/web/pages/settings/security/password.tsx diff --git a/apps/web/pages/v2/settings/security/two-factor-auth.tsx b/apps/web/pages/settings/security/two-factor-auth.tsx similarity index 100% rename from apps/web/pages/v2/settings/security/two-factor-auth.tsx rename to apps/web/pages/settings/security/two-factor-auth.tsx diff --git a/apps/web/pages/v2/settings/teams/[id]/appearance.tsx b/apps/web/pages/settings/teams/[id]/appearance.tsx similarity index 100% rename from apps/web/pages/v2/settings/teams/[id]/appearance.tsx rename to apps/web/pages/settings/teams/[id]/appearance.tsx diff --git a/apps/web/pages/v2/settings/teams/[id]/members.tsx b/apps/web/pages/settings/teams/[id]/members.tsx similarity index 100% rename from apps/web/pages/v2/settings/teams/[id]/members.tsx rename to apps/web/pages/settings/teams/[id]/members.tsx diff --git a/apps/web/pages/v2/settings/teams/[id]/profile.tsx b/apps/web/pages/settings/teams/[id]/profile.tsx similarity index 100% rename from apps/web/pages/v2/settings/teams/[id]/profile.tsx rename to apps/web/pages/settings/teams/[id]/profile.tsx diff --git a/apps/web/pages/v2/settings/teams/new/[[...step]].tsx b/apps/web/pages/settings/teams/new/[[...step]].tsx similarity index 100% rename from apps/web/pages/v2/settings/teams/new/[[...step]].tsx rename to apps/web/pages/settings/teams/new/[[...step]].tsx diff --git a/apps/web/pages/v2/success.tsx b/apps/web/pages/success.tsx similarity index 100% rename from apps/web/pages/v2/success.tsx rename to apps/web/pages/success.tsx diff --git a/apps/web/pages/v2/teams/index.tsx b/apps/web/pages/teams/index.tsx similarity index 100% rename from apps/web/pages/v2/teams/index.tsx rename to apps/web/pages/teams/index.tsx diff --git a/apps/web/pages/v2/apps/[slug]/index.tsx b/apps/web/pages/v2/apps/[slug]/index.tsx deleted file mode 100644 index 2b69e599a4..0000000000 --- a/apps/web/pages/v2/apps/[slug]/index.tsx +++ /dev/null @@ -1,107 +0,0 @@ -import fs from "fs"; -import matter from "gray-matter"; -import { GetStaticPaths, GetStaticPropsContext } from "next"; -import { MDXRemote } from "next-mdx-remote"; -import { serialize } from "next-mdx-remote/serialize"; -import Image from "next/image"; -import Link from "next/link"; -import path from "path"; - -import { getAppWithMetadata } from "@calcom/app-store/_appRegistry"; -import prisma from "@calcom/prisma"; - -import { inferSSRProps } from "@lib/types/inferSSRProps"; - -import App from "@components/v2/apps/App"; - -const components = { - a: ({ href = "", ...otherProps }: JSX.IntrinsicElements["a"]) => ( - - - - ), - img: ({ src = "", alt = "", placeholder, ...rest }: JSX.IntrinsicElements["img"]) => ( - {alt} - ), - // @TODO: In v2 the slider isn't shown anymore. However, to ensure the v1 pages keep - // working, this component is still rendered in the MDX content. To skip them in the v2 - // content we have to render null here. In v2 the gallery is shown by directly - // using the `items` property from the MDX's meta data. - Slider: () => <>, -}; - -function SingleAppPage({ data, source }: inferSSRProps) { - return ( - } - /> - ); -} - -export const getStaticPaths: GetStaticPaths<{ slug: string }> = async () => { - const appStore = await prisma.app.findMany({ select: { slug: true } }); - const paths = appStore.map(({ slug }) => ({ params: { slug } })); - - return { - paths, - fallback: false, - }; -}; - -export const getStaticProps = async (ctx: GetStaticPropsContext) => { - if (typeof ctx.params?.slug !== "string") return { notFound: true }; - - const app = await prisma.app.findUnique({ - where: { slug: ctx.params.slug }, - }); - - if (!app) return { notFound: true }; - - const singleApp = await getAppWithMetadata(app); - - if (!singleApp) return { notFound: true }; - - const appDirname = app.dirName; - const README_PATH = path.join(process.cwd(), "..", "..", `packages/app-store/${appDirname}/README.mdx`); - const postFilePath = path.join(README_PATH); - let source = ""; - - try { - /* If the app doesn't have a README we fallback to the package description */ - source = fs.readFileSync(postFilePath).toString(); - } catch (error) { - console.log(`No README.mdx provided for: ${appDirname}`); - source = singleApp.description; - } - - const { content, data } = matter(source); - const mdxSource = await serialize(content, { scope: data }); - - return { - props: { - source: mdxSource, - data: singleApp, - }, - }; -}; - -export default SingleAppPage; diff --git a/apps/web/pages/v2/apps/[slug]/setup.tsx b/apps/web/pages/v2/apps/[slug]/setup.tsx deleted file mode 100644 index 4cd7a56216..0000000000 --- a/apps/web/pages/v2/apps/[slug]/setup.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { GetStaticPaths, InferGetStaticPropsType } from "next"; -import { useSession } from "next-auth/react"; -import { useRouter } from "next/router"; - -import { getStaticProps } from "@calcom/app-store/_pages/setup/_getStaticProps"; -import { AppSetupPage } from "@calcom/app-store/_pages/v2/setup"; - -export default function SetupInformation(props: InferGetStaticPropsType) { - const router = useRouter(); - const slug = router.query.slug as string; - const { status } = useSession(); - - if (status === "loading") { - return
; - } - - if (status === "unauthenticated") { - router.replace({ - pathname: "/auth/login", - query: { - callbackUrl: `/apps/${slug}/setup`, - }, - }); - } - - return ; -} - -export const getStaticPaths: GetStaticPaths = async () => { - return { - paths: [], - fallback: "blocking", - }; -}; - -export { getStaticProps }; diff --git a/apps/web/pages/v2/auth/login.tsx b/apps/web/pages/v2/auth/login.tsx deleted file mode 100644 index 4fa4f9cd1c..0000000000 --- a/apps/web/pages/v2/auth/login.tsx +++ /dev/null @@ -1,241 +0,0 @@ -import classNames from "classnames"; -import { GetServerSidePropsContext } from "next"; -import { getCsrfToken, signIn } from "next-auth/react"; -import Link from "next/link"; -import { useRouter } from "next/router"; -import { useState } from "react"; -import { useForm } from "react-hook-form"; -import { FaGoogle } from "react-icons/fa"; - -import { getSafeRedirectUrl } from "@calcom/lib/getSafeRedirectUrl"; -import { useLocale } from "@calcom/lib/hooks/useLocale"; -import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry"; -import prisma from "@calcom/prisma"; -import { Icon } from "@calcom/ui"; -import { Alert } from "@calcom/ui/Alert"; -import { Button, EmailField, Form, PasswordField } from "@calcom/ui/v2"; -import SAMLLogin from "@calcom/ui/v2/modules/auth/SAMLLogin"; - -import { ErrorCode, getSession } from "@lib/auth"; -import { WEBAPP_URL, WEBSITE_URL } from "@lib/config/constants"; -import { hostedCal, isSAMLLoginEnabled, samlProductID, samlTenantID } from "@lib/saml"; -import { inferSSRProps } from "@lib/types/inferSSRProps"; - -import AddToHomescreen from "@components/AddToHomescreen"; -import TwoFactor from "@components/auth/TwoFactor"; -import AuthContainer from "@components/v2/ui/AuthContainer"; - -import { IS_GOOGLE_LOGIN_ENABLED } from "@server/lib/constants"; -import { ssrInit } from "@server/lib/ssr"; - -interface LoginValues { - email: string; - password: string; - totpCode: string; - csrfToken: string; -} - -export default function Login({ - csrfToken, - isGoogleLoginEnabled, - isSAMLLoginEnabled, - hostedCal, - samlTenantID, - samlProductID, -}: inferSSRProps) { - const { t } = useLocale(); - const router = useRouter(); - const form = useForm(); - const { formState } = form; - const { isSubmitting } = formState; - - const [twoFactorRequired, setTwoFactorRequired] = useState(false); - const [errorMessage, setErrorMessage] = useState(null); - - const errorMessages: { [key: string]: string } = { - // [ErrorCode.SecondFactorRequired]: t("2fa_enabled_instructions"), - [ErrorCode.IncorrectPassword]: `${t("incorrect_password")} ${t("please_try_again")}`, - [ErrorCode.UserNotFound]: t("no_account_exists"), - [ErrorCode.IncorrectTwoFactorCode]: `${t("incorrect_2fa_code")} ${t("please_try_again")}`, - [ErrorCode.InternalServerError]: `${t("something_went_wrong")} ${t("please_try_again_and_contact_us")}`, - [ErrorCode.ThirdPartyIdentityProviderEnabled]: t("account_created_with_identity_provider"), - }; - - const telemetry = useTelemetry(); - - let callbackUrl = typeof router.query?.callbackUrl === "string" ? router.query.callbackUrl : ""; - - if (/"\//.test(callbackUrl)) callbackUrl = callbackUrl.substring(1); - - // If not absolute URL, make it absolute - if (!/^https?:\/\//.test(callbackUrl)) { - callbackUrl = `${WEBAPP_URL}/${callbackUrl}`; - } - - const safeCallbackUrl = getSafeRedirectUrl(callbackUrl); - - callbackUrl = safeCallbackUrl || ""; - - const LoginFooter = ( - - {t("dont_have_an_account")} - - ); - - const TwoFactorFooter = ( - - ); - - return ( - <> - -
{ - setErrorMessage(null); - telemetry.event(telemetryEventTypes.login, collectPageParameters()); - const res = await signIn<"credentials">("credentials", { - ...values, - callbackUrl, - redirect: false, - }); - if (!res) setErrorMessage(errorMessages[ErrorCode.InternalServerError]); - // we're logged in! let's do a hard refresh to the desired url - else if (!res.error) router.push(callbackUrl); - // reveal two factor input if required - else if (res.error === ErrorCode.SecondFactorRequired) setTwoFactorRequired(true); - // fallback if error not found - else setErrorMessage(errorMessages[res.error] || t("something_went_wrong")); - }} - data-testid="login-form"> -
- -
-
-
- -
- - -
-
- - {twoFactorRequired && } - - {errorMessage && } - -
-
- {!twoFactorRequired && ( - <> - {(isGoogleLoginEnabled || isSAMLLoginEnabled) &&
} -
- {isGoogleLoginEnabled && ( - - )} - {isSAMLLoginEnabled && ( - - )} -
- - )} -
- - - ); -} - -export async function getServerSideProps(context: GetServerSidePropsContext) { - const { req } = context; - const session = await getSession({ req }); - const ssr = await ssrInit(context); - - if (session) { - return { - redirect: { - destination: "/", - permanent: false, - }, - }; - } - - const userCount = await prisma.user.count(); - if (userCount === 0) { - // Proceed to new onboarding to create first admin user - return { - redirect: { - destination: "/auth/setup", - permanent: false, - }, - }; - } - - return { - props: { - csrfToken: await getCsrfToken(context), - trpcState: ssr.dehydrate(), - isGoogleLoginEnabled: IS_GOOGLE_LOGIN_ENABLED, - isSAMLLoginEnabled, - hostedCal, - samlTenantID, - samlProductID, - }, - }; -} diff --git a/apps/web/pages/v2/workflows/[workflow].tsx b/apps/web/pages/workflows/[workflow].tsx similarity index 100% rename from apps/web/pages/v2/workflows/[workflow].tsx rename to apps/web/pages/workflows/[workflow].tsx diff --git a/apps/web/pages/v2/workflows/index.tsx b/apps/web/pages/workflows/index.tsx similarity index 100% rename from apps/web/pages/v2/workflows/index.tsx rename to apps/web/pages/workflows/index.tsx