feat: conferencing atoms (#17988)

* added api/v2 for zoom connect

* Update conferencing.controller.ts

* fix: added api for ConferencingAppsViewPlatformWrapper

* type fixes

* added getBulkEventTypes api for bulk-update default location

* added bulk-update-to-default-location

* fix:bulk-update-to-default-location

* invalidated

* fixed returnTo and onErrorReturnTo

* make logos work for conferencing atoms

* smalll improvements

* fixup

* share common types

* type fix, and fixed a typo

* fix: type-error

* fix: json.parse(json.parse())

* fix: invalidate query

* fix: removing app throws error in the main app

* undo platform-libraries-1.2.3

* update platform-libraries version

---------

Co-authored-by: Morgan <[email protected]>
This commit is contained in:
Somay ChauhanandMorgan authored and GitHub committed 2024-12-06 19:03:04 +05:30
1 parent 44115ac7fa
commit 063400fcbc
54 files changed
+1898 -413

No files matched your search

+37 -18
View File
@@ -5,12 +5,16 @@ import { InstallAppButton } from "@calcom/app-store/components";
import { getLocationFromApp, type EventLocationType } from "@calcom/app-store/locations";
import type { CredentialOwner } from "@calcom/app-store/types";
import AppListCard from "@calcom/features/apps/components/AppListCard";
import type { UpdateUsersDefaultConferencingAppParams } from "@calcom/features/apps/components/AppSetDefaultLinkDialog";
import { AppSetDefaultLinkDialog } from "@calcom/features/apps/components/AppSetDefaultLinkDialog";
import type { BulkUpdatParams } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
import type {
BulkUpdatParams,
EventTypes,
} from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
import { BulkEditDefaultForEventsModal } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { AppCategories } from "@calcom/prisma/enums";
import { trpc, type RouterOutputs } from "@calcom/trpc";
import { type RouterOutputs } from "@calcom/trpc";
import type { App } from "@calcom/types/App";
import {
Alert,
@@ -24,17 +28,21 @@ import {
showToast,
} from "@calcom/ui";
export type UpdateDefaultConferencingAppParams = { appSlug: string; callback: () => void };
export type HandleDisconnect = (credentialId: number, app: App["slug"], teamId?: number) => void;
interface AppListProps {
variant?: AppCategories;
data: RouterOutputs["viewer"]["integrations"];
handleDisconnect: (credentialId: number) => void;
handleDisconnect: HandleDisconnect;
listClassName?: string;
defaultConferencingApp: RouterOutputs["viewer"]["getUsersDefaultConferencingApp"];
handleUpdateDefaultConferencingApp: (params: UpdateDefaultConferencingAppParams) => void;
handleUpdateUserDefaultConferencingApp: (params: UpdateUsersDefaultConferencingAppParams) => void;
handleBulkUpdateDefaultLocation: (params: BulkUpdatParams) => void;
isBulkUpdateDefaultLocationPending: boolean;
eventTypes?: EventTypes;
isEventTypesFetching?: boolean;
handleConnectDisconnectIntegrationMenuToggle: () => void;
handleBulkEditDialogToggle: () => void;
}
export const AppList = ({
@@ -43,15 +51,18 @@ export const AppList = ({
variant,
listClassName,
defaultConferencingApp,
handleUpdateDefaultConferencingApp,
handleUpdateUserDefaultConferencingApp,
handleBulkUpdateDefaultLocation,
isBulkUpdateDefaultLocationPending,
eventTypes,
isEventTypesFetching,
handleConnectDisconnectIntegrationMenuToggle,
handleBulkEditDialogToggle,
}: AppListProps) => {
const [bulkUpdateModal, setBulkUpdateModal] = useState(false);
const [locationType, setLocationType] = useState<(EventLocationType & { slug: string }) | undefined>(
undefined
);
const onSuccessCallback = useCallback(() => {
setBulkUpdateModal(true);
showToast("Default app updated successfully", "success");
@@ -98,9 +109,12 @@ export const AppList = ({
if (locationType?.linkType === "static") {
setLocationType({ ...locationType, slug: appSlug });
} else {
handleUpdateDefaultConferencingApp({
handleUpdateUserDefaultConferencingApp({
appSlug,
callback: () => setBulkUpdateModal(true),
onSuccessCallback: () => setBulkUpdateModal(true),
onErrorCallback: () => {
return;
},
});
}
}}>
@@ -111,11 +125,15 @@ export const AppList = ({
<ConnectOrDisconnectIntegrationMenuItem
credentialId={item.credentialOwner?.credentialId || item.userCredentialIds[0]}
type={item.type}
app={item.slug}
isGlobal={item.isGlobal}
installed
invalidCredentialIds={item.invalidCredentialIds}
handleDisconnect={handleDisconnect}
teamId={item.credentialOwner ? item.credentialOwner?.teamId : undefined}
handleConnectDisconnectIntegrationMenuToggle={
handleConnectDisconnectIntegrationMenuToggle
}
/>
</DropdownMenuContent>
</Dropdown>
@@ -171,6 +189,7 @@ export const AppList = ({
locationType={locationType}
setLocationType={() => setLocationType(undefined)}
onSuccess={onSuccessCallback}
handleUpdateUserDefaultConferencingApp={handleUpdateUserDefaultConferencingApp}
/>
)}
@@ -181,6 +200,9 @@ export const AppList = ({
setOpen={setBulkUpdateModal}
isPending={isBulkUpdateDefaultLocationPending}
description={t("default_conferencing_bulk_description")}
eventTypes={eventTypes}
isEventTypesFetching={isEventTypesFetching}
handleBulkEditDialogToggle={handleBulkEditDialogToggle}
/>
)}
</>
@@ -194,22 +216,19 @@ function ConnectOrDisconnectIntegrationMenuItem(props: {
installed?: boolean;
invalidCredentialIds?: number[];
teamId?: number;
handleDisconnect: (credentialId: number, teamId?: number) => void;
app: App["slug"];
handleDisconnect: HandleDisconnect;
handleConnectDisconnectIntegrationMenuToggle: () => void;
}) {
const { type, credentialId, isGlobal, installed, handleDisconnect, teamId } = props;
const { type, credentialId, isGlobal, installed, handleDisconnect, teamId, app } = props;
const { t } = useLocale();
const utils = trpc.useUtils();
const handleOpenChange = () => {
utils.viewer.integrations.invalidate();
};
if (credentialId || type === "stripe_payment" || isGlobal) {
return (
<DropdownMenuItem>
<DropdownItem
color="destructive"
onClick={() => handleDisconnect(credentialId, teamId)}
onClick={() => handleDisconnect(credentialId, app, teamId)}
disabled={isGlobal}
StartIcon="trash">
{t("remove_app")}
@@ -234,7 +253,7 @@ function ConnectOrDisconnectIntegrationMenuItem(props: {
{t("install")}
</Button>
)}
onChanged={handleOpenChange}
onChanged={props.handleConnectDisconnectIntegrationMenuToggle}
/>
);
}
@@ -37,7 +37,8 @@ export type AppListCardProps = {
const schema = z.object({ hl: z.string().optional() });
function AppListCardPlatformWrapper(props: AppListCardProps) {
return <AppListCardComponent {...props} />;
const logo = `https://app.cal.com${props.logo}`;
return <AppListCardComponent {...props} logo={logo} />;
}
function AppListCardWebWrapper(props: AppListCardProps) {
const { slug, shouldHighlight } = props;
@@ -6,7 +6,6 @@ import { z } from "zod";
import type { EventLocationType } from "@calcom/app-store/locations";
import { getEventLocationType } from "@calcom/app-store/locations";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import {
Button,
Dialog,
@@ -18,6 +17,13 @@ import {
TextField,
} from "@calcom/ui";
export type UpdateUsersDefaultConferencingAppParams = {
appSlug: string;
appLink?: string;
onSuccessCallback: () => void;
onErrorCallback: () => void;
};
type LocationTypeSetLinkDialogFormProps = {
link?: string;
type: EventLocationType["type"];
@@ -27,10 +33,12 @@ export function AppSetDefaultLinkDialog({
locationType,
setLocationType,
onSuccess,
handleUpdateUserDefaultConferencingApp,
}: {
locationType: EventLocationType & { slug: string };
setLocationType: Dispatch<SetStateAction<(EventLocationType & { slug: string }) | undefined>>;
onSuccess: () => void;
handleUpdateUserDefaultConferencingApp: (params: UpdateUsersDefaultConferencingAppParams) => void;
}) {
const { t } = useLocale();
const eventLocationTypeOptions = getEventLocationType(locationType.type);
@@ -41,15 +49,6 @@ export function AppSetDefaultLinkDialog({
),
});
const updateDefaultAppMutation = trpc.viewer.updateUserDefaultConferencingApp.useMutation({
onSuccess: () => {
onSuccess();
},
onError: () => {
showToast(`Invalid App Link Format`, "error");
},
});
return (
<Dialog open={!!locationType} onOpenChange={() => setLocationType(undefined)}>
<DialogContent
@@ -60,9 +59,15 @@ export function AppSetDefaultLinkDialog({
<Form
form={form}
handleSubmit={(values) => {
updateDefaultAppMutation.mutate({
handleUpdateUserDefaultConferencingApp({
appSlug: locationType.slug,
appLink: values.link,
onSuccessCallback: () => {
onSuccess();
},
onErrorCallback: () => {
showToast(`Invalid App Link Format`, "error");
},
});
setLocationType(undefined);
}}>
@@ -1,23 +1,33 @@
import { useIsPlatform } from "@calcom/atoms/monorepo";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { App } from "@calcom/types/App";
import { Dialog, ConfirmationDialogContent } from "@calcom/ui";
export type RemoveAppParams = { credentialId: number; teamId?: number; callback: () => void };
export type RemoveAppParams = {
credentialId: number;
app?: App["slug"];
teamId?: number;
callback: () => void;
};
interface DisconnectIntegrationModalProps {
credentialId: number | null;
isOpen: boolean;
handleModelClose: () => void;
teamId?: number;
handleRemoveApp: (params: RemoveAppParams) => void;
app?: App["slug"] | null;
}
export default function DisconnectIntegrationModal({
credentialId,
app,
isOpen,
handleModelClose,
teamId,
handleRemoveApp,
}: DisconnectIntegrationModalProps) {
const { t } = useLocale();
const isPlatform = useIsPlatform();
return (
<Dialog open={isOpen} onOpenChange={handleModelClose}>
<ConfirmationDialogContent
@@ -25,7 +35,9 @@ export default function DisconnectIntegrationModal({
title={t("remove_app")}
confirmBtnText={t("yes_remove_app")}
onConfirm={() => {
if (credentialId) {
if (isPlatform && app && credentialId) {
handleRemoveApp({ credentialId, app, teamId, callback: () => handleModelClose() });
} else if (credentialId) {
handleRemoveApp({ credentialId, teamId, callback: () => handleModelClose() });
}
}}>
@@ -39,7 +39,7 @@ const handleDeleteCredential = async ({
teamId,
}: {
userId: number;
userMetadata: Prisma.JsonValue;
userMetadata?: Prisma.JsonValue;
credentialId: number;
teamId?: number;
}) => {
@@ -1,5 +1,5 @@
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
import { Meta, SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui";
import { SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui";
export const AppearanceSkeletonLoader = () => {
return (
@@ -17,7 +17,6 @@ import {
DropdownMenuItem,
Icon,
showToast,
useMeta,
} from "@calcom/ui";
import { DeleteAttributeModal } from "./DeleteAttributeModal";
@@ -14,7 +14,7 @@ import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
import { MembershipRole } from "@calcom/prisma/enums";
import { trpc } from "@calcom/trpc/react";
import type { RouterOutputs } from "@calcom/trpc/react";
import { Button, Form, Meta, showToast, SettingsToggle } from "@calcom/ui";
import { Button, Form, showToast, SettingsToggle } from "@calcom/ui";
import ThemeLabel from "../../../settings/ThemeLabel";
@@ -1,7 +1,6 @@
"use client";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Meta } from "@calcom/ui";
import { TeamsListing } from "../components";
@@ -8,7 +8,6 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
import { MembershipRole } from "@calcom/prisma/enums";
import { trpc } from "@calcom/trpc/react";
import { Meta } from "@calcom/ui";
import DisableTeamImpersonation from "../components/DisableTeamImpersonation";
import InviteLinkSettingsModal from "../components/InviteLinkSettingsModal";
@@ -35,7 +35,6 @@ import {
ImageUploader,
Label,
LinkIconButton,
Meta,
showToast,
SkeletonAvatar,
SkeletonButton,
@@ -3,7 +3,6 @@ import { useForm } from "react-hook-form";
import { z } from "zod";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { Dialog, DialogContent, Form, DialogFooter, DialogClose, Button, CheckboxField } from "@calcom/ui";
export const BulkUpdateEventSchema = z.object({
@@ -11,28 +10,35 @@ export const BulkUpdateEventSchema = z.object({
});
export type BulkUpdatParams = { eventTypeIds: number[]; callback: () => void };
export type EventTypes = Array<{ id: number; title: string }>;
export function BulkEditDefaultForEventsModal(props: {
export function BulkEditDefaultForEventsModal({
eventTypes,
isEventTypesFetching,
...props
}: {
open: boolean;
setOpen: (open: boolean) => void;
bulkUpdateFunction: (params: BulkUpdatParams) => void;
isPending: boolean;
description: string;
isEventTypesFetching?: boolean;
eventTypes?: EventTypes;
handleBulkEditDialogToggle: () => void;
}) {
const { t } = useLocale();
const utils = trpc.useUtils();
const { data, isFetching } = trpc.viewer.eventTypes.bulkEventFetch.useQuery();
const form = useForm({
resolver: zodResolver(BulkUpdateEventSchema),
defaultValues: {
eventTypeIds: data?.eventTypes.map((e) => e.id) ?? [],
eventTypeIds: eventTypes?.map((e) => e.id) ?? [],
},
});
const eventTypesSelected = form.watch("eventTypeIds");
const isButtonDisabled = eventTypesSelected.length === 0;
if (isFetching || !open || !data?.eventTypes) return null;
if (isEventTypesFetching || !open || !eventTypes) return null;
return (
<Dialog name="Bulk Default Location Update" open={props.open} onOpenChange={props.setOpen}>
@@ -50,19 +56,19 @@ export function BulkEditDefaultForEventsModal(props: {
});
}}>
<div className="flex flex-col space-y-2">
{data.eventTypes.length > 0 && (
{eventTypes.length > 0 && (
<div className="flex items-center space-x-2 rounded-md px-3 pb-2.5 pt-1">
<CheckboxField
description={t("select_all")}
descriptionAsLabel
onChange={(e) => {
form.setValue("eventTypeIds", e.target.checked ? data.eventTypes.map((e) => e.id) : []);
form.setValue("eventTypeIds", e.target.checked ? eventTypes.map((e) => e.id) : []);
}}
checked={eventTypesSelected.length === data.eventTypes.length}
checked={eventTypesSelected.length === eventTypes.length}
/>
</div>
)}
{data.eventTypes.map((eventType) => (
{eventTypes.map((eventType) => (
<div key={eventType.id} className="bg-muted flex items-center space-x-2 rounded-md px-3 py-2.5">
<CheckboxField
description={eventType.title}
@@ -83,7 +89,7 @@ export function BulkEditDefaultForEventsModal(props: {
<DialogFooter showDivider className="mt-10">
<DialogClose
onClick={() => {
utils.viewer.getUsersDefaultConferencingApp.invalidate();
props.handleBulkEditDialogToggle();
}}
/>
<Button type="submit" color="primary" loading={props.isPending} disabled={isButtonDisabled}>