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:
1 parent
44115ac7fa
commit
063400fcbc
54 files changed
+1898
-413
No files matched your search
@@ -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() });
|
||||
}
|
||||
}}>
|
||||
|
||||
Reference in new issue
Block a user