Embed behind authentication page, Floating Button Popup and other changes (#2468)

Co-authored-by: Omar López <[email protected]>
This commit is contained in:
Hariom BalharaandOmar López authored and GitHub committed 2022-04-14 08:17:34 +05:30
1 parent ce476bf90f
commit 39935306fc
20 files changed
+559 -152

No files matched your search

+9 -3
View File
@@ -17,6 +17,7 @@ import { useRouter } from "next/router";
import React, { Fragment, ReactNode, useEffect } from "react";
import { Toaster } from "react-hot-toast";
import { useIsEmbed } from "@calcom/embed-core";
import Button from "@calcom/ui/Button";
import Dropdown, {
DropdownMenuContent,
@@ -135,6 +136,7 @@ export default function Shell(props: {
flexChildrenContainer?: boolean;
isPublic?: boolean;
}) {
const isEmbed = useIsEmbed();
const { t } = useLocale();
const router = useRouter();
const { loading, session } = useRedirectToLoginIfUnauthenticated(props.isPublic);
@@ -231,7 +233,7 @@ export default function Shell(props: {
className={classNames("flex h-screen overflow-hidden", props.large ? "bg-white" : "bg-gray-100")}
data-testid="dashboard-shell">
{status === "authenticated" && (
<div className="hidden md:flex lg:flex-shrink-0">
<div style={isEmbed ? { display: "none" } : {}} className="hidden md:flex lg:flex-shrink-0">
<div className="flex w-14 flex-col lg:w-56">
<div className="flex h-0 flex-1 flex-col border-r border-gray-200 bg-white">
<div className="flex flex-1 flex-col overflow-y-auto pt-3 pb-4 lg:pt-5">
@@ -322,7 +324,9 @@ export default function Shell(props: {
)}>
{/* show top navigation for md and smaller (tablet and phones) */}
{status === "authenticated" && (
<nav className="flex items-center justify-between border-b border-gray-200 bg-white p-4 md:hidden">
<nav
style={isEmbed ? { display: "none" } : {}}
className="flex items-center justify-between border-b border-gray-200 bg-white p-4 md:hidden">
<Link href="/event-types">
<a>
<Logo />
@@ -382,7 +386,9 @@ export default function Shell(props: {
</div>
{/* show bottom navigation for md and smaller (tablet and phones) */}
{status === "authenticated" && (
<nav className="bottom-nav fixed bottom-0 z-30 flex w-full bg-white shadow md:hidden">
<nav
style={isEmbed ? { display: "none" } : {}}
className="bottom-nav fixed bottom-0 z-30 flex w-full bg-white shadow md:hidden">
{/* note(PeerRich): using flatMap instead of map to remove settings from bottom nav */}
{navigation.flatMap((item, itemIdx) =>
item.href === "/settings/profile" ? (
@@ -16,7 +16,7 @@ import { useRouter } from "next/router";
import { useEffect, useMemo, useState } from "react";
import { FormattedNumber, IntlProvider } from "react-intl";
import { useEmbedStyles, useIsEmbed, useIsBackgroundTransparent } from "@calcom/embed-core";
import { useEmbedStyles, useIsEmbed, useIsBackgroundTransparent, sdkActionManager } from "@calcom/embed-core";
import classNames from "@calcom/lib/classNames";
import { asStringOrNull } from "@lib/asStringOrNull";
@@ -83,6 +83,10 @@ const AvailabilityPage = ({ profile, plan, eventType, workingHours, previousPage
return null;
}, [router.query.date]);
if (selectedDate) {
// Let iframe take the width available due to increase in max-width
sdkActionManager?.fire("__refreshWidth", {});
}
const [isTimeOptionsOpen, setIsTimeOptionsOpen] = useState(false);
const [timeFormat, setTimeFormat] = useState(detectBrowserTimeFormat);
@@ -91,7 +95,12 @@ const AvailabilityPage = ({ profile, plan, eventType, workingHours, previousPage
useEffect(() => {
handleToggle24hClock(localStorage.getItem("timeOption.is24hClock") === "true");
telemetry.withJitsu((jitsu) => jitsu.track(telemetryEventTypes.pageView, collectPageParameters()));
telemetry.withJitsu((jitsu) =>
jitsu.track(
telemetryEventTypes.pageView,
collectPageParameters("availability", { isTeamBooking: document.URL.includes("team/") })
)
);
}, [telemetry]);
const changeDate = (newDate: Dayjs) => {
@@ -136,7 +145,7 @@ const AvailabilityPage = ({ profile, plan, eventType, workingHours, previousPage
<main
className={
isEmbed
? ""
? classNames("m-auto", selectedDate ? "max-w-5xl" : "max-w-3xl")
: "transition-max-width mx-auto my-0 duration-500 ease-in-out md:my-24 " +
(selectedDate ? "max-w-5xl" : "max-w-3xl")
}>
@@ -222,7 +222,10 @@ const BookingPage = ({
const bookEvent = (booking: BookingFormValues) => {
telemetry.withJitsu((jitsu) =>
jitsu.track(telemetryEventTypes.bookingConfirmed, collectPageParameters())
jitsu.track(
telemetryEventTypes.bookingConfirmed,
collectPageParameters("/book", { isTeamBooking: document.URL.includes("team/") })
)
);
// "metadata" is a reserved key to allow for connecting external users without relying on the email address.
@@ -290,9 +293,10 @@ const BookingPage = ({
</Head>
<CustomBranding lightVal={profile.brandColor} darkVal={profile.darkBrandColor} />
<main
className={
isEmbed ? "mx-auto" : "mx-auto my-0 max-w-3xl rounded-sm sm:my-24 sm:border sm:dark:border-gray-600"
}>
className={classNames(
isEmbed ? "mx-auto" : "mx-auto my-0 rounded-sm sm:my-24",
"max-w-3xl sm:border sm:dark:border-gray-600"
)}>
{isReady && (
<div
className={classNames(
+3 -3
View File
@@ -1,7 +1,7 @@
import { SessionProvider } from "next-auth/react";
import { appWithTranslation } from "next-i18next";
import type { AppProps as NextAppProps } from "next/app";
import { ComponentProps, ReactNode } from "react";
import { ComponentProps, ReactNode, useMemo } from "react";
import DynamicHelpscoutProvider from "@ee/lib/helpscout/providerDynamic";
import DynamicIntercomProvider from "@ee/lib/intercom/providerDynamic";
@@ -48,9 +48,9 @@ const AppProviders = (props: AppPropsWithChildren) => {
<CustomI18nextProvider {...props}>{props.children}</CustomI18nextProvider>
</SessionProvider>
);
const telemetryClient = useMemo(createTelemetryClient, []);
return (
<TelemetryProvider value={createTelemetryClient()}>
<TelemetryProvider value={telemetryClient}>
{isPublicPage ? (
RemainingProviders
) : (
+2 -1
View File
@@ -46,7 +46,7 @@ function isLocalhost(host: string) {
* Collects page parameters and makes sure no sensitive data made it to telemetry
* @param route current next.js route
*/
export function collectPageParameters(route?: string): any {
export function collectPageParameters(route?: string, extraData: Record<string, any> = {}): any {
const host = document.location.hostname;
const maskedHost = isLocalhost(host) ? "localhost" : "masked";
//starts with ''
@@ -60,6 +60,7 @@ export function collectPageParameters(route?: string): any {
doc_search: "",
doc_path: docPath,
referer: "",
...extraData,
};
}
+8
View File
@@ -20,6 +20,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { useExposePlanGlobally } from "@lib/hooks/useExposePlanGlobally";
import useTheme from "@lib/hooks/useTheme";
import prisma from "@lib/prisma";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry";
import { inferSSRProps } from "@lib/types/inferSSRProps";
import AvatarGroup from "@components/ui/AvatarGroup";
@@ -108,6 +109,13 @@ export default function User(props: inferSSRProps<typeof getServerSideProps>) {
const nameOrUsername = user.name || user.username || "";
const [evtsToVerify, setEvtsToVerify] = useState<EvtsToVerify>({});
const isEmbed = useIsEmbed();
const telemetry = useTelemetry();
useEffect(() => {
telemetry.withJitsu((jitsu) =>
jitsu.track(telemetryEventTypes.pageView, collectPageParameters("/[user]"))
);
}, [telemetry]);
return (
<>
<Theme />
+14 -2
View File
@@ -3,7 +3,7 @@ import { UserPlan } from "@prisma/client";
import classNames from "classnames";
import { GetServerSidePropsContext } from "next";
import Link from "next/link";
import React from "react";
import React, { useEffect } from "react";
import { useIsEmbed } from "@calcom/embed-core";
import Button from "@calcom/ui/Button";
@@ -15,6 +15,7 @@ import useTheme from "@lib/hooks/useTheme";
import { useToggleQuery } from "@lib/hooks/useToggleQuery";
import { defaultAvatarSrc } from "@lib/profile";
import { getTeamWithMembers } from "@lib/queries/teams";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry";
import { inferSSRProps } from "@lib/types/inferSSRProps";
import EventTypeDescription from "@components/eventtype/EventTypeDescription";
@@ -25,13 +26,24 @@ import AvatarGroup from "@components/ui/AvatarGroup";
import Text from "@components/ui/Text";
export type TeamPageProps = inferSSRProps<typeof getServerSideProps>;
function TeamPage({ team }: TeamPageProps) {
const { isReady, Theme } = useTheme();
const showMembers = useToggleQuery("members");
const { t } = useLocale();
useExposePlanGlobally("PRO");
const isEmbed = useIsEmbed();
const telemetry = useTelemetry();
useEffect(() => {
telemetry.withJitsu((jitsu) =>
jitsu.track(
telemetryEventTypes.pageView,
collectPageParameters("/team/[slug]", {
isTeamBooking: true,
})
)
);
}, [telemetry]);
const eventTypes = (
<ul className="space-y-3">
{team.eventTypes.map((type) => (