refactor: remove @calcom/features dependency to @calcom/web (#13365)

* refactor: remove @calcom/features dependency to @calcom/web

* refactor: remove IS_VISUAL_REGRESSION_TESTING from web

* fix: wrong imports

---------

Co-authored-by: Omar López <[email protected]>
This commit is contained in:
MorganandOmar López authored and GitHub committed 2024-01-23 17:17:36 +00:00
1 parent 7058da70e6
commit 4417d649ea
24 files changed
+52 -36

No files matched your search

@@ -2,7 +2,7 @@ import jwt from "jsonwebtoken";
import type { NextApiRequest } from "next";
import prisma from "@calcom/prisma";
import type { OAuthTokenPayload } from "@calcom/web/pages/api/auth/oauth/token";
import type { OAuthTokenPayload } from "@calcom/types/oauth";
export default async function isAuthorized(req: NextApiRequest, requiredScopes: string[] = []) {
const token = req.headers.authorization?.split(" ")[1] || "";
@@ -1,8 +1,7 @@
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { SchedulingType } from "@calcom/prisma/enums";
import { type RouterOutputs } from "@calcom/trpc";
import { Button } from "@calcom/ui";
import { UserAvatarGroupWithOrg } from "@calcom/web/components/ui/avatar/UserAvatarGroupWithOrg";
import { Button, UserAvatarGroupWithOrg } from "@calcom/ui";
interface IInstantBookingProps {
onConnectNow: () => void;
@@ -1,6 +1,5 @@
import { SchedulingType } from "@calcom/prisma/enums";
import { UserAvatarGroup } from "@calcom/web/components/ui/avatar/UserAvatarGroup";
import { UserAvatarGroupWithOrg } from "@calcom/web/components/ui/avatar/UserAvatarGroupWithOrg";
import { UserAvatarGroup, UserAvatarGroupWithOrg } from "@calcom/ui";
import type { PublicEvent } from "../../types";
@@ -19,8 +19,8 @@ import {
InputField,
CheckboxField,
} from "@calcom/ui";
import { InfoBadge } from "@calcom/ui";
import { UserPlus, X } from "@calcom/ui/components/icon";
import InfoBadge from "@calcom/web/components/ui/InfoBadge";
import { ComponentForField } from "./FormBuilderField";
import { propsTypes } from "./propsTypes";
@@ -5,9 +5,8 @@ import type { z } from "zod";
import { classNames } from "@calcom/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Label } from "@calcom/ui";
import { Label, InfoBadge } from "@calcom/ui";
import { Info } from "@calcom/ui/components/icon";
import InfoBadge from "@calcom/web/components/ui/InfoBadge";
import { Components, isValidValueProp } from "./Components";
import { fieldTypesConfigMap } from "./fieldTypes";
@@ -2,10 +2,10 @@ import { useSession } from "next-auth/react";
import { useEffect, useState } from "react";
import dayjs from "@calcom/dayjs";
import { IS_VISUAL_REGRESSION_TESTING } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { Dialog, DialogClose, DialogContent, DialogFooter, showToast } from "@calcom/ui";
import { IS_VISUAL_REGRESSION_TESTING } from "@calcom/web/constants";
export default function TimezoneChangeDialog() {
const { t } = useLocale();
+9 -3
View File
@@ -33,8 +33,15 @@ import VerifyEmailBanner, {
type VerifyEmailBannerProps,
} from "@calcom/features/users/components/VerifyEmailBanner";
import classNames from "@calcom/lib/classNames";
import { TOP_BANNER_HEIGHT } from "@calcom/lib/constants";
import { APP_NAME, DESKTOP_APP_LINK, JOIN_DISCORD, ROADMAP, WEBAPP_URL } from "@calcom/lib/constants";
import {
APP_NAME,
DESKTOP_APP_LINK,
JOIN_DISCORD,
ROADMAP,
WEBAPP_URL,
IS_VISUAL_REGRESSION_TESTING,
TOP_BANNER_HEIGHT,
} from "@calcom/lib/constants";
import getBrandColours from "@calcom/lib/getBrandColours";
import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
import { useLocale } from "@calcom/lib/hooks/useLocale";
@@ -88,7 +95,6 @@ import {
Zap,
} from "@calcom/ui/components/icon";
import { Discord } from "@calcom/ui/components/icon/Discord";
import { IS_VISUAL_REGRESSION_TESTING } from "@calcom/web/constants";
import { useOrgBranding } from "../ee/organizations/context/provider";
import FreshChatProvider from "../ee/support/lib/freshchat/FreshChatProvider";
+2
View File
@@ -126,3 +126,5 @@ export const IS_PREMIUM_USERNAME_ENABLED =
export const MAX_NB_INVITES = 100;
export const URL_PROTOCOL_REGEX = /(^\w+:|^)\/\//;
export const IS_VISUAL_REGRESSION_TESTING = Boolean(globalThis.window?.Meticulous?.isRunningAsTest);
+1 -1
View File
@@ -5,6 +5,6 @@
"jsx": "preserve",
"resolveJsonModule": true
},
"include": [".", "../types/next-auth.d.ts"],
"include": [".", "../types/next-auth.d.ts", "../types/window.d.ts"],
"exclude": ["dist", "build", "node_modules"]
}
+7
View File
@@ -0,0 +1,7 @@
export type OAuthTokenPayload = {
userId?: number | null;
teamId?: number | null;
token_type: string;
scope: string[];
clientId: string;
};
@@ -0,0 +1,22 @@
import { CAL_URL } from "@calcom/lib/constants";
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
import type { User } from "@calcom/prisma/client";
import { AvatarGroup } from "@calcom/ui";
type UserAvatarProps = Omit<React.ComponentProps<typeof AvatarGroup>, "items"> & {
users: Pick<User, "organizationId" | "name" | "username">[];
};
export function UserAvatarGroup(props: UserAvatarProps) {
const { users, ...rest } = props;
return (
<AvatarGroup
{...rest}
items={users.map((user) => ({
href: `${CAL_URL}/${user.username}?redirect=false`,
alt: user.name || "",
title: user.name || "",
image: getUserAvatarUrl(user),
}))}
/>
);
}
@@ -0,0 +1,32 @@
import { WEBAPP_URL } from "@calcom/lib/constants";
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
import { getBookerBaseUrlSync } from "@calcom/lib/getBookerUrl/client";
import type { Team, User } from "@calcom/prisma/client";
import { AvatarGroup } from "@calcom/ui";
type UserAvatarProps = Omit<React.ComponentProps<typeof AvatarGroup>, "items"> & {
users: (Pick<User, "organizationId" | "name" | "username"> & { bookerUrl: string })[];
organization: Pick<Team, "slug" | "name">;
};
export function UserAvatarGroupWithOrg(props: UserAvatarProps) {
const { users, organization, ...rest } = props;
const items = [
{
href: getBookerBaseUrlSync(organization.slug),
image: `${WEBAPP_URL}/team/${organization.slug}/avatar.png`,
alt: organization.name || undefined,
title: organization.name,
},
].concat(
users.map((user) => {
return {
href: `${user.bookerUrl}/${user.username}?redirect=false`,
image: getUserAvatarUrl(user),
alt: user.name || undefined,
title: user.name || user.username || "",
};
})
);
return <AvatarGroup {...rest} items={items} />;
}
+2
View File
@@ -2,4 +2,6 @@ export { Avatar } from "./Avatar";
export { UserAvatar } from "./UserAvatar";
export type { AvatarProps } from "./Avatar";
export { AvatarGroup } from "./AvatarGroup";
export { UserAvatarGroup } from "./UserAvatarGroup";
export { UserAvatarGroupWithOrg } from "./UserAvatarGroupWithOrg";
export type { AvatarGroupProps } from "./AvatarGroup";
@@ -0,0 +1,14 @@
import { Info } from "../icon";
import { Tooltip } from "../tooltip/Tooltip";
export function InfoBadge({ content }: { content: string }) {
return (
<>
<Tooltip side="top" content={content}>
<span title={content}>
<Info className="text-subtle relative left-1 right-1 top-px mt-px h-4 w-4" />
</span>
</Tooltip>
</>
);
}
+1 -1
View File
@@ -1,5 +1,5 @@
export { Badge } from "./Badge";
export { UpgradeTeamsBadge } from "./UpgradeTeamsBadge";
export { UpgradeOrgsBadge } from "./UpgradeOrgsBadge";
export { InfoBadge } from "./InfoBadge";
export type { BadgeProps } from "./Badge";
+8 -2
View File
@@ -1,8 +1,14 @@
export { Avatar, AvatarGroup, UserAvatar } from "./components/avatar";
export {
Avatar,
AvatarGroup,
UserAvatar,
UserAvatarGroup,
UserAvatarGroupWithOrg,
} from "./components/avatar";
export type { AvatarProps, AvatarGroupProps } from "./components/avatar";
export { ArrowButton } from "./components/arrow-button";
export type { ArrowButtonProps } from "./components/arrow-button";
export { Badge, UpgradeTeamsBadge } from "./components/badge";
export { Badge, UpgradeTeamsBadge, InfoBadge } from "./components/badge";
export type { BadgeProps } from "./components/badge";
export { Breadcrumb, BreadcrumbContainer, BreadcrumbItem } from "./components/breadcrumb";
export { Button, LinkIconButton } from "./components/button";