fix: set conferencing apps as default (#15376)
* fix: set conferencing apps as default * fix in other oauth conferencing apps * creating default event-types should set the user's default location * Update getDefaultLocations.ts * fix: unit test * default install only for first oauth app * fix: type-check * update default on success * fix: pass callback prop * chore: code cleanup * Fix condition * no longer needed - as we reverted https://github.com/calcom/cal.com/commit/20fdb50081ae684723a5af78436068c0b09509a4 --------- Co-authored-by: Somay Chauhan <[email protected]> Co-authored-by: Hariom <[email protected]>
This commit is contained in:
7 files changed
+73
-5
No files matched your search
@@ -19,7 +19,7 @@ type CustomUseMutationOptions =
|
||||
| undefined;
|
||||
|
||||
type AddAppMutationData = { setupPending: boolean } | void;
|
||||
type UseAddAppMutationOptions = CustomUseMutationOptions & {
|
||||
export type UseAddAppMutationOptions = CustomUseMutationOptions & {
|
||||
onSuccess?: (data: AddAppMutationData) => void;
|
||||
installGoogleVideo?: boolean;
|
||||
returnTo?: string;
|
||||
|
||||
@@ -2,6 +2,7 @@ import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
import type { UseAddAppMutationOptions } from "@calcom/app-store/_utils/useAddAppMutation";
|
||||
import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation";
|
||||
import classNames from "@calcom/lib/classNames";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
@@ -19,9 +20,10 @@ import type { InstallAppButtonProps } from "./types";
|
||||
export const InstallAppButtonWithoutPlanCheck = (
|
||||
props: {
|
||||
type: App["type"];
|
||||
options?: UseAddAppMutationOptions;
|
||||
} & InstallAppButtonProps
|
||||
) => {
|
||||
const mutation = useAddAppMutation(null);
|
||||
const mutation = useAddAppMutation(null, props.options);
|
||||
const key = deriveAppDictKeyFromType(props.type, InstallAppButtonMap);
|
||||
const InstallAppButtonComponent = InstallAppButtonMap[key as keyof typeof InstallAppButtonMap];
|
||||
if (!InstallAppButtonComponent)
|
||||
|
||||
@@ -4,6 +4,7 @@ import { checkGlobalKeysSchema } from "./checkGlobalKeys.schema";
|
||||
import { ZListLocalInputSchema } from "./listLocal.schema";
|
||||
import { ZQueryForDependenciesInputSchema } from "./queryForDependencies.schema";
|
||||
import { ZSaveKeysInputSchema } from "./saveKeys.schema";
|
||||
import { ZSetDefaultConferencingAppSchema } from "./setDefaultConferencingApp.schema";
|
||||
import { ZToggleInputSchema } from "./toggle.schema";
|
||||
import { ZUpdateAppCredentialsInputSchema } from "./updateAppCredentials.schema";
|
||||
|
||||
@@ -15,6 +16,7 @@ type AppsRouterHandlerCache = {
|
||||
updateAppCredentials?: typeof import("./updateAppCredentials.handler").updateAppCredentialsHandler;
|
||||
queryForDependencies?: typeof import("./queryForDependencies.handler").queryForDependenciesHandler;
|
||||
checkGlobalKeys?: typeof import("./checkGlobalKeys.handler").checkForGlobalKeysHandler;
|
||||
setDefaultConferencingApp?: typeof import("./setDefaultConferencingApp.handler").setDefaultConferencingAppHandler;
|
||||
};
|
||||
|
||||
const UNSTABLE_HANDLER_CACHE: AppsRouterHandlerCache = {};
|
||||
@@ -87,6 +89,25 @@ export const appsRouter = router({
|
||||
});
|
||||
}),
|
||||
|
||||
setDefaultConferencingApp: authedProcedure
|
||||
.input(ZSetDefaultConferencingAppSchema)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.setDefaultConferencingApp) {
|
||||
UNSTABLE_HANDLER_CACHE.setDefaultConferencingApp = await import(
|
||||
"./setDefaultConferencingApp.handler"
|
||||
).then((mod) => mod.setDefaultConferencingAppHandler);
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.setDefaultConferencingApp) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.setDefaultConferencingApp({
|
||||
ctx,
|
||||
input,
|
||||
});
|
||||
}),
|
||||
updateAppCredentials: authedProcedure
|
||||
.input(ZUpdateAppCredentialsInputSchema)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import setDefaultConferencingApp from "@calcom/app-store/_utils/setDefaultConferencingApp";
|
||||
|
||||
import type { TrpcSessionUser } from "../../../trpc";
|
||||
import type { TSetDefaultConferencingAppSchema } from "./setDefaultConferencingApp.schema";
|
||||
|
||||
type SetDefaultConferencingAppOptions = {
|
||||
ctx: {
|
||||
user: NonNullable<TrpcSessionUser>;
|
||||
};
|
||||
input: TSetDefaultConferencingAppSchema;
|
||||
};
|
||||
|
||||
export const setDefaultConferencingAppHandler = async ({ ctx, input }: SetDefaultConferencingAppOptions) => {
|
||||
return await setDefaultConferencingApp(ctx.user.id, input.slug);
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const ZSetDefaultConferencingAppSchema = z.object({
|
||||
slug: z.string(),
|
||||
});
|
||||
|
||||
export type TSetDefaultConferencingAppSchema = z.infer<typeof ZSetDefaultConferencingAppSchema>;
|
||||
Reference in new issue
Block a user