From 49dce6f4350fb0ae72a357287b0334befd6bd3ff Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Tue, 24 Sep 2024 11:50:58 -0400 Subject: [PATCH] remove pages router and use app router --- .env.example | 1 - apps/web/abTest/middlewareFactory.ts | 1 - apps/web/app/settings/platform/new/page.tsx | 21 ++++++ .../oauth-clients/[clientId]/edit/page.tsx | 15 +++++ .../[clientId]/edit/webhooks/page.tsx | 15 +++++ .../platform/oauth-clients/create/page.tsx | 19 ++++++ apps/web/app/settings/platform/page.tsx | 16 +++++ .../pages/settings/platform/billing/index.tsx | 12 ---- apps/web/pages/settings/platform/index.tsx | 12 ---- .../web/pages/settings/platform/new/index.tsx | 64 ------------------- .../oauth-clients/[clientId]/edit/index.tsx | 12 ---- .../[clientId]/edit/webhooks.tsx | 12 ---- .../platform/oauth-clients/create.tsx | 12 ---- .../pages/settings/platform/plans/index.tsx | 12 ---- apps/web/scripts/vercel-app-router-deploy.sh | 1 - turbo.json | 1 - 16 files changed, 86 insertions(+), 140 deletions(-) create mode 100644 apps/web/app/settings/platform/new/page.tsx create mode 100644 apps/web/app/settings/platform/oauth-clients/[clientId]/edit/page.tsx create mode 100644 apps/web/app/settings/platform/oauth-clients/[clientId]/edit/webhooks/page.tsx create mode 100644 apps/web/app/settings/platform/oauth-clients/create/page.tsx create mode 100644 apps/web/app/settings/platform/page.tsx delete mode 100644 apps/web/pages/settings/platform/billing/index.tsx delete mode 100644 apps/web/pages/settings/platform/index.tsx delete mode 100644 apps/web/pages/settings/platform/new/index.tsx delete mode 100644 apps/web/pages/settings/platform/oauth-clients/[clientId]/edit/index.tsx delete mode 100644 apps/web/pages/settings/platform/oauth-clients/[clientId]/edit/webhooks.tsx delete mode 100644 apps/web/pages/settings/platform/oauth-clients/create.tsx delete mode 100644 apps/web/pages/settings/platform/plans/index.tsx diff --git a/.env.example b/.env.example index ff2e2c1875f4a0..2349888f7b74c6 100644 --- a/.env.example +++ b/.env.example @@ -334,7 +334,6 @@ AB_TEST_BUCKET_PROBABILITY=50 # whether we redirect to the future/event-types from event-types or not APP_ROUTER_EVENT_TYPES_ENABLED=0 APP_ROUTER_SETTINGS_ADMIN_ENABLED=0 -APP_ROUTER_SETTINGS_PLATFORM_ENABLED=0 APP_ROUTER_SETTINGS_ORG_ENABLED=0 APP_ROUTER_APPS_INSTALLED_CATEGORY_ENABLED=0 APP_ROUTER_APPS_SLUG_ENABLED=0 diff --git a/apps/web/abTest/middlewareFactory.ts b/apps/web/abTest/middlewareFactory.ts index c04f08fd15297e..75ae5deccc5eae 100644 --- a/apps/web/abTest/middlewareFactory.ts +++ b/apps/web/abTest/middlewareFactory.ts @@ -8,7 +8,6 @@ import { FUTURE_ROUTES_ENABLED_COOKIE_NAME, FUTURE_ROUTES_OVERRIDE_COOKIE_NAME } const ROUTES: [URLPattern, boolean][] = [ ["/event-types", process.env.APP_ROUTER_EVENT_TYPES_ENABLED === "1"] as const, ["/settings/admin/:path*", process.env.APP_ROUTER_SETTINGS_ADMIN_ENABLED === "1"] as const, - ["/settings/platform/:path*", process.env.APP_ROUTER_SETTINGS_PLATFORM_ENABLED === "1"] as const, ["/settings/organizations/:path*", process.env.APP_ROUTER_SETTINGS_ORG_ENABLED === "1"] as const, ["/apps/installed/:category", process.env.APP_ROUTER_APPS_INSTALLED_CATEGORY_ENABLED === "1"] as const, ["/apps/:slug", process.env.APP_ROUTER_APPS_SLUG_ENABLED === "1"] as const, diff --git a/apps/web/app/settings/platform/new/page.tsx b/apps/web/app/settings/platform/new/page.tsx new file mode 100644 index 00000000000000..033ef74380771f --- /dev/null +++ b/apps/web/app/settings/platform/new/page.tsx @@ -0,0 +1,21 @@ +import { withAppDirSsr } from "app/WithAppDirSsr"; +import { _generateMetadata } from "app/_utils"; +import { WithLayout } from "app/layoutHOC"; + +import { getServerSideProps } from "@lib/settings/organizations/new/getServerSideProps"; +import { type inferSSRProps } from "@lib/types/inferSSRProps"; + +import LegacyPage, { LayoutWrapper } from "~/settings/platform/new/create-new-view"; + +export const generateMetadata = async () => + await _generateMetadata( + (t) => t("set_up_your_platform_organization"), + (t) => t("platform_organization_description") + ); + +export default WithLayout({ + getLayout: LayoutWrapper, + Page: LegacyPage, + getData: withAppDirSsr>(getServerSideProps), + requiresLicense: true, +}); diff --git a/apps/web/app/settings/platform/oauth-clients/[clientId]/edit/page.tsx b/apps/web/app/settings/platform/oauth-clients/[clientId]/edit/page.tsx new file mode 100644 index 00000000000000..754e9a20fcc069 --- /dev/null +++ b/apps/web/app/settings/platform/oauth-clients/[clientId]/edit/page.tsx @@ -0,0 +1,15 @@ +import { _generateMetadata } from "app/_utils"; +import { WithLayout } from "app/layoutHOC"; + +import EditView from "~/settings/platform/oauth-clients/[clientId]/edit/edit-view"; + +export const generateMetadata = async () => + await _generateMetadata( + () => "OAuth client updation form", + () => "" + ); + +export default WithLayout({ + getLayout: null, + Page: EditView, +}); diff --git a/apps/web/app/settings/platform/oauth-clients/[clientId]/edit/webhooks/page.tsx b/apps/web/app/settings/platform/oauth-clients/[clientId]/edit/webhooks/page.tsx new file mode 100644 index 00000000000000..7eef008b4ee714 --- /dev/null +++ b/apps/web/app/settings/platform/oauth-clients/[clientId]/edit/webhooks/page.tsx @@ -0,0 +1,15 @@ +import { _generateMetadata } from "app/_utils"; +import { WithLayout } from "app/layoutHOC"; + +import EditWebhooksView from "~/settings/platform/oauth-clients/[clientId]/edit/edit-webhooks-view"; + +export const generateMetadata = async () => + await _generateMetadata( + () => "OAuth client updation form", + () => "" + ); + +export default WithLayout({ + getLayout: null, + Page: EditWebhooksView, +}); diff --git a/apps/web/app/settings/platform/oauth-clients/create/page.tsx b/apps/web/app/settings/platform/oauth-clients/create/page.tsx new file mode 100644 index 00000000000000..5303d7dc4a47e3 --- /dev/null +++ b/apps/web/app/settings/platform/oauth-clients/create/page.tsx @@ -0,0 +1,19 @@ +import type { PageProps } from "app/_types"; +import { _generateMetadata } from "app/_utils"; +import { WithLayout } from "app/layoutHOC"; + +import CreateNewView from "~/settings/platform/oauth-clients/create-new-view"; + +export const generateMetadata = async ({ params, searchParams }: PageProps) => { + const p = { ...params, ...searchParams }; + const clientId = p?.clientId ?? ""; + return await _generateMetadata( + () => `OAuth client ${!!clientId ? "updation" : "creation"} form`, + () => "" + ); +}; + +export default WithLayout({ + getLayout: null, + Page: CreateNewView, +}); diff --git a/apps/web/app/settings/platform/page.tsx b/apps/web/app/settings/platform/page.tsx new file mode 100644 index 00000000000000..e6105fcc58a325 --- /dev/null +++ b/apps/web/app/settings/platform/page.tsx @@ -0,0 +1,16 @@ +import { _generateMetadata } from "app/_utils"; +import { WithLayout } from "app/layoutHOC"; + +import PlatformView from "~/settings/platform/platform-view"; + +export const generateMetadata = async () => { + return await _generateMetadata( + () => "Platform", + () => "Manage everything related to platform." + ); +}; + +export default WithLayout({ + getLayout: null, + Page: PlatformView, +}); diff --git a/apps/web/pages/settings/platform/billing/index.tsx b/apps/web/pages/settings/platform/billing/index.tsx deleted file mode 100644 index 4bdf02297b9bcf..00000000000000 --- a/apps/web/pages/settings/platform/billing/index.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import PageWrapper from "@components/PageWrapper"; - -import PlatformBillingUpgrade from "~/settings/platform/billing/billing-view"; - -const Page = new Proxy<{ - (): JSX.Element; - PageWrapper?: typeof PageWrapper; -}>(PlatformBillingUpgrade, {}); - -Page.PageWrapper = PageWrapper; - -export default Page; diff --git a/apps/web/pages/settings/platform/index.tsx b/apps/web/pages/settings/platform/index.tsx deleted file mode 100644 index 3d029175264b3d..00000000000000 --- a/apps/web/pages/settings/platform/index.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import PageWrapper from "@components/PageWrapper"; - -import PlatformView from "~/settings/platform/platform-view"; - -const Page = new Proxy<{ - (): JSX.Element; - PageWrapper?: typeof PageWrapper; -}>(PlatformView, {}); - -Page.PageWrapper = PageWrapper; - -export default Page; diff --git a/apps/web/pages/settings/platform/new/index.tsx b/apps/web/pages/settings/platform/new/index.tsx deleted file mode 100644 index dfffff7d29f491..00000000000000 --- a/apps/web/pages/settings/platform/new/index.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { useRouter } from "next/navigation"; - -import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired"; -import { useLocale } from "@calcom/lib/hooks/useLocale"; -import { Meta } from "@calcom/ui"; -import { SkeletonContainer, SkeletonText } from "@calcom/ui"; - -import { getServerSideProps } from "@lib/settings/organizations/new/getServerSideProps"; - -import PageWrapper from "@components/PageWrapper"; -import usePlatformMe from "@components/settings/platform/hooks/usePlatformMe"; - -import CreateNewOrganizationPage, { LayoutWrapper } from "~/settings/platform/new/create-new-view"; - -const SkeletonLoader = () => { - return ( - -
- - - -
-
- ); -}; - -const Page = () => { - const { t } = useLocale(); - const { isFetching, data: platformMe } = usePlatformMe(); - const router = useRouter(); - - if (isFetching) { - return ; - } - - if (platformMe?.organization?.id) { - // if user has a platform org redirect to platform dashboard - if (platformMe?.organization?.isPlatform) { - router.push("/settings/platform"); - // user has a regular org redirect to organization settings - } else { - router.push("/settings/organizations/profile"); - } - // display loader while redirection is happening - return ; - } - - return ( - - - - - ); -}; - -Page.getLayout = LayoutWrapper; -Page.PageWrapper = PageWrapper; - -export default Page; - -export { getServerSideProps }; diff --git a/apps/web/pages/settings/platform/oauth-clients/[clientId]/edit/index.tsx b/apps/web/pages/settings/platform/oauth-clients/[clientId]/edit/index.tsx deleted file mode 100644 index 5588eacbc36f2f..00000000000000 --- a/apps/web/pages/settings/platform/oauth-clients/[clientId]/edit/index.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import PageWrapper from "@components/PageWrapper"; - -import EditView from "~/settings/platform/oauth-clients/[clientId]/edit/edit-view"; - -const Page = new Proxy<{ - (): JSX.Element; - PageWrapper?: typeof PageWrapper; -}>(EditView, {}); - -Page.PageWrapper = PageWrapper; - -export default Page; diff --git a/apps/web/pages/settings/platform/oauth-clients/[clientId]/edit/webhooks.tsx b/apps/web/pages/settings/platform/oauth-clients/[clientId]/edit/webhooks.tsx deleted file mode 100644 index 818de3ef2c4c67..00000000000000 --- a/apps/web/pages/settings/platform/oauth-clients/[clientId]/edit/webhooks.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import PageWrapper from "@components/PageWrapper"; - -import EditWebhooksView from "~/settings/platform/oauth-clients/[clientId]/edit/edit-webhooks-view"; - -const Page = new Proxy<{ - (): JSX.Element; - PageWrapper?: typeof PageWrapper; -}>(EditWebhooksView, {}); - -Page.PageWrapper = PageWrapper; - -export default Page; diff --git a/apps/web/pages/settings/platform/oauth-clients/create.tsx b/apps/web/pages/settings/platform/oauth-clients/create.tsx deleted file mode 100644 index 593eef06ffd939..00000000000000 --- a/apps/web/pages/settings/platform/oauth-clients/create.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import PageWrapper from "@components/PageWrapper"; - -import CreateOAuthClientView from "~/settings/platform/oauth-clients/create-new-view"; - -const Page = new Proxy<{ - (): JSX.Element; - PageWrapper?: typeof PageWrapper; -}>(CreateOAuthClientView, {}); - -Page.PageWrapper = PageWrapper; - -export default Page; diff --git a/apps/web/pages/settings/platform/plans/index.tsx b/apps/web/pages/settings/platform/plans/index.tsx deleted file mode 100644 index 8aa52be3e527ef..00000000000000 --- a/apps/web/pages/settings/platform/plans/index.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import PageWrapper from "@components/PageWrapper"; - -import PlatformPlansView from "~/settings/platform/plans/platform-plans-view"; - -const Page = new Proxy<{ - (): JSX.Element; - PageWrapper?: typeof PageWrapper; -}>(PlatformPlansView, {}); - -Page.PageWrapper = PageWrapper; - -export default Page; diff --git a/apps/web/scripts/vercel-app-router-deploy.sh b/apps/web/scripts/vercel-app-router-deploy.sh index 1d44f26cdc5204..182ea9ee0e634f 100755 --- a/apps/web/scripts/vercel-app-router-deploy.sh +++ b/apps/web/scripts/vercel-app-router-deploy.sh @@ -9,7 +9,6 @@ checkRoute () { checkRoute "$APP_ROUTER_EVENT_TYPES_ENABLED" app/future/event-types checkRoute "$APP_ROUTER_AVAILABILITY_ENABLED" app/future/availability checkRoute "$APP_ROUTER_SETTINGS_ADMIN_ENABLED" app/future/settings/admin -checkRoute "$APP_ROUTER_SETTINGS_PLATFORM_ENABLED" app/future/settings/platform checkRoute "$APP_ROUTER_SETTINGS_ORG_ENABLED" app/future/settings/organizations checkRoute "$APP_ROUTER_APPS_INSTALLED_CATEGORY_ENABLED" app/future/apps/installed checkRoute "$APP_ROUTER_APPS_SLUG_ENABLED" app/future/apps/\[slug\] diff --git a/turbo.json b/turbo.json index 3091f2940adf29..f378b2a15c6b1d 100644 --- a/turbo.json +++ b/turbo.json @@ -237,7 +237,6 @@ "APP_ROUTER_EVENT_TYPES_ENABLED", "APP_ROUTER_GETTING_STARTED_STEP_ENABLED", "APP_ROUTER_SETTINGS_ADMIN_ENABLED", - "APP_ROUTER_SETTINGS_PLATFORM_ENABLED", "APP_ROUTER_SETTINGS_ORG_ENABLED", "APP_ROUTER_SETTINGS_TEAMS_ENABLED", "APP_ROUTER_WORKFLOWS_ENABLED",