Remove global app installed button (#2561)
* Remove global app installed button * Add Jitsi add button * Find app credentials based on variant * Make huddle installable * Remove default installed message from installed apps page * Display Jitsi and Huddle as locations if installed * Reverse global app changes and made Jitsi and Huddle non global * Changes to app page refrence #2556 * Fix type errors * Revert code Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
parent
18d41b52a2
commit
97e4cca252
13 changed files with 130 additions and 2 deletions
|
@ -21,6 +21,8 @@ export const InstallAppButtonMap = {
|
||||||
zoomvideo: dynamic(() => import("./zoomvideo/components/InstallAppButton")),
|
zoomvideo: dynamic(() => import("./zoomvideo/components/InstallAppButton")),
|
||||||
office365video: dynamic(() => import("./office365video/components/InstallAppButton")),
|
office365video: dynamic(() => import("./office365video/components/InstallAppButton")),
|
||||||
wipemycalother: dynamic(() => import("./wipemycalother/components/InstallAppButton")),
|
wipemycalother: dynamic(() => import("./wipemycalother/components/InstallAppButton")),
|
||||||
|
jitsivideo: dynamic(() => import("./jitsivideo/components/InstallAppButton")),
|
||||||
|
huddle01video: dynamic(() => import("./huddle01video/components/InstallAppButton")),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const InstallAppButton = (
|
export const InstallAppButton = (
|
||||||
|
|
|
@ -21,7 +21,7 @@ export const metadata = {
|
||||||
slug: "huddle01_video",
|
slug: "huddle01_video",
|
||||||
title: "Huddle01",
|
title: "Huddle01",
|
||||||
trending: true,
|
trending: true,
|
||||||
isGlobal: true,
|
isGlobal: false,
|
||||||
email: "support@huddle01.com",
|
email: "support@huddle01.com",
|
||||||
locationType: LocationType.Huddle01,
|
locationType: LocationType.Huddle01,
|
||||||
locationLabel: "Huddle01 Video",
|
locationLabel: "Huddle01 Video",
|
||||||
|
|
42
packages/app-store/huddle01video/api/add.ts
Normal file
42
packages/app-store/huddle01video/api/add.ts
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import type { NextApiRequest, NextApiResponse } from "next";
|
||||||
|
|
||||||
|
import prisma from "@calcom/prisma";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an example endpoint for an app, these will run under `/api/integrations/[...args]`
|
||||||
|
* @param req
|
||||||
|
* @param res
|
||||||
|
*/
|
||||||
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
if (!req.session?.user?.id) {
|
||||||
|
return res.status(401).json({ message: "You must be logged in to do this" });
|
||||||
|
}
|
||||||
|
const appType = "huddle01_video";
|
||||||
|
try {
|
||||||
|
const alreadyInstalled = await prisma.credential.findFirst({
|
||||||
|
where: {
|
||||||
|
type: appType,
|
||||||
|
userId: req.session.user.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (alreadyInstalled) {
|
||||||
|
throw new Error("Already installed");
|
||||||
|
}
|
||||||
|
const installation = await prisma.credential.create({
|
||||||
|
data: {
|
||||||
|
type: appType,
|
||||||
|
key: {},
|
||||||
|
userId: req.session.user.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!installation) {
|
||||||
|
throw new Error("Unable to create user credential for huddle01video");
|
||||||
|
}
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
return res.status(500).json({ message: error.message });
|
||||||
|
}
|
||||||
|
return res.status(500);
|
||||||
|
}
|
||||||
|
return res.redirect("/apps/installed");
|
||||||
|
}
|
1
packages/app-store/huddle01video/api/index.ts
Normal file
1
packages/app-store/huddle01video/api/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { default as add } from "./add";
|
|
@ -0,0 +1,18 @@
|
||||||
|
import type { InstallAppButtonProps } from "@calcom/app-store/types";
|
||||||
|
|
||||||
|
import useAddAppMutation from "../../_utils/useAddAppMutation";
|
||||||
|
|
||||||
|
export default function InstallAppButton(props: InstallAppButtonProps) {
|
||||||
|
const mutation = useAddAppMutation("huddle01_video");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{props.render({
|
||||||
|
onClick() {
|
||||||
|
mutation.mutate("");
|
||||||
|
},
|
||||||
|
loading: mutation.isLoading,
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
1
packages/app-store/huddle01video/components/index.ts
Normal file
1
packages/app-store/huddle01video/components/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { default as InstallAppButton } from "./InstallAppButton";
|
|
@ -1,2 +1,3 @@
|
||||||
export * as lib from "./lib";
|
export * as lib from "./lib";
|
||||||
|
export * as api from "./api";
|
||||||
export { metadata } from "./_metadata";
|
export { metadata } from "./_metadata";
|
||||||
|
|
|
@ -20,7 +20,7 @@ export const metadata = {
|
||||||
slug: "jitsi_video",
|
slug: "jitsi_video",
|
||||||
title: "Jitsi Meet",
|
title: "Jitsi Meet",
|
||||||
trending: true,
|
trending: true,
|
||||||
isGlobal: true,
|
isGlobal: false,
|
||||||
email: "help@cal.com",
|
email: "help@cal.com",
|
||||||
locationType: LocationType.Jitsi,
|
locationType: LocationType.Jitsi,
|
||||||
locationLabel: "Jitsi Video",
|
locationLabel: "Jitsi Video",
|
||||||
|
|
42
packages/app-store/jitsivideo/api/add.ts
Normal file
42
packages/app-store/jitsivideo/api/add.ts
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import type { NextApiRequest, NextApiResponse } from "next";
|
||||||
|
|
||||||
|
import prisma from "@calcom/prisma";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an example endpoint for an app, these will run under `/api/integrations/[...args]`
|
||||||
|
* @param req
|
||||||
|
* @param res
|
||||||
|
*/
|
||||||
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
if (!req.session?.user?.id) {
|
||||||
|
return res.status(401).json({ message: "You must be logged in to do this" });
|
||||||
|
}
|
||||||
|
const appType = "jitsi_video";
|
||||||
|
try {
|
||||||
|
const alreadyInstalled = await prisma.credential.findFirst({
|
||||||
|
where: {
|
||||||
|
type: appType,
|
||||||
|
userId: req.session.user.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (alreadyInstalled) {
|
||||||
|
throw new Error("Already installed");
|
||||||
|
}
|
||||||
|
const installation = await prisma.credential.create({
|
||||||
|
data: {
|
||||||
|
type: appType,
|
||||||
|
key: {},
|
||||||
|
userId: req.session.user.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!installation) {
|
||||||
|
throw new Error("Unable to create user credential for jitsivideo");
|
||||||
|
}
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
return res.status(500).json({ message: error.message });
|
||||||
|
}
|
||||||
|
return res.status(500);
|
||||||
|
}
|
||||||
|
return res.redirect("/apps/installed");
|
||||||
|
}
|
1
packages/app-store/jitsivideo/api/index.ts
Normal file
1
packages/app-store/jitsivideo/api/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { default as add } from "./add";
|
|
@ -0,0 +1,18 @@
|
||||||
|
import type { InstallAppButtonProps } from "@calcom/app-store/types";
|
||||||
|
|
||||||
|
import useAddAppMutation from "../../_utils/useAddAppMutation";
|
||||||
|
|
||||||
|
export default function InstallAppButton(props: InstallAppButtonProps) {
|
||||||
|
const mutation = useAddAppMutation("jitsi_video");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{props.render({
|
||||||
|
onClick() {
|
||||||
|
mutation.mutate("");
|
||||||
|
},
|
||||||
|
loading: mutation.isLoading,
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
1
packages/app-store/jitsivideo/components/index.ts
Normal file
1
packages/app-store/jitsivideo/components/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { default as InstallAppButton } from "./InstallAppButton";
|
|
@ -1,2 +1,3 @@
|
||||||
export * as lib from "./lib";
|
export * as lib from "./lib";
|
||||||
|
export * as api from "./api";
|
||||||
export { metadata } from "./_metadata";
|
export { metadata } from "./_metadata";
|
||||||
|
|
Loading…
Reference in a new issue