Skip to content

Scheduling infrastructure for absolutely everyone.

Revert "feat: migrate /apps/routing-forms/forms to /routing (#18001)"

Alex van Andel9c127cbfc255
diff --git a/apps/web/lib/routing/getServerSideProps.ts b/apps/web/lib/routing/getServerSideProps.ts
deleted file mode 100644
index 1b8021fac74..00000000000
--- a/apps/web/lib/routing/getServerSideProps.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-import type { GetServerSidePropsContext } from "next";
-
-import { getAppWithMetadata } from "@calcom/app-store/_appRegistry";
-import RoutingFormsRoutingConfig from "@calcom/app-store/routing-forms/pages/app-routing.config";
-import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
-import prisma from "@calcom/prisma";
-import type { AppGetServerSideProps } from "@calcom/types/AppGetServerSideProps";
-
-import type { AppProps } from "@lib/app-providers";
-
-import { ssrInit } from "@server/lib/ssr";
-
-type AppPageType = {
- getServerSideProps?: AppGetServerSideProps;
- // A component than can accept any properties
- default: ((props: unknown) => JSX.Element) &
- Pick<AppProps["Component"], "isBookingPage" | "getLayout" | "PageWrapper">;
-};
-
-type Found = {
- notFound: false;
- Component: AppPageType["default"];
- getServerSideProps: AppPageType["getServerSideProps"];
-};
-
-type NotFound = {
- notFound: true;
-};
-
-function getRoute(pages: string[]) {
- const mainPage = pages[0] as keyof typeof RoutingFormsRoutingConfig;
- const appPage =
- RoutingFormsRoutingConfig.layoutHandler || (RoutingFormsRoutingConfig[mainPage] as AppPageType);
-
- if (!appPage) {
- return {
- notFound: true,
- } as NotFound;
- }
- return { notFound: false, Component: appPage.default, ...appPage } as Found;
-}
-
-export const getServerSideProps = async (context: GetServerSidePropsContext) => {
- const { req } = context;
- const appName = "routing-forms";
- const pages = ["forms"]; // set forms page to be the default one
- const route = getRoute(pages);
-
- if (route.notFound) {
- return { notFound: true };
- }
-
- if (route.getServerSideProps) {
- const session = await getServerSession({ req });
- const user = session?.user;
- const app = await getAppWithMetadata({ slug: appName });
-
- if (!app) {
- return {
- notFound: true,
- };
- }
-
- const result = await route.getServerSideProps(
- context as GetServerSidePropsContext<{
- slug: string;
- pages: string[];
- appPages: string[];
- }>,
- prisma,
- user,
- ssrInit
- );
-
- if (result.notFound) {
- return { notFound: true };
- }
-
- if (result.redirect) {
- return { redirect: result.redirect };
- }
-
- return {
- props: {
- appName,
- appUrl: "/apps/routing-forms",
- ...result.props,
- },
- };
- } else {
- return {
- props: {
- appName,
- },
- };
- }
-};
diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts
index 9d135c34182..95556aed892 100644
--- a/apps/web/middleware.ts
+++ b/apps/web/middleware.ts
@@ -41,10 +41,6 @@ const middleware = async (req: NextRequest): Promise<NextResponse<unknown>> => {
}
}
- if (url.pathname.startsWith("/apps/routing-forms/forms")) {
- return NextResponse.redirect(new URL("/routing", url.origin), { headers: requestHeaders });
- }
-
const routingFormRewriteResponse = routingForms.handleRewrite(url);
if (routingFormRewriteResponse) {
return responseWithHeaders({ url, res: routingFormRewriteResponse, req });
@@ -167,7 +163,7 @@ export const config = {
* Paths required by routingForms.handle
*/
"/apps/routing_forms/:path*",
- "/apps/routing-forms/forms",
+
"/event-types",
"/future/event-types/",
"/apps/installed/:category/",
diff --git a/apps/web/modules/routing/pages-view.tsx b/apps/web/modules/routing/pages-view.tsx
deleted file mode 100644
index 6aaac609eaa..00000000000
--- a/apps/web/modules/routing/pages-view.tsx
+++ /dev/null
@@ -1,88 +0,0 @@
-"use client";
-
-import RoutingFormsRoutingConfig from "@calcom/app-store/routing-forms/pages/app-routing.config";
-import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
-import type { AppGetServerSideProps } from "@calcom/types/AppGetServerSideProps";
-import type { inferSSRProps } from "@calcom/types/inferSSRProps";
-
-import type { AppProps } from "@lib/app-providers";
-import type { getServerSideProps } from "@lib/apps/[slug]/[...pages]/getServerSideProps";
-
-type AppPageType = {
- getServerSideProps: AppGetServerSideProps;
- // A component than can accept any properties
- default: ((props: unknown) => JSX.Element) &
- Pick<AppProps["Component"], "isBookingPage" | "getLayout" | "PageWrapper">;
-};
-
-type Found = {
- notFound: false;
- Component: AppPageType["default"];
- getServerSideProps: AppPageType["getServerSideProps"];
-};
-
-type NotFound = {
- notFound: true;
-};
-
-function getRoute(pages: string[]) {
- const mainPage = pages[0] as keyof typeof RoutingFormsRoutingConfig;
- const appPage =
- RoutingFormsRoutingConfig.layoutHandler || (RoutingFormsRoutingConfig[mainPage] as AppPageType);
- if (!appPage) {
- return {
- notFound: true,
- } as NotFound;
- }
- return { notFound: false, Component: appPage.default, ...appPage } as Found;
-}
-
-export type PageProps = inferSSRProps<typeof getServerSideProps>;
-
-const AppPage: AppPageType["default"] = function AppPage(props: PageProps) {
- const params = useParamsWithFallback();
- const defaultPage = ["forms"];
- const pages = Array.isArray(params.pages) ? params.pages : params.pages?.split("/") ?? defaultPage;
-
- const route = getRoute(pages);
-
- const componentProps = {
- ...props,
- pages: pages.slice(1),
- };
-
- if (!route || route.notFound) {
- throw new Error("Route can't be undefined");
- }
- return <route.Component {...componentProps} />;
-};
-
-AppPage.isBookingPage = ({ router }) => {
- const route = getRoute(router.query.pages as string[]);
- if (route.notFound) {
- return false;
- }
- const isBookingPage = route.Component.isBookingPage;
- if (typeof isBookingPage === "function") {
- return isBookingPage({ router });
- }
-
- return !!isBookingPage;
-};
-
-export const GetFormLayout: NonNullable<(typeof AppPage)["getLayout"]> = (page) => {
- const { pages: paramsPages } = useParamsWithFallback();
- const defaultPage = ["forms"];
- const pages = paramsPages?.length ? (paramsPages as string[]) : defaultPage;
- const route = getRoute(pages);
-
- if (route.notFound) {
- return null;
- }
- if (!route.Component.getLayout) {
- return page;
- }
- return route.Component.getLayout(page);
-};
-
-export default AppPage;
diff --git a/apps/web/pages/routing/index.tsx b/apps/web/pages/routing/index.tsx
deleted file mode 100644
index 22b65b6e5cd..00000000000
--- a/apps/web/pages/routing/index.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import { getServerSideProps } from "@lib/routing/getServerSideProps";
-
-import PageWrapper from "@components/PageWrapper";
-
-import type { PageProps } from "~/routing/pages-view";
-import PagesView, { GetFormLayout as getLayout } from "~/routing/pages-view";
-
-const Page = (props: PageProps) => <PagesView {...props} />;
-
-Page.PageWrapper = PageWrapper;
-Page.getLayout = getLayout;
-
-export { getServerSideProps };
-
-export default Page;
diff --git a/apps/web/public/icons/sprite.svg b/apps/web/public/icons/sprite.svg
index a9d82df2dd7..949437c333e 100644
--- a/apps/web/public/icons/sprite.svg
+++ b/apps/web/public/icons/sprite.svg
@@ -558,12 +558,6 @@
<path d="M4 17v2" ></path>
<path d="M5 18H3" ></path>
</symbol>
-<symbol class="lucide lucide-split" viewBox="0 0 24 24" fill="inherit" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" id="split">
- <path d="M16 3h5v5" ></path>
- <path d="M8 3H3v5" ></path>
- <path d="M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3" ></path>
- <path d="m15 9 6-6" ></path>
-</symbol>
<symbol class="lucide lucide-square-check" viewBox="0 0 24 24" fill="inherit" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" id="square-check">
<rect width="18" height="18" x="3" y="3" rx="2" ></rect>
<path d="m9 12 2 2 4-4" ></path>
diff --git a/packages/app-store/routing-forms/pages/layout-handler/[...appPages].tsx b/packages/app-store/routing-forms/pages/layout-handler/[...appPages].tsx
index 359f94352f4..5d1058cb288 100644
--- a/packages/app-store/routing-forms/pages/layout-handler/[...appPages].tsx
+++ b/packages/app-store/routing-forms/pages/layout-handler/[...appPages].tsx
@@ -55,10 +55,6 @@ export async function getServerSideProps(
context: GetServerSidePropsContext,
...rest: GetServerSidePropsRestArgs
) {
- //add forms to be the default page, if no pages are found
- //this is useful when rendering /routing as no params would be available
- const defaultPage = "forms";
- const page = context.params?.pages?.[0] || defaultPage;
- const component = getComponent(page);
+ const component = getComponent(context.params?.pages?.[0] || "");
return component.getServerSideProps?.(context, ...rest) || { props: {} };
}
diff --git a/packages/app-store/routing-forms/playwright/tests/basic.e2e.ts b/packages/app-store/routing-forms/playwright/tests/basic.e2e.ts
index 771c7c98b6a..ce421eee545 100644
--- a/packages/app-store/routing-forms/playwright/tests/basic.e2e.ts
+++ b/packages/app-store/routing-forms/playwright/tests/basic.e2e.ts
@@ -84,7 +84,7 @@ test.describe("Routing Forms", () => {
test("should be able to add a new form and view it", async ({ page }) => {
const formId = await addForm(page);
- await page.click('[href="/routing"]');
+ await page.click('[href*="/forms"]');
await page.waitForSelector('[data-testid="routing-forms-list"]');
// Ensure that it's visible in forms list
diff --git a/packages/features/shell/navigation/Navigation.tsx b/packages/features/shell/navigation/Navigation.tsx
index cf5a21b964c..000c9a15f18 100644
--- a/packages/features/shell/navigation/Navigation.tsx
+++ b/packages/features/shell/navigation/Navigation.tsx
@@ -87,10 +87,10 @@ const getNavigationItems = (orgBranding: OrganizationBranding): NavigationItemTy
icon: "ellipsis",
},
{
- name: "routing",
- href: "/routing",
- icon: "split",
- isCurrent: ({ pathname }) => pathname?.startsWith("/routing") ?? false,
+ name: "routing_forms",
+ href: "/apps/routing-forms/forms",
+ icon: "file-text",
+ isCurrent: ({ pathname }) => pathname?.startsWith("/apps/routing-forms/") ?? false,
moreOnMobile: true,
},
{
diff --git a/packages/ui/components/icon/icon-list.mjs b/packages/ui/components/icon/icon-list.mjs
index eef2e727cb2..c8513f1ed76 100644
--- a/packages/ui/components/icon/icon-list.mjs
+++ b/packages/ui/components/icon/icon-list.mjs
@@ -114,7 +114,6 @@ export const lucideIconList = new Set([
"sliders-vertical",
"smartphone",
"sparkles",
- "split",
"square-check",
"star",
"sun",
diff --git a/packages/ui/components/icon/icon-names.ts b/packages/ui/components/icon/icon-names.ts
index 7915b661ff5..a08e8f90414 100644
--- a/packages/ui/components/icon/icon-names.ts
+++ b/packages/ui/components/icon/icon-names.ts
@@ -115,7 +115,6 @@ export type IconName =
| "sliders-vertical"
| "smartphone"
| "sparkles"
- | "split"
| "square-check"
| "star"
| "sun"