perf: workflows—remove data fetching for metadata (#20734)

This commit is contained in:
Benny Joo authored and GitHub committed 2025-04-26 12:21:11 +00:00
1 parent 31cbea0e23
commit 57df25505d
6 files changed
+16 -43

No files matched your search

@@ -9,14 +9,11 @@ import { buildLegacyCtx } from "@lib/buildLegacyCtx";
import type { OnboardingPageProps } from "~/apps/installation/[[...step]]/step-view";
import Page from "~/apps/installation/[[...step]]/step-view";
export const generateMetadata = async ({ params, searchParams }: PageProps) => {
const legacyCtx = buildLegacyCtx(await headers(), await cookies(), await params, await searchParams);
const { appMetadata } = await getData(legacyCtx);
export const generateMetadata = async ({ params }: PageProps) => {
const stepParam = (await params).step;
const step = stepParam && Array.isArray(stepParam) ? stepParam.join("/") : "";
return await _generateMetadata(
(t) => `${t("install")} ${appMetadata?.name ?? ""}`,
(t) => t("app_installation"),
() => "",
undefined,
undefined,
@@ -23,7 +23,6 @@ const normalizePages = (pages: string[] | string | undefined) => {
export const generateMetadata = async ({ params }: { params: Promise<{ pages: string[] }> }) => {
const { mainPage } = normalizePages((await params).pages);
return await _generateMetadata(
// TODO: Need to show the actual form name instead of "Form"
(t) => (mainPage === "routing-link" ? `Form | Cal.com Forms` : `${t("routing_forms")} | Cal.com Forms`),
() => "",
undefined,
@@ -1,15 +1,11 @@
import type { PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { cache } from "react";
import { z } from "zod";
// import { cookies, headers } from "next/headers";
// import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
// import { buildLegacyRequest } from "@lib/buildLegacyCtx";
import LegacyPage from "@calcom/features/ee/workflows/pages/workflow";
import { WorkflowRepository } from "@calcom/lib/server/repository/workflow";
const querySchema = z.object({
workflow: z
@@ -20,26 +16,6 @@ const querySchema = z.object({
.transform((val) => Number(val)),
});
const getWorkflow = cache((id: number) => WorkflowRepository.getById({ id }));
export const generateMetadata = async ({ params }: PageProps): Promise<Metadata | null> => {
const parsed = querySchema.safeParse(await params);
if (!parsed.success) {
notFound();
}
const workflow = await getWorkflow(parsed.data.workflow);
if (!workflow) {
notFound();
}
return await _generateMetadata(
(t) => (workflow && workflow.name ? workflow.name : t("untitled")),
() => "",
undefined,
undefined,
`/workflows/${parsed.data.workflow}`
);
};
const Page = async ({ params }: PageProps) => {
// const session = await getServerSession({ req: buildLegacyRequest(await headers(), await cookies()) });
// const user = session?.user;
@@ -0,0 +1,12 @@
import { _generateMetadata } from "app/_utils";
import type { ReactNode } from "react";
export const generateMetadata = async () =>
await _generateMetadata(
(t) => t("workflows"),
(t) => t("workflows_to_automate_notifications")
);
export default function Layout({ children }: { children: ReactNode }) {
return <>{children}</>;
}
@@ -1,6 +1,3 @@
import type { PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
// import { cookies, headers } from "next/headers";
// import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
// import { buildLegacyRequest } from "@lib/buildLegacyCtx";
@@ -8,16 +5,7 @@ import { _generateMetadata } from "app/_utils";
// import { WorkflowRepository } from "@calcom/lib/server/repository/workflow";
import LegacyPage from "@calcom/features/ee/workflows/pages/index";
export const generateMetadata = async () =>
await _generateMetadata(
(t) => t("workflows"),
(t) => t("workflows_to_automate_notifications"),
undefined,
undefined,
"/workflows"
);
const Page = async ({ params, searchParams }: PageProps) => {
const Page = async () => {
// const session = await getServerSession({ req: buildLegacyRequest(await headers(), await cookies()) });
// const user = session?.user;
@@ -1241,6 +1241,7 @@
"make_setup_instructions_6": "You're set!",
"install_zapier_app": "Please first install the Zapier App in the app store.",
"install_make_app": "Please first install the Make App in the app store.",
"app_installation": "App Installation",
"app_not_installed": "App not installed",
"visit_our_app_store": "Sorry, this app isn't installed on your account. Please visit our app store to explore and discover this and other great apps.",
"connect_apple_server": "Connect to Apple Server",