Feat: v2 App Store / Installed Apps (#4220)

* First commit

* Additional changes to meet designs

* Fixing app details disconnect button
App Store category filtering fixed

* Further changes for the fix

* Progress on various fronts

* Fixing e2e tests

* second try fixing e2e tests

* Yet again trying to fix e2e tests

* Missing action for non-credential flow

* Adding missing Add button

* Final tweaks and fixes

* Missing button in empty screen

* fix border radius

* EmptyScreen for calendar

* Dynamic installed app return page with highlights + other fixes

* Removing unneeded code

* App Store V2 Improvements over feat/v2-installed-apps (#4379)

* Removing unneeded text

* Fixing app details disconnect button and number of apps (#4305)

* V2 Settings Shell - Add Teams Section & UI fixes (#4347)

* Add teams to sidebar and fix UI

* Clean up

* V2 Multi-select (Team Select) (#4324)

* --init

* design improved

* further fine tuning

* more fixes

* removed extra JSX tag

* added story

* NIT

* revert to use of CheckedTeamSelect

* Removes comments

Co-authored-by: Peer Richelsen <[email protected]>

* fix: toggle alligment (#4361)

* fix: add checked tranform for switch (#4357)

* fixed input size on mobile, fixed settings (#4360)

* fixing type errors

* Mobile fixes

* Tests fixes

Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: zomars <[email protected]>

* Feat/team owner booking (#3999)

* WIP: testing queries

* feat: add badge

* fix: get only id

* refactor: get bookings query

* WIP: display attendees added

* fix: add type

* Adds skeleton loader to workflows (#4402)

* fix event types skeleton loader

* fix margin in event types

* fix skeleton loader in bookings

* add skeleton loader for workflow list

* add skeleton loader for editing page

* fix border radius of skeleton loader

* fix mobile view workflow list

* add mobile view for skeleton list

* make multi select full with in mobile view

* mobile view for edit skeleton loader

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* V2 settings teams (Profil, Members, Appearance View) (#4350)

* add team profile

* first version for team members page

* finish up design of member list item

* fix dialog buttons

* add missing seats and upgrading information

* add v2 dialog for changing role

* finish basic version of member's schedule

* remove modalContainer

* design fixes team profile page

* show only team info to non admins

* allow all member to check availabilities

* make time available heading sticky

* add dropdown for mobile view

* create team appearance view

* finish appearance page

* use settings layout and add danger zone for member

* add fallback logo

* Add teams to sidebar and fix UI

* add team invitations

* Clean up

* code clean up

* add impersontation and disable autofocus on calendar

* improve team info

* refactor teaminvitelist code and fix leaving a team

* add team pages to settings shell

* add link to create new team

* small fixes

* clean up comments

* V2 Multi-select (Team Select) (#4324)

* --init

* design improved

* further fine tuning

* more fixes

* removed extra JSX tag

* added story

* NIT

* revert to use of CheckedTeamSelect

* Removes comments

Co-authored-by: Peer Richelsen <[email protected]>

* fix: toggle alligment (#4361)

* fix: add checked tranform for switch (#4357)

* fixed input size on mobile, fixed settings (#4360)

* fix image uploader button in safari

* code clean up

* fixing type errors

* Moved v2 team components to features

Adds deprecation notices

* Update SettingsLayout.tsx

* Migrated to features and build fixes

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: zomars <[email protected]>

* add rainbowkit form to v2 event-types (#4349)

Co-authored-by: Omar López <[email protected]>

* v1.9.5

* Fix/daterangepicker css (#4418)

* added styles from external stylesheet

* fixed a border color

* codacy improvements

* more codacy fix

* codacy why u be so dumb

* dynamic import rainbow (only if installed) (#4409)

* Tidyup app cards (#4428)

* Moving API to trpc query

Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: zomars <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Carina Wollendorfer <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: hexcowboy <[email protected]>
Co-authored-by: sean-brydon <[email protected]>

* Abstracting one level the redirectUrl for apps

* Moving enum to a better/working place

* Another try

* Missing code

* Correcting categories look in apps page

* ui tweaks

* Breadcrumb wrong font-weight

* Toast is v1 component and copy updated

* Fix TS error

* Fix TS error

* Update AppsLayout.tsx

* Update InstalledAppsLayout.tsx

* translations and disconnect button with icon

* Reverting file

* Test e2e fix on app-store

* Missing testid in button

* Fix to click categories that are visible

* Going directly to category page as a patch

* Fixing stripe e2e test

* Disconnect is now empty with icon

* Disabled stripe test for now as the navigation is completely changed

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Omar López <[email protected]>
Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: Hariom Balhara <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Carina Wollendorfer <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: hexcowboy <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
68 files changed
+1284 -231

No files matched your search

+1 -1
View File
@@ -6,10 +6,10 @@ import appConfig from "../config.json";
const handler: AppDeclarativeHandler = {
// Instead of passing appType and slug from here, api/integrations/[..args] should be able to derive and pass these directly to createCredential
appType: appConfig.type,
variant: appConfig.variant,
slug: appConfig.slug,
supportsMultipleInstalls: false,
handlerType: "add",
redirectUrl: "/apps/installed",
createCredential: ({ appType, user, slug }) =>
createDefaultInstallation({ appType, userId: user.id, slug, key: {} }),
};
@@ -0,0 +1,20 @@
import z from "zod";
import { InstalledAppVariants } from "../utils";
const variantSchema = z.nativeEnum(InstalledAppVariants);
export default function getInstalledAppPath(
{ variant, slug }: { variant?: string; slug?: string },
locationSearch = ""
): string {
if (!variant) return `/apps/installed${locationSearch}`;
const parsedVariant = variantSchema.safeParse(variant);
if (!parsedVariant.success) return `/apps/installed${locationSearch}`;
if (!slug) return `/apps/installed/${variant}${locationSearch}`;
return `/apps/installed/${variant}?hl=${slug}${locationSearch && locationSearch.slice(1)}`;
}
+30 -20
View File
@@ -4,30 +4,40 @@ import type { IntegrationOAuthCallbackState } from "@calcom/app-store/types";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { App } from "@calcom/types/App";
import getInstalledAppPath from "./getInstalledAppPath";
function useAddAppMutation(_type: App["type"] | null, options?: Parameters<typeof useMutation>[2]) {
const mutation = useMutation<unknown, Error, { type?: App["type"] } | "">(async (variables) => {
let type: string | null | undefined;
if (variables === "") {
type = _type;
} else {
type = variables.type;
}
const state: IntegrationOAuthCallbackState = {
returnTo: WEBAPP_URL + "/apps/installed" + location.search,
};
const stateStr = encodeURIComponent(JSON.stringify(state));
const searchParams = `?state=${stateStr}`;
const mutation = useMutation<unknown, Error, { type?: App["type"]; variant?: string; slug?: string } | "">(
async (variables) => {
let type: string | null | undefined;
if (variables === "") {
type = _type;
} else {
type = variables.type;
}
const state: IntegrationOAuthCallbackState = {
returnTo:
WEBAPP_URL +
getInstalledAppPath(
{ variant: variables && variables.variant, slug: variables && variables.slug },
location.search
),
};
const stateStr = encodeURIComponent(JSON.stringify(state));
const searchParams = `?state=${stateStr}`;
const res = await fetch(`/api/integrations/${type}/add` + searchParams);
const res = await fetch(`/api/integrations/${type}/add` + searchParams);
if (!res.ok) {
const errorBody = await res.json();
throw new Error(errorBody.message || "Something went wrong");
}
if (!res.ok) {
const errorBody = await res.json();
throw new Error(errorBody.message || "Something went wrong");
}
const json = await res.json();
window.location.href = json.url;
}, options);
const json = await res.json();
window.location.href = json.url;
},
options
);
return mutation;
}
+4 -1
View File
@@ -4,6 +4,7 @@ import { symmetricEncrypt } from "@calcom/lib/crypto";
import logger from "@calcom/lib/logger";
import prisma from "@calcom/prisma";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import { CalendarService } from "../lib";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
@@ -40,7 +41,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
return res.status(500).json({ message: "Could not add this caldav account" });
}
return res.status(200).json({ url: "/apps/installed" });
return res
.status(200)
.json({ url: getInstalledAppPath({ variant: "calendar", slug: "apple-calendar" }) });
}
if (req.method === "GET") {
+3 -1
View File
@@ -3,12 +3,14 @@ import type { NextApiRequest, NextApiResponse } from "next";
import { defaultResponder } from "@calcom/lib/server";
import checkSession from "../../_utils/auth";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import { checkInstalled, createDefaultInstallation } from "../../_utils/installation";
import appConfig from "../config.json";
export async function getHandler(req: NextApiRequest, res: NextApiResponse) {
const session = checkSession(req);
const slug = appConfig.slug;
const variant = appConfig.variant;
const appType = appConfig.type;
await checkInstalled(slug, session.user.id);
@@ -19,7 +21,7 @@ export async function getHandler(req: NextApiRequest, res: NextApiResponse) {
key: {},
});
return { url: "/apps/installed" };
return { url: getInstalledAppPath({ variant, slug }) };
}
export default defaultResponder(getHandler);
+4 -1
View File
@@ -4,6 +4,7 @@ import { symmetricEncrypt } from "@calcom/lib/crypto";
import logger from "@calcom/lib/logger";
import prisma from "@calcom/prisma";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import { CalendarService } from "../lib";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
@@ -43,7 +44,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
return res.status(500).json({ message: "Could not add this caldav account" });
}
return res.status(200).json({ url: "/apps/installed" });
return res
.status(200)
.json({ url: getInstalledAppPath({ variant: "calendar", slug: "caldav-calendar" }) });
}
if (req.method === "GET") {
+1 -1
View File
@@ -6,10 +6,10 @@ import appConfig from "../config.json";
const handler: AppDeclarativeHandler = {
// Instead of passing appType and slug from here, api/integrations/[..args] should be able to derive and pass these directly to createCredential
appType: appConfig.type,
variant: appConfig.variant,
slug: appConfig.slug,
supportsMultipleInstalls: false,
handlerType: "add",
redirectUrl: "/apps/installed",
createCredential: ({ appType, user, slug }) =>
createDefaultInstallation({ appType, userId: user.id, slug, key: {} }),
};
@@ -7,6 +7,7 @@ import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import checkSession from "../../_utils/auth";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
export async function getHandler(req: NextApiRequest, res: NextApiResponse) {
const session = checkSession(req);
@@ -32,7 +33,7 @@ export async function getHandler(req: NextApiRequest, res: NextApiResponse) {
return res.status(500).json({ message: "Could not add Close.com app" });
}
return res.status(200).json({ url: "/apps/installed" });
return res.status(200).json({ url: getInstalledAppPath({ variant: "other", slug: "closecom" }) });
}
export default defaultResponder(getHandler);
+2 -1
View File
@@ -25,6 +25,7 @@ export const InstallAppButton = (
props: {
isProOnly?: App["isProOnly"];
type: App["type"];
wrapperClassName?: string;
} & InstallAppButtonProps
) => {
const { isLoading, data: user } = trpc.useQuery(["viewer.me"]);
@@ -55,7 +56,7 @@ export const InstallAppButton = (
}
return (
<div ref={proProtectionElementRef}>
<div ref={proProtectionElementRef} className={props.wrapperClassName}>
<InstallAppButtonWithoutPlanCheck {...props} />
</div>
);
@@ -6,6 +6,7 @@ import appConfig from "../config.json";
const handler: AppDeclarativeHandler = {
// Instead of passing appType and slug from here, api/integrations/[..args] should be able to derive and pass these directly to createCredential
appType: appConfig.type,
variant: appConfig.variant,
slug: appConfig.slug,
supportsMultipleInstalls: false,
handlerType: "add",
@@ -6,6 +6,7 @@ import logger from "@calcom/lib/logger";
import { defaultHandler, defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import { CalendarService } from "../lib";
const bodySchema = z
@@ -49,7 +50,7 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
return res.status(500).json({ message: "Could not add this exchange account" });
}
return { url: "/apps/installed" };
return { url: getInstalledAppPath({ variant: "calendar", slug: "exchange2013-calendar" }) };
}
async function getHandler() {
@@ -6,6 +6,7 @@ import logger from "@calcom/lib/logger";
import { defaultHandler, defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import { CalendarService } from "../lib";
const bodySchema = z
@@ -49,7 +50,7 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
return res.status(500).json({ message: "Could not add this exchange account" });
}
return { url: "/apps/installed" };
return { url: getInstalledAppPath({ variant: "calendar", slug: "exchange2016-calendar" }) };
}
async function getHandler() {
+3 -1
View File
@@ -2,6 +2,8 @@ import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@calcom/prisma";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
/**
* This is an example endpoint for an app, these will run under `/api/integrations/[...args]`
* @param req
@@ -40,5 +42,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
return res.status(500);
}
return res.status(200).json({ url: "/apps/installed" });
return res.status(200).json({ url: getInstalledAppPath({ variant: "other", slug: "giphy" }) });
}
@@ -7,6 +7,7 @@ import prisma from "@calcom/prisma";
import { decodeOAuthState } from "../../_utils/decodeOAuthState";
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
let client_id = "";
let client_secret = "";
@@ -48,5 +49,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
},
});
const state = decodeOAuthState(req);
res.redirect(getSafeRedirectUrl(state?.returnTo) ?? "/apps/installed");
res.redirect(
getSafeRedirectUrl(state?.returnTo) ??
getInstalledAppPath({ variant: "calendar", slug: "google-calendar" })
);
}
@@ -8,6 +8,7 @@ import prisma from "@calcom/prisma";
import { decodeOAuthState } from "../../_utils/decodeOAuthState";
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
let client_id = "";
let client_secret = "";
@@ -55,5 +56,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
});
const state = decodeOAuthState(req);
res.redirect(getSafeRedirectUrl(state?.returnTo) ?? "/apps/installed");
res.redirect(
getSafeRedirectUrl(state?.returnTo) ?? getInstalledAppPath({ variant: "other_calendar", slug: "hubspot" })
);
}
+3 -1
View File
@@ -2,6 +2,8 @@ import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@calcom/prisma";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
/**
* This is an example endpoint for an app, these will run under `/api/integrations/[...args]`
* @param req
@@ -40,5 +42,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
return res.status(500);
}
// need to return a json object with the response status
return res.status(200).json({ url: "/apps/installed" });
return res.status(200).json({ url: getInstalledAppPath({ variant: "conferencing", slug: "huddle01" }) });
}
+3 -1
View File
@@ -2,6 +2,8 @@ import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@calcom/prisma";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
/**
* This is an example endpoint for an app, these will run under `/api/integrations/[...args]`
* @param req
@@ -39,5 +41,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
return res.status(500);
}
return res.status(200).json({ url: "/apps/installed" });
return res.status(200).json({ url: getInstalledAppPath({ variant: "conferencing", slug: "jitsi" }) });
}
@@ -7,6 +7,7 @@ import { defaultHandler, defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { decodeOAuthState } from "../../_utils/decodeOAuthState";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import { LARK_HOST } from "../common";
import { getAppAccessToken } from "../lib/AppAccessToken";
import type { LarkAuthCredentials } from "../types/LarkCalendar";
@@ -88,7 +89,10 @@ async function getHandler(req: NextApiRequest, res: NextApiResponse) {
});
}
res.redirect(getSafeRedirectUrl(state?.returnTo) ?? "/apps/installed");
res.redirect(
getSafeRedirectUrl(state?.returnTo) ??
getInstalledAppPath({ variant: "calendar", slug: "lark-calendar" })
);
} catch (error) {
log.error("handle callback error", error);
res.redirect(state?.returnTo ?? "/apps/installed");
+1
View File
@@ -6,6 +6,7 @@ import appConfig from "../config.json";
const handler: AppDeclarativeHandler = {
// Instead of passing appType and slug from here, api/integrations/[..args] should be able to derive and pass these directly to createCredential
appType: appConfig.type,
variant: appConfig.variant,
slug: appConfig.slug,
supportsMultipleInstalls: false,
handlerType: "add",
@@ -6,6 +6,7 @@ import prisma from "@calcom/prisma";
import { decodeOAuthState } from "../../_utils/decodeOAuthState";
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
const scopes = ["offline_access", "Calendars.Read", "Calendars.ReadWrite"];
@@ -74,5 +75,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
});
const state = decodeOAuthState(req);
return res.redirect(getSafeRedirectUrl(state?.returnTo) ?? "/apps/installed");
return res.redirect(
getSafeRedirectUrl(state?.returnTo) ??
getInstalledAppPath({ variant: "calendar", slug: "office365-calendar" })
);
}
@@ -6,6 +6,7 @@ import prisma from "@calcom/prisma";
import { decodeOAuthState } from "../../_utils/decodeOAuthState";
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
const scopes = ["OnlineMeetings.ReadWrite"];
@@ -101,5 +102,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
});
const state = decodeOAuthState(req);
return res.redirect(getSafeRedirectUrl(state?.returnTo) ?? "/apps/installed");
return res.redirect(
getSafeRedirectUrl(state?.returnTo) ?? getInstalledAppPath({ variant: "conferencing", slug: "msteams" })
);
}
+2 -1
View File
@@ -3,6 +3,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
import { defaultResponder } from "@calcom/lib/server";
import checkSession from "../../_utils/auth";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import { checkInstalled, createDefaultInstallation } from "../../_utils/installation";
import appConfig from "../config.json";
@@ -19,7 +20,7 @@ export async function getHandler(req: NextApiRequest, res: NextApiResponse) {
key: {},
});
return { url: "/apps/installed" };
return { url: getInstalledAppPath({ variant: "other", slug: "ping" }) };
}
export default defaultResponder(getHandler);
+1 -1
View File
@@ -7,9 +7,9 @@ const handler: AppDeclarativeHandler = {
// Instead of passing appType and slug from here, api/integrations/[..args] should be able to derive and pass these directly to createCredential
appType: appConfig.type,
slug: appConfig.slug,
variant: appConfig.slug,
supportsMultipleInstalls: false,
handlerType: "add",
redirectUrl: "/apps/installed",
createCredential: ({ appType, user, slug }) =>
createDefaultInstallation({ appType, userId: user.id, slug, key: {} }),
};
+1
View File
@@ -7,6 +7,7 @@ const handler: AppDeclarativeHandler = {
// Instead of passing appType and slug from here, api/integrations/[..args] should be able to derive and pass these directly to createCredential
appType: appConfig.type,
slug: appConfig.slug,
variant: appConfig.variant,
supportsMultipleInstalls: false,
handlerType: "add",
redirectUrl: "raycast://extensions/eluce2/cal-com-share-meeting-links?source=webstore",
+2 -1
View File
@@ -3,6 +3,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
import { defaultResponder } from "@calcom/lib/server";
import checkSession from "../../_utils/auth";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import { checkInstalled, createDefaultInstallation } from "../../_utils/installation";
import appConfig from "../config.json";
@@ -19,7 +20,7 @@ export async function getHandler(req: NextApiRequest, res: NextApiResponse) {
key: {},
});
return { url: "/apps/installed" };
return { url: getInstalledAppPath({ variant: "conferencing", slug: "riverside" }) };
}
export default defaultResponder(getHandler);
@@ -6,6 +6,7 @@ import { HttpError } from "@calcom/lib/http-error";
import { defaultHandler, defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import { getSlackAppKeys } from "../lib/utils";
const callbackQuerySchema = z.object({
@@ -52,7 +53,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
},
});
res.redirect("/apps/installed");
res.redirect(getInstalledAppPath({ variant: "conferencing", slug: "slack" }));
}
export default defaultHandler({
@@ -4,6 +4,7 @@ import { stringify } from "querystring";
import prisma from "@calcom/prisma";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import stripe, { StripeData } from "../lib/server";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
@@ -39,5 +40,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
},
});
res.redirect("/apps/installed");
res.redirect(getInstalledAppPath({ variant: "payment", slug: "stripe" }));
}
@@ -3,6 +3,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@calcom/prisma";
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
let client_id = "";
let client_secret = "";
@@ -74,5 +75,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
});
}
res.redirect("/apps/installed");
res.redirect(getInstalledAppPath({ variant: "conferencing", slug: "tandem" }));
}
+1
View File
@@ -7,6 +7,7 @@ const handler: AppDeclarativeHandler = {
// Instead of passing appType and slug from here, api/integrations/[..args] should be able to derive and pass these directly to createCredential
appType: appConfig.type,
slug: appConfig.slug,
variant: appConfig.variant,
supportsMultipleInstalls: false,
handlerType: "add",
redirectUrl: "/apps/typeform/how-to-use",
+7
View File
@@ -25,6 +25,13 @@ const credentialData = Prisma.validator<Prisma.CredentialArgs>()({
type CredentialData = Prisma.CredentialGetPayload<typeof credentialData>;
export enum InstalledAppVariants {
"conferencing" = "conferencing",
"calendar" = "calendar",
"payment" = "payment",
"other" = "other",
}
export const ALL_APPS = Object.values(ALL_APPS_MAP);
type OptionTypeBase = {
+3 -1
View File
@@ -3,6 +3,8 @@ import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@calcom/prisma";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
/**
* This is will generate a user token for a client_user_id`
* @param req
@@ -34,7 +36,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
},
},
});
return res.redirect("/apps/installed");
return res.redirect(getInstalledAppPath({ variant: "other", slug: "vital-automation" }));
} catch (e) {
return res.status(500);
}
+2 -1
View File
@@ -3,6 +3,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
import { defaultResponder } from "@calcom/lib/server";
import checkSession from "../../_utils/auth";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import { checkInstalled, createDefaultInstallation } from "../../_utils/installation";
import appConfig from "../config.json";
@@ -19,7 +20,7 @@ export async function getHandler(req: NextApiRequest, res: NextApiResponse) {
key: {},
});
return { url: "/apps/installed" };
return { url: getInstalledAppPath({ variant: "conferencing", slug: "whereby" }) };
}
export default defaultResponder(getHandler);
+3 -1
View File
@@ -2,6 +2,8 @@ import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@calcom/prisma";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
/**
* This is an example endpoint for an app, these will run under `/api/integrations/[...args]`
* @param req
@@ -40,5 +42,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
return res.status(500);
}
return res.status(200).json({ url: "/apps/installed" });
return res.status(200).json({ url: getInstalledAppPath({ variant: "other", slug: "wipe-my-cal" }) });
}
+2 -1
View File
@@ -3,6 +3,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
import { WEBAPP_URL } from "@calcom/lib/constants";
import prisma from "@calcom/prisma";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import { getZoomAppKeys } from "../lib";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
@@ -83,5 +84,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
},
});
res.redirect("/apps/installed");
res.redirect(getInstalledAppPath({ variant: "conferencing", slug: "zoom" }));
}
@@ -19,9 +19,10 @@ type LicenseRequiredProps = {
const LicenseRequired = ({ children, as = "", ...rest }: LicenseRequiredProps) => {
const session = useSession();
const Component = as || Fragment;
const hasValidLicense = session.data ? session.data.hasValidLicense : null;
return (
<Component {...rest}>
{session.data?.hasValidLicense ? (
{hasValidLicense === null || hasValidLicense ? (
children
) : (
<EmptyScreen
+15 -2
View File
@@ -721,19 +721,23 @@ const loggedInViewerRouter = createProtectedRouter()
.query("integrations", {
input: z.object({
variant: z.string().optional(),
exclude: z.array(z.string()).optional(),
onlyInstalled: z.boolean().optional(),
}),
async resolve({ ctx, input }) {
const { user } = ctx;
const { variant, onlyInstalled } = input;
const { variant, exclude, onlyInstalled } = input;
const { credentials } = user;
let apps = getApps(credentials).map(
({ credentials: _, credential: _1 /* don't leak to frontend */, ...app }) => ({
...app,
credentialIds: credentials.filter((c) => c.type === app.type).map((c) => c.id),
})
);
if (exclude) {
// exclusion filter
apps = apps.filter((item) => (exclude ? !exclude.includes(item.variant) : true));
}
if (variant) {
// `flatMap()` these work like `.filter()` but infers the types correctly
apps = apps
@@ -766,6 +770,15 @@ const loggedInViewerRouter = createProtectedRouter()
return app;
},
})
.query("appCredentialsByType", {
input: z.object({
appType: z.string(),
}),
async resolve({ ctx, input }) {
const { user } = ctx;
return user.credentials.filter((app) => app.type == input.appType).map((credential) => credential.id);
},
})
.query("stripeCustomer", {
async resolve({ ctx }) {
const {
+2 -1
View File
@@ -6,10 +6,11 @@ import { Credential } from "@calcom/prisma/client";
export type AppDeclarativeHandler = {
appType: string;
slug: string;
variant: string;
supportsMultipleInstalls: false;
handlerType: "add";
createCredential: (arg: { user: Session["user"]; appType: string; slug: string }) => Promise<Credential>;
supportsMultipleInstalls: boolean;
redirectUrl: string;
redirectUrl?: string;
};
export type AppHandler = AppDeclarativeHandler | NextApiHandler;
+1 -1
View File
@@ -112,7 +112,7 @@ export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps
)}
<div>
{props.title && <DialogHeader title={props.title} />}
{props.description && <p className="mb-6 text-sm text-gray-500">Optional Description</p>}
{props.description && <p className="mb-6 text-sm text-gray-500">{props.description}</p>}
</div>
</div>
)}
+25 -7
View File
@@ -376,7 +376,7 @@ function UserDropdown({ small }: { small?: boolean }) {
);
}
type NavigationItemType = {
export type NavigationItemType = {
name: string;
href: string;
icon?: SVGComponent;
@@ -417,16 +417,32 @@ const navigation: NavigationItemType[] = [
icon: Icon.FiGrid,
isCurrent: ({ router, item }) => {
const path = router.asPath.split("?")[0];
return !!item.child?.some((child) => path === child.href);
// During Server rendering path is /v2/apps but on client it becomes /apps(weird..)
return (
(path.startsWith(item.href) || path.startsWith("/v2" + item.href)) && !path.includes("routing_forms/")
);
},
child: [
{
name: "app_store",
href: "/apps",
isCurrent: ({ router, item }) => {
const path = router.asPath.split("?")[0];
// During Server rendering path is /v2/apps but on client it becomes /apps(weird..)
return (
(path.startsWith(item.href) || path.startsWith("/v2" + item.href)) &&
!path.includes("routing_forms/") &&
!path.includes("/installed")
);
},
},
{
name: "installed_apps",
href: "/apps/installed",
href: "/apps/installed/calendar",
isCurrent: ({ router }) => {
const path = router.asPath;
return path.startsWith("/apps/installed/") || path.startsWith("/v2/apps/installed/");
},
},
],
},
@@ -538,7 +554,6 @@ const NavigationItem: React.FC<{
</Link>
{item.child &&
isCurrent({ router, isChild, item }) &&
router.asPath.startsWith(item.href) &&
item.child.map((item) => <NavigationItem key={item.name} item={item} isChild />)}
</Fragment>
);
@@ -648,7 +663,10 @@ function DeploymentInfo() {
function SideBarContainer() {
const { status } = useSession();
const router = useRouter();
if (status !== "authenticated") return null;
// Make sure that Sidebar is rendered optimistically so that a refresh of pages when logged in have SideBar from the beginning.
// This improves the experience of refresh on app store pages(when logged in) which are SSG.
// Though when logged out, app store pages would temporarily show SideBar until session status is confirmed.
if (status !== "loading" && status !== "authenticated") return null;
if (router.route.startsWith("/v2/settings/")) return null;
return <SideBar />;
}
@@ -735,12 +753,12 @@ export function ShellMain(props: LayoutProps) {
<div className="hidden w-full ltr:mr-4 rtl:ml-4 sm:block">
{props.heading && (
<h1 className="font-cal mb-1 text-xl font-bold capitalize tracking-wide text-black">
{!isLocaleReady ? null : props.heading}
{!isLocaleReady ? <SkeletonText invisible /> : props.heading}
</h1>
)}
{props.subtitle && (
<p className="hidden text-sm text-neutral-500 sm:block">
{!isLocaleReady ? null : props.subtitle}
{!isLocaleReady ? <SkeletonText invisible /> : props.subtitle}
</p>
)}
</div>
+14 -6
View File
@@ -86,8 +86,8 @@ export default function AllApps({ apps }: AllAppsPropsType) {
router.replace(router.asPath.split("?")[0], undefined, { shallow: true });
}}
className={classNames(
selectedCategory === null ? "bg-gray-200" : "bg-gray-50",
"rounded-md px-4 py-2.5 text-sm font-medium text-gray-900 hover:cursor-pointer hover:bg-gray-200"
selectedCategory === null ? "bg-gray-900 text-gray-50" : "bg-gray-50 text-gray-900",
"rounded-md px-4 py-2.5 text-sm font-medium hover:cursor-pointer hover:bg-gray-900 hover:text-gray-50"
)}>
{t("all_apps")}
</li>
@@ -104,8 +104,8 @@ export default function AllApps({ apps }: AllAppsPropsType) {
}
}}
className={classNames(
selectedCategory === cat ? "bg-gray-200" : "bg-gray-50",
"rounded-md px-4 py-2.5 text-sm font-medium text-gray-900 hover:cursor-pointer hover:bg-gray-200"
selectedCategory === cat ? "bg-gray-900 text-gray-50" : "bg-gray-50 text-gray-900",
"rounded-md px-4 py-2.5 text-sm font-medium hover:cursor-pointer hover:bg-gray-900 hover:text-gray-50"
)}>
{cat[0].toUpperCase() + cat.slice(1)}
</li>
@@ -120,9 +120,17 @@ export default function AllApps({ apps }: AllAppsPropsType) {
</div>
)}
</div>
<div className="grid grid-cols-2 gap-3 md:grid-cols-4" ref={appsContainerRef}>
<div
className="grid gap-3 lg:grid-cols-4 [@media(max-width:1270px)]:grid-cols-3 [@media(max-width:730px)]:grid-cols-2 [@media(max-width:500px)]:grid-cols-1"
ref={appsContainerRef}>
{apps
.filter((app) => (selectedCategory !== null ? app.category === selectedCategory : true))
.filter((app) =>
selectedCategory !== null
? app.categories
? app.categories.includes(selectedCategory)
: app.category === selectedCategory
: true
)
.map((app) => (
<AppCard key={app.name} app={app} credentials={app.credentials} />
))}
+13 -4
View File
@@ -9,6 +9,8 @@ import { App } from "@calcom/types/App";
import { Icon } from "@calcom/ui/Icon";
import Button from "@calcom/ui/v2/core/Button";
import { SkeletonText } from "../skeleton";
interface AppCardProps {
app: App;
credentials?: Credential[];
@@ -16,7 +18,7 @@ interface AppCardProps {
export default function AppCard({ app, credentials }: AppCardProps) {
const { t } = useLocale();
const { isLocaleReady } = useLocale();
const mutation = useAddAppMutation(null, {
onSuccess: () => {
showToast(t("app_successfully_installed"), "success");
@@ -64,16 +66,21 @@ export default function AppCard({ app, credentials }: AppCardProps) {
<InstallAppButton
type={app.type}
isProOnly={app.isProOnly}
wrapperClassName="[@media(max-width:260px)]:w-full"
render={({ useDefaultComponent, ...props }) => {
if (useDefaultComponent) {
props = {
onClick: () => {
mutation.mutate({ type: app.type });
mutation.mutate({ type: app.type, variant: app.variant, slug: app.slug });
},
};
}
return (
<Button color="secondary" StartIcon={Icon.FiPlus} {...props}>
<Button
color="secondary"
className="[@media(max-width:260px)]:w-full [@media(max-width:260px)]:justify-center"
StartIcon={Icon.FiPlus}
{...props}>
{t("install")}
</Button>
);
@@ -85,11 +92,12 @@ export default function AppCard({ app, credentials }: AppCardProps) {
<InstallAppButton
type={app.type}
isProOnly={app.isProOnly}
wrapperClassName="[@media(max-width:260px)]:w-full"
render={({ useDefaultComponent, ...props }) => {
if (useDefaultComponent) {
props = {
onClick: () => {
mutation.mutate({ type: app.type });
mutation.mutate({ type: app.type, variant: app.variant, slug: app.slug });
},
};
}
@@ -97,6 +105,7 @@ export default function AppCard({ app, credentials }: AppCardProps) {
<Button
StartIcon={Icon.FiPlus}
color="secondary"
className="[@media(max-width:260px)]:w-full [@media(max-width:260px)]:justify-center"
data-testid="install-app-button"
{...props}>
{t("install")}
+11 -5
View File
@@ -3,6 +3,7 @@ import { ArrowRight } from "react-feather";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { SkeletonText } from "../skeleton";
import Slider from "./Slider";
export default function AppStoreCategories({
@@ -13,7 +14,7 @@ export default function AppStoreCategories({
count: number;
}[];
}) {
const { t } = useLocale();
const { t, isLocaleReady } = useLocale();
return (
<div className="mb-16">
<Slider
@@ -33,11 +34,16 @@ export default function AppStoreCategories({
<Link key={category.name} href={"/apps/categories/" + category.name}>
<a
data-testid={`app-store-category-${category.name}`}
className="relative flex rounded-sm bg-gray-100 px-6 py-4 sm:block">
<div className="self-center">
<h3 className="font-medium capitalize">{category.name}</h3>
className="relative flex rounded-md"
style={{ background: "radial-gradient(farthest-side at top right, #a2abbe 0%, #E3E3E3 100%)" }}>
<div className="w-full self-center bg-[url('/noise.svg')] bg-cover bg-center bg-no-repeat px-6 py-4">
{isLocaleReady ? (
<h3 className="font-medium capitalize">{category.name}</h3>
) : (
<SkeletonText invisible />
)}
<p className="text-sm text-gray-500">
{t("number_apps", { count: category.count })}{" "}
{isLocaleReady ? t("number_apps", { count: category.count }) : <SkeletonText invisible />}{" "}
<ArrowRight className="inline-block h-4 w-4" />
</p>
</div>
+12 -5
View File
@@ -3,8 +3,11 @@ import "@glidejs/glide/dist/css/glide.core.min.css";
import "@glidejs/glide/dist/css/glide.theme.min.css";
import { useEffect, useRef } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Icon } from "@calcom/ui/Icon";
import { SkeletonText } from "../skeleton";
const Slider = <T extends string | unknown>({
title = "",
className = "",
@@ -22,7 +25,7 @@ const Slider = <T extends string | unknown>({
}) => {
const glide = useRef(null);
const slider = useRef<Glide.Properties | null>(null);
const { isLocaleReady } = useLocale();
useEffect(() => {
if (glide.current) {
slider.current = new Glide(glide.current, {
@@ -45,10 +48,14 @@ const Slider = <T extends string | unknown>({
</style>
<div className="glide" ref={glide}>
<div className="flex cursor-default">
{title && (
<div>
<h2 className="mt-0 mb-2 text-lg font-semibold text-gray-900">{title}</h2>
</div>
{isLocaleReady ? (
title && (
<div>
<h2 className="mt-0 mb-2 text-lg font-semibold text-gray-900">{title}</h2>
</div>
)
) : (
<SkeletonText className="h-4 w-24" />
)}
<div className="glide__arrows ml-auto" data-glide-el="controls">
<button data-glide-dir="<" className="mr-4">
+2 -3
View File
@@ -1,9 +1,8 @@
import React, { ComponentProps } from "react";
import HorizontalTabs from "@calcom/ui/v2/core/navigation/tabs/HorizontalTabs";
import Shell from "../Shell";
import { HorizontalTabItemProps } from "../navigation/tabs/HorizontalTabItem";
import type { HorizontalTabItemProps } from "../navigation/tabs/HorizontalTabItem";
import HorizontalTabs from "../navigation/tabs/HorizontalTabs";
const tabs: HorizontalTabItemProps[] = [
{
@@ -0,0 +1,62 @@
import React, { ComponentProps } from "react";
import { InstalledAppVariants } from "@calcom/app-store/utils";
import { trpc } from "@calcom/trpc/react";
import { Icon } from "../../../Icon";
import Shell from "../Shell";
import type { HorizontalTabItemProps } from "../navigation/tabs/HorizontalTabItem";
import HorizontalTabs from "../navigation/tabs/HorizontalTabs";
import type { VerticalTabItemProps } from "../navigation/tabs/VerticalTabItem";
import VerticalTabs from "../navigation/tabs/VerticalTabs";
const tabs: (VerticalTabItemProps | HorizontalTabItemProps)[] = [
{
name: "calendar",
href: "/apps/installed/calendar",
icon: Icon.FiCalendar,
},
{
name: "conferencing",
href: "/apps/installed/conferencing",
icon: Icon.FiVideo,
},
{
name: "payment",
href: "/apps/installed/payment",
icon: Icon.FiCreditCard,
},
{
name: "other",
href: "/apps/installed/other",
icon: Icon.FiGrid,
},
];
export default function InstalledAppsLayout({
children,
...rest
}: { children: React.ReactNode } & ComponentProps<typeof Shell>) {
const query = trpc.useQuery([
"viewer.integrations",
{ variant: InstalledAppVariants.payment, onlyInstalled: true },
]);
let actualTabs = tabs;
if (query.data?.items.length === 0) {
actualTabs = tabs.filter((tab) => tab.name !== InstalledAppVariants.payment);
}
return (
<Shell {...rest}>
<div className="mt-10 flex flex-col p-2 md:p-0 xl:flex-row">
<div className="hidden xl:block">
<VerticalTabs tabs={actualTabs} sticky />
</div>
<div className="block xl:hidden">
<HorizontalTabs tabNameKey="tabName" tabs={actualTabs} />
</div>
<main className="w-full xl:mx-5 xl:w-4/5 xl:pr-5">{children}</main>
</div>
</Shell>
);
}
export const getLayout = (page: React.ReactElement) => <InstalledAppsLayout>{page}</InstalledAppsLayout>;
@@ -6,6 +6,8 @@ import { MouseEventHandler } from "react";
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { SkeletonText } from "../../skeleton";
export type HorizontalTabItemProps<T extends string = "tabName"> = {
name: string;
disabled?: boolean;
@@ -28,7 +30,7 @@ const HorizontalTabItem = function <T extends string>({
tabNameKey?: T;
}) {
const router = useRouter();
const { t } = useLocale();
const { t, isLocaleReady } = useLocale();
let newHref = "";
let isCurrent;
const _tabNameKey = tabNameKey || "tabName";
@@ -36,7 +38,7 @@ const HorizontalTabItem = function <T extends string>({
if (href) {
newHref = href;
isCurrent = router.asPath === href;
isCurrent = router.asPath.startsWith(href);
} else if (tabName) {
newHref = "";
isCurrent = router.query[_tabNameKey] === tabName;
@@ -65,7 +67,7 @@ const HorizontalTabItem = function <T extends string>({
props.className
)}
aria-current={isCurrent ? "page" : undefined}>
{t(name)}
{isLocaleReady ? t(name) : <SkeletonText className="h-4 w-24" />}
</a>
</Link>
);
@@ -50,7 +50,7 @@ const VerticalTabItem = function <T extends string>({
const _tabNameKey = tabNameKey || "tabName";
if (href) {
newHref = href;
isCurrent = router.asPath === href;
isCurrent = router.asPath.startsWith(href);
} else if (tabName) {
newHref = "";
isCurrent = router.query[_tabNameKey] === tabName;
+7 -3
View File
@@ -14,12 +14,16 @@ const SkeletonAvatar: React.FC<SkeletonBaseProps> = ({ className }) => {
return <div className={classNames(`mt-1 rounded-full bg-gray-200 ltr:mr-2 rtl:ml-2`, className)} />;
};
const SkeletonText: React.FC<SkeletonBaseProps> = ({ className = "" }) => {
const SkeletonText: React.FC<SkeletonBaseProps & { invisible?: boolean }> = ({
className = "",
invisible = false,
}) => {
return (
<span
className={classNames(
`font-size-0 dark:white-300 inline-block animate-pulse rounded-md bg-gray-300 empty:before:inline-block empty:before:content-['']`,
className
className,
invisible ? "invisible" : ""
)}
/>
);
@@ -28,7 +32,7 @@ const SkeletonText: React.FC<SkeletonBaseProps> = ({ className = "" }) => {
const SkeletonButton: React.FC<SkeletonBaseProps> = ({ className }) => {
return (
<SkeletonContainer>
<div className={classNames(`bg-gray-200`, className)} />
<div className={classNames(`rounded-md bg-gray-200`, className)} />
</SkeletonContainer>
);
};
@@ -12,12 +12,14 @@ export default function DisconnectIntegration({
label,
trashIcon,
isGlobal,
onSuccess,
buttonProps,
}: {
credentialId: number;
label?: string;
trashIcon?: boolean;
isGlobal?: boolean;
onSuccess?: () => void;
buttonProps?: ButtonProps;
}) {
const { t } = useLocale();
@@ -25,11 +27,12 @@ export default function DisconnectIntegration({
const mutation = trpc.useMutation("viewer.deleteCredential", {
onSuccess: () => {
showToast("Integration deleted successfully", "success");
showToast(t("app_removed_successfully"), "success");
setModalOpen(false);
onSuccess && onSuccess();
},
onError: () => {
showToast("Error deleting app", "error");
showToast(t("error_removing_app"), "error");
setModalOpen(false);
},
});
@@ -41,16 +44,17 @@ export default function DisconnectIntegration({
<Button
color={buttonProps?.color || "destructive"}
StartIcon={trashIcon ? Icon.FiTrash : undefined}
size={trashIcon && !label ? "icon" : "base"}
disabled={isGlobal}
{...buttonProps}>
{label}
{label && label}
</Button>
</DialogTrigger>
<DialogContent
title="Remove app"
description="Are you sure you want to remove this app?"
title={t("remove_app")}
description={t("are_you_sure_you_want_to_remove_this_app")}
type="confirmation"
actionText="Yes, remove app"
actionText={t("yes_remove_app")}
Icon={Icon.FiAlertCircle}
actionOnClick={() => mutation.mutate({ id: credentialId })}
/>