Scheduling infrastructure for absolutely everyone.
[CAL-203] App Store: Add <iframe> as an option in the slider (#7324)
GitStart-Cal.comc8554e68788f
diff --git a/apps/web/components/apps/App.tsx b/apps/web/components/apps/App.tsxindex 4e049d5a5f4..9abf18688df 100644--- a/apps/web/components/apps/App.tsx+++ b/apps/web/components/apps/App.tsx@@ -1,5 +1,6 @@import Link from "next/link";import { useRouter } from "next/router";+import type { IframeHTMLAttributes } from "react";import React, { useState } from "react";import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation";@@ -45,12 +46,12 @@ const Component = ({tos,privacy,isProOnly,- images,+ descriptionItems,isTemplate,dependencies,}: Parameters<typeof App>[0]) => {const { t } = useLocale();- const hasImages = images && images.length > 0;+ const hasDescriptionItems = descriptionItems && descriptionItems.length > 0;const router = useRouter();const mutation = useAddAppMutation(null, {@@ -94,17 +95,25 @@ const Component = ({return (<div className="relative flex-1 flex-col items-start justify-start px-4 md:flex md:px-8 lg:flex-row lg:px-0">- {hasImages && (+ {hasDescriptionItems && (<div className="align-center mb-4 -ml-4 -mr-4 flex min-h-[450px] w-auto basis-3/5 snap-x snap-mandatory flex-row overflow-auto whitespace-nowrap bg-gray-100 p-4 md:mb-8 md:-ml-8 md:-mr-8 md:p-8 lg:mx-0 lg:mb-0 lg:max-w-2xl lg:flex-col lg:justify-center lg:rounded-md">- {images ? (- images.map((img) => (- <img- key={img}- src={img}- alt={`Screenshot of app ${name}`}- className="mr-4 h-auto max-h-80 max-w-[90%] snap-center rounded-md object-contain last:mb-0 md:max-h-min lg:mb-4 lg:mr-0 lg:max-w-full"- />- ))+ {descriptionItems ? (+ descriptionItems.map((descriptionItem, index) =>+ typeof descriptionItem === "object" ? (+ <div+ key={`iframe-${index}`}+ className="mr-4 max-h-full min-h-[315px] min-w-[90%] max-w-full snap-center last:mb-0 lg:mb-4 lg:mr-0 [&_iframe]:h-full [&_iframe]:min-h-[315px] [&_iframe]:w-full">+ <iframe allowFullScreen {...descriptionItem.iframe} />+ </div>+ ) : (+ <img+ key={descriptionItem}+ src={descriptionItem}+ alt={`Screenshot of app ${name}`}+ className="mr-4 h-auto max-h-80 max-w-[90%] snap-center rounded-md object-contain last:mb-0 md:max-h-min lg:mb-4 lg:mr-0 lg:max-w-full"+ />+ )+ )) : (<SkeletonText />)}@@ -113,7 +122,7 @@ const Component = ({<divclassName={classNames("sticky top-0 -mt-4 max-w-xl basis-2/5 pb-12 text-sm lg:pb-0",- hasImages && "lg:ml-8"+ hasDescriptionItems && "lg:ml-8")}><div className="mb-8 flex pt-4"><header>@@ -354,7 +363,7 @@ export default function App(props: {privacy?: string;licenseRequired: AppType["licenseRequired"];isProOnly: AppType["isProOnly"];- images?: string[];+ descriptionItems?: Array<string | { iframe: IframeHTMLAttributes<HTMLIFrameElement> }>;isTemplate?: boolean;disableInstall?: boolean;dependencies?: string[];diff --git a/apps/web/pages/apps/[slug]/index.tsx b/apps/web/pages/apps/[slug]/index.tsxindex 566f0a8418d..35fc252b734 100644--- a/apps/web/pages/apps/[slug]/index.tsx+++ b/apps/web/pages/apps/[slug]/index.tsx@@ -3,6 +3,7 @@ import matter from "gray-matter";import MarkdownIt from "markdown-it";import type { GetStaticPaths, GetStaticPropsContext } from "next";import path from "path";+import { z } from "zod";import { getAppWithMetadata } from "@calcom/app-store/_appRegistry";import prisma from "@calcom/prisma";@@ -13,6 +14,23 @@ import App from "@components/apps/App";const md = new MarkdownIt("default", { html: true, breaks: true });+const sourceSchema = z.object({+ content: z.string(),+ data: z.object({+ description: z.string().optional(),+ items: z+ .array(+ z.union([+ z.string(),+ z.object({+ iframe: z.object({ src: z.string() }),+ }),+ ])+ )+ .optional(),+ }),+});+function SingleAppPage({ data, source }: inferSSRProps<typeof getStaticProps>) {return (<App@@ -33,7 +51,7 @@ function SingleAppPage({ data, source }: inferSSRProps<typeof getStaticProps>) {email={data.email}licenseRequired={data.licenseRequired}isProOnly={data.isProOnly}- images={source.data?.items as string[] | undefined}+ descriptionItems={source.data?.items as string[] | undefined}isTemplate={data.isTemplate}dependencies={data.dependencies}// tos="https://zoom.us/terms"@@ -85,10 +103,11 @@ export const getStaticProps = async (ctx: GetStaticPropsContext) => {source = singleApp.description;}- const { content, data } = matter(source);+ const result = matter(source);+ const { content, data } = sourceSchema.parse({ content: result.content, data: result.data });if (data.items) {- data.items = data.items.map((item: string) => {- if (!item.includes("/api/app-store")) {+ data.items = data.items.map((item) => {+ if (typeof item === "string" && !item.includes("/api/app-store")) {// Make relative paths absolutereturn `/api/app-store/${appDirname}/${item}`;}diff --git a/packages/app-store/typeform/DESCRIPTION.md b/packages/app-store/typeform/DESCRIPTION.mdindex 1a602623168..611805bf888 100644--- a/packages/app-store/typeform/DESCRIPTION.md+++ b/packages/app-store/typeform/DESCRIPTION.md@@ -1,6 +1,7 @@---description: Adds a link to copy Typeform Redirect URL to integrate with Routing Forms.items:+ - iframe: { src: https://www.youtube.com/embed/vcV-N2gLPZc }- /api/app-store/typeform/copy-typeform-redirect-url.png- /api/app-store/typeform/how-it-looks-in-typeform.png---