refactor: Cal.diy (#28903)

* feat: Cal.diy — community-driven MIT-licensed fork of Cal.com

This squashed commit contains all Cal.diy changes applied on top of calcom/cal.com main:

- Rebrand Cal.com to Cal.diy across the entire codebase
- Remove Enterprise Edition (EE) features, license checks, and AGPL restrictions
- Switch license from AGPL-3.0 to MIT
- Remove docs/ directory (migrated to Nextra at cal.diy)
- Remove dead code: org tests, EE tips, platform nav, premium username, SAML/SSO, etc.
- Clean up .env.example for self-hosted Cal.diy
- Update Docker image references to calcom/cal.diy
- Update README, CONTRIBUTING.md, and issue templates for Cal.diy community fork
- Add PR welcome bot for Cal.diy contributors
- Fix API v2 breaking changes oasdiff ignore entries
- Replace Blacksmith CI runners with default GitHub Actions

3893 files changed, 20789 insertions(+), 411020 deletions(-)

Co-Authored-By: [email protected] <[email protected]>

* refactor: remove org-specific /organizations/:orgId endpoints from API v2 atoms controllers (#1701)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix: revert Cal.diy Inc to Cal.com, Inc. in license files, copyright notices, and package metadata (#1702)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* rip out org related comments in api v2

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Benny JooandDevin AI authored and GitHub committed 2026-04-15 09:52:36 -03:00
1 parent a17f28e9ab
commit ab21c7f805
4080 files changed
+14403 -404922

No files matched your search

@@ -1,32 +1,29 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { useSession } from "next-auth/react";
import type { Dispatch } from "react";
import { useMemo, useState } from "react";
import { Controller, useForm, useFormContext } from "react-hook-form";
import { z } from "zod";
import { TimezoneSelect } from "@calcom/web/modules/timezone/components/TimezoneSelect";
import { timeZoneSchema } from "@calcom/lib/dayjs/timeZone.schema";
import { emailSchema } from "@calcom/lib/emailSchema";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { MembershipRole } from "@calcom/prisma/enums";
import { trpc, type RouterOutputs } from "@calcom/trpc/react";
import { trpc } from "@calcom/trpc/react";
import { Avatar } from "@calcom/ui/components/avatar";
import { Button } from "@calcom/ui/components/button";
import { Divider } from "@calcom/ui/components/divider";
import {
InputField,
TextAreaField,
SelectField,
Form,
Label,
SelectField,
TextAreaField,
TextField,
ToggleGroup,
} from "@calcom/ui/components/form";
import { ImageUploader } from "@calcom/ui/components/image-uploader";
import { SheetHeader, SheetBody, SheetFooter, SheetTitle } from "@calcom/ui/components/sheet";
import { SheetBody, SheetFooter, SheetHeader, SheetTitle } from "@calcom/ui/components/sheet";
import { showToast } from "@calcom/ui/components/toast";
import { TimezoneSelect } from "@calcom/web/modules/timezone/components/TimezoneSelect";
import { zodResolver } from "@hookform/resolvers/zod";
import { useSession } from "next-auth/react";
import type { Dispatch } from "react";
import { useMemo, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { z } from "zod";
import type { UserTableAction } from "../types";
import { useEditMode } from "./store";
@@ -36,23 +33,6 @@ interface MembershipOption {
isCustomRole?: boolean;
}
const stringOrNumber = z.string().or(z.number());
const attributeSchema = z.object({
id: z.string(),
options: z
.array(
z.object({
label: z.string().optional(),
value: stringOrNumber.optional(),
weight: z.number().optional(),
createdByDSyncId: z.string().nullable().optional(),
})
)
.optional(),
value: stringOrNumber.optional(),
});
const editSchema = z.object({
name: z.string(),
username: z.string(),
@@ -61,7 +41,6 @@ const editSchema = z.object({
bio: z.string(),
role: z.union([z.nativeEnum(MembershipRole), z.string()]),
timeZone: timeZoneSchema,
attributes: z.array(attributeSchema).optional(),
});
type EditSchema = z.infer<typeof editSchema>;
@@ -71,13 +50,11 @@ export function EditForm({
avatarUrl,
domainUrl,
dispatch,
canEditAttributesForUser,
}: {
selectedUser: RouterOutputs["viewer"]["organizations"]["getUser"];
selectedUser: Record<string, unknown>;
avatarUrl: string;
domainUrl: string;
dispatch: Dispatch<UserTableAction>;
canEditAttributesForUser?: boolean;
}) {
const setEditMode = useEditMode((state) => state.setEditMode);
const [mutationLoading, setMutationLoading] = useState(false);
@@ -88,26 +65,18 @@ export function EditForm({
const form = useForm<EditSchema>({
resolver: zodResolver(editSchema),
defaultValues: {
name: selectedUser?.name ?? "",
username: selectedUser?.username ?? "",
email: selectedUser?.email ?? "",
name: (selectedUser?.name as string) ?? "",
username: (selectedUser?.username as string) ?? "",
email: (selectedUser?.email as string) ?? "",
avatar: avatarUrl,
bio: selectedUser?.bio ?? "",
role: selectedUser?.role ?? "",
timeZone: selectedUser?.timeZone ?? "",
bio: (selectedUser?.bio as string) ?? "",
role: (selectedUser?.role as string) ?? "",
timeZone: (selectedUser?.timeZone as string) ?? "",
},
});
const isOwner = org?.role === MembershipRole.OWNER;
const { data: teamRoles, isLoading: isLoadingRoles } = trpc.viewer.pbac.getTeamRoles.useQuery(
// @ts-expect-error this query is only ran when we have an orgId so can ignore this
{ teamId: org?.id },
{
enabled: !!org?.id, // Only enable the query when we have a valid team ID
staleTime: 30000, // Cache for 30 seconds
}
);
const teamRoles: { id: string; name: string }[] = [];
const membershipOptions = useMemo<MembershipOption[]>(() => {
// Add custom roles if they exist
@@ -146,23 +115,7 @@ export function EditForm({
return options;
}, [t, isOwner, teamRoles]);
const mutation = trpc.viewer.organizations.updateUser.useMutation({
onSuccess: () => {
dispatch({ type: "CLOSE_MODAL" });
utils.viewer.organizations.listMembers.invalidate();
showToast(t("profile_updated_successfully"), "success");
},
onError: (error) => {
showToast(error.message, "error");
},
onSettled: () => {
/**
* /We need to do this as the submit button lives out side
* the form for some complicated reason so we can't relay on mutationState
*/
setMutationLoading(false);
},
});
const mutation = { mutate: (..._args: unknown[]) => {}, mutateAsync: async () => ({}), isPending: false };
const watchTimezone = form.watch("timeZone");
@@ -171,22 +124,9 @@ export function EditForm({
<Form
form={form}
className="flex h-full flex-col"
handleSubmit={(values) => {
handleSubmit={() => {
setMutationLoading(true);
mutation.mutate({
userId: selectedUser?.id ?? "",
role: values.role as MembershipRole,
username: values.username,
name: values.name,
email: values.email,
avatar: values.avatar,
bio: values.bio,
timeZone: values.timeZone,
// @ts-expect-error they're there in local types but for some reason it errors?
attributeOptions: values.attributes
? { userId: selectedUser?.id ?? "", attributes: values.attributes }
: undefined,
});
setMutationLoading(false);
setEditMode(false);
}}>
<SheetHeader>
@@ -226,11 +166,11 @@ export function EditForm({
{teamRoles?.length > 0 ? (
<SelectField
defaultValue={membershipOptions.find(
(option) => option.value === (selectedUser?.role ?? "MEMBER")
(option) => option.value === ((selectedUser?.role as string) ?? "MEMBER")
)}
value={membershipOptions.find((option) => option.value === form.watch("role"))}
options={membershipOptions}
onChange={(option) => {
onChange={(option: MembershipOption | null) => {
if (option) {
form.setValue("role", option.value);
}
@@ -239,7 +179,7 @@ export function EditForm({
) : (
<ToggleGroup
isFullWidth
defaultValue={selectedUser?.role ?? "MEMBER"}
defaultValue={(selectedUser?.role as string) ?? "MEMBER"}
value={form.watch("role")}
options={membershipOptions}
onValueChange={(value) => {
@@ -253,13 +193,6 @@ export function EditForm({
<TimezoneSelect value={watchTimezone ?? "America/Los_Angeles"} />
</div>
</div>
{canEditAttributesForUser && (
<>
<Divider />
<AttributesList selectedUserId={selectedUser?.id} />
</>
)}
</SheetBody>
<SheetFooter>
<Button
@@ -280,226 +213,3 @@ export function EditForm({
</>
);
}
type Attribute = z.infer<typeof attributeSchema>;
type DefaultValueType = {
[key: `attributes.${number}`]: Attribute;
};
function AttributesList(props: { selectedUserId: number }) {
const { data: usersAttributes, isPending: usersAttributesPending } =
trpc.viewer.attributes.getByUserId.useQuery({
userId: props.selectedUserId,
});
const { data: attributes } = trpc.viewer.attributes.list.useQuery();
const enabledAttributes = attributes?.filter((attr) => attr.enabled);
const { t } = useLocale();
const { control, getFieldState } = useFormContext();
const getOptionsByAttributeId = (attributeId: string) => {
const attribute = attributes?.find((attr) => attr.id === attributeId);
return attribute
? attribute.options.map((option) => ({
value: option.id,
label: option.value,
}))
: [];
};
const defaultValues = useMemo<DefaultValueType>(() => {
if (!usersAttributes || usersAttributesPending || !enabledAttributes) return {};
return enabledAttributes.reduce<DefaultValueType>((acc, enabledAttr, index) => {
const attr = usersAttributes.find((attr) => attr.id === enabledAttr.id);
const key = `attributes.${index}` as const;
if (!attr) {
acc[key] = { id: enabledAttr.id, value: "", options: [] };
} else if (attr.type === "MULTI_SELECT") {
acc[key] = {
id: attr.id,
options: attr.options.map((option) => ({
label: option.value,
value: option.id,
createdByDSyncId: option.createdByDSyncId ?? null,
weight: option.weight ?? 100,
})),
};
} else if (attr.type === "SINGLE_SELECT") {
acc[key] = {
id: attr.id,
options: [
{
label: attr.options[0]?.value,
value: attr.options[0]?.id,
createdByDSyncId: attr.options[0]?.createdByDSyncId ?? null,
weight: attr.options[0]?.weight ?? 100,
},
],
};
} else if (attr.type === "TEXT") {
acc[key] = {
id: attr.id,
value: attr.options[0]?.value || "",
};
}
return acc;
}, {});
}, [usersAttributes, usersAttributesPending, enabledAttributes]);
if (!enabledAttributes || !usersAttributes) return null;
const attributeFieldState = getFieldState("attributes");
return (
<div className="flex flex-col overflow-visible">
<div className="flex flex-col gap-3 rounded-lg">
{attributeFieldState.error && (
<p className="text-error mb-2 block text-sm font-medium leading-none">
{JSON.stringify(attributeFieldState.error)}
</p>
)}
{enabledAttributes.map((attr, index) => (
<Controller
name={`attributes.${index}`}
control={control}
key={attr.id}
defaultValue={defaultValues[`attributes.${index}`]}
render={({ field: { value, ...field } }) => {
const fieldValue = value as Attribute | undefined | null;
return (
<div className="flex w-full items-center justify-center" key={attr.id}>
{["TEXT", "NUMBER"].includes(attr.type) && (
<InputField
{...field}
containerClassName="w-full"
labelClassName="text-emphasis mb-2 block text-sm font-medium leading-none"
label={attr.name}
type={attr.type === "TEXT" ? "text" : "number"}
value={fieldValue?.value || ""}
onChange={(e) => {
field.onChange({
id: attr.id,
value: e.target.value,
});
}}
/>
)}
{["SINGLE_SELECT", "MULTI_SELECT"].includes(attr.type) && (
<div className="w-full">
<SelectField
isDisabled={attr.isLocked}
name={field.name}
containerClassName="w-full"
isMulti={attr.type === "MULTI_SELECT"}
labelProps={{
className: "text-emphasis mb-2 block text-sm font-medium leading-none",
}}
label={attr.name}
options={getOptionsByAttributeId(attr.id)}
value={attr.type === "MULTI_SELECT" ? fieldValue?.options : fieldValue?.options?.[0]}
onChange={(value) => {
if (!value) return;
const valueAsArray = value instanceof Array ? value : [value];
const updatedOptions =
attr.type === "MULTI_SELECT"
? valueAsArray.map((v) => ({
label: v.label,
value: v.value,
weight: v.weight || 100,
}))
: [
{
label: valueAsArray[0].label,
value: valueAsArray[0].value,
weight: valueAsArray[0].weight || 100,
},
];
field.onChange({
id: attr.id,
options: getOptionsEnsuringNotOwnedByCalcomNotRemoved({
earlierOptions: fieldValue?.options || [],
updatedOptions,
}),
});
}}
/>
{attr.isWeightsEnabled && fieldValue?.options && (
<div className="mt-3 stack-y-2">
<Label>Weights</Label>
<div className="">
{fieldValue.options.map((option, idx) => {
return (
<>
<div key={option.value} className="flex items-center justify-between">
<Label
htmlFor={`attributes.${index}.options.${idx}.weight`}
className="text-subtle">
{option.label}
</Label>
<InputField
noLabel
name={`attributes.${index}.options.${idx}.weight`}
type="number"
step={10}
value={option.weight || 100}
onChange={(e) => {
const newWeight = parseFloat(e.target.value) || 1;
const newOptions = fieldValue?.options?.map((opt, i) =>
i === idx ? { ...opt, weight: newWeight } : opt
);
field.onChange({
id: attr.id,
options: newOptions,
});
}}
addOnSuffix={<span className="text-subtle text-sm">%</span>}
/>
</div>
</>
);
})}
</div>
</div>
)}
</div>
)}
</div>
);
}}
/>
))}
</div>
</div>
);
}
/**
* Ensures that options that are not owned by cal.com are not removed
* Such options are created by dsync and removed only through corresponding dsync
*/
function getOptionsEnsuringNotOwnedByCalcomNotRemoved<
// Before assigning this option it can't have createdByDSyncId set
TOptionToChoose extends { value: string | number | undefined },
// Already set option can have createdByDSyncId set
TOptionAlreadySet extends {
value?: string | number | undefined;
createdByDSyncId?: string | null | undefined;
},
>({
earlierOptions,
updatedOptions,
}: {
earlierOptions: TOptionAlreadySet[];
updatedOptions: TOptionToChoose[];
}) {
const optionsNotOwnedByCalcom = earlierOptions.filter((option) => !!option.createdByDSyncId);
const newUniqueOptionsPlusNotOwnedByCalcom = [...optionsNotOwnedByCalcom, ...updatedOptions].filter(
(option, index, self) => index === self.findIndex((o) => o.value === option.value && o.value)
);
return newUniqueOptionsPlusNotOwnedByCalcom;
}
@@ -1,14 +1,11 @@
import type { Dispatch } from "react";
import { shallow } from "zustand/shallow";
import { useOrgBranding } from "@calcom/ee/organizations/context/provider";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { Avatar } from "@calcom/ui/components/avatar";
import { Sheet, SheetContent, SheetBody, SheetHeader, SheetFooter } from "@calcom/ui/components/sheet";
import { Sheet, SheetBody, SheetContent, SheetFooter, SheetHeader } from "@calcom/ui/components/sheet";
import { Loader } from "@calcom/ui/components/skeleton";
import type { Dispatch } from "react";
import { shallow } from "zustand/shallow";
import type { UserTableAction, UserTableState } from "../types";
import { DisplayInfo } from "./DisplayInfo";
import { EditForm } from "./EditUserForm";
@@ -35,34 +32,29 @@ export function EditUserSheet({
}) {
const { t } = useLocale();
const { user: selectedUser } = state.editSheet;
const orgBranding = useOrgBranding();
const [editMode, setEditMode] = useEditMode((state) => [state.editMode, state.setEditMode], shallow);
const { data: loadedUser, isPending } = trpc.viewer.organizations.getUser.useQuery(
{
userId: selectedUser?.id,
},
{
enabled: !!selectedUser?.id,
}
const loadedUser = selectedUser as
| (typeof selectedUser & {
schedules?: { name: string }[];
teams?: { name: string; accepted: boolean }[];
bio?: string;
avatarUrl?: string | null;
role?: string;
timeZone?: string;
email?: string;
username?: string;
})
| undefined;
type TeamWithAccepted = { name: string; accepted: boolean };
const avatarURL = `${WEBAPP_URL}/${loadedUser?.username}/avatar.png`;
const schedulesNames = loadedUser?.schedules?.map((s) => s.name);
const teamNames = (loadedUser?.teams as TeamWithAccepted[] | undefined)?.map(
(t) => `${t.name} ${!t.accepted ? "(pending)" : ""}`
);
const { data: usersAttributes, isPending: usersAttributesPending } =
trpc.viewer.attributes.getByUserId.useQuery(
{
// @ts-expect-error We know it exists as it is only called when selectedUser is defined
userId: selectedUser?.id,
},
{
enabled: !!selectedUser?.id && !!canViewAttributes,
}
);
const avatarURL = `${orgBranding?.fullDomain ?? WEBAPP_URL}/${loadedUser?.username}/avatar.png`;
const schedulesNames = loadedUser?.schedules && loadedUser?.schedules.map((s) => s.name);
const teamNames =
loadedUser?.teams && loadedUser?.teams.map((t) => `${t.name} ${!t.accepted ? "(pending)" : ""}`);
return (
<Sheet
open={true}
@@ -71,89 +63,62 @@ export function EditUserSheet({
dispatch({ type: "CLOSE_MODAL" });
}}>
<SheetContent className="bg-default">
{!isPending && loadedUser ? (
<>
{!editMode ? (
<>
<SheetHeader showCloseButton={false} className="w-full">
<div className="border-subtle bg-default w-full rounded-xl border p-4">
<OrganizationBanner />
<div className="bg-default ml-3 w-fit translate-y-[-50%] rounded-full p-1 ring-1 ring-[#0000000F]">
<Avatar asChild size="lg" alt={`${loadedUser?.name} avatar`} imageSrc={avatarURL} />
</div>
<h2 className="text-emphasis font-sans text-2xl font-semibold -mt-8">
{loadedUser?.name || "Nameless User"}
</h2>
<p className="text-subtle max-h-[3em] overflow-hidden text-ellipsis text-sm font-normal">
{loadedUser?.bio || "This user does not have a bio..."}
</p>
{loadedUser ? (
!editMode ? (
<>
<SheetHeader showCloseButton={false} className="w-full">
<div className="w-full rounded-xl border border-subtle bg-default p-4">
<OrganizationBanner />
<div className="ml-3 w-fit translate-y-[-50%] rounded-full bg-default p-1 ring-1 ring-[#0000000F]">
<Avatar asChild size="lg" alt={`${loadedUser?.name} avatar`} imageSrc={avatarURL} />
</div>
</SheetHeader>
<SheetBody className="stack-y-4 flex flex-col p-4">
<div className="stack-y-4 mb-4 flex flex-col">
<h3 className="text-emphasis mb-1 text-base font-semibold">{t("profile")}</h3>
<DisplayInfo
label="Cal"
value={removeProtocol(
`${orgBranding?.fullDomain ?? WEBAPP_URL}/${loadedUser?.username}`
)}
icon="external-link"
/>
<DisplayInfo label={t("email")} value={loadedUser?.email ?? ""} icon="at-sign" />
<DisplayInfo label={t("role")} value={[loadedUser?.role ?? ""]} icon="fingerprint" />
<DisplayInfo label={t("timezone")} value={loadedUser?.timeZone ?? ""} icon="clock" />
<DisplayInfo
label={t("teams")}
value={!teamNames || teamNames.length === 0 ? "" : teamNames}
icon="users"
coloredBadges
/>
<DisplayInfo
label={t("availability")}
value={!schedulesNames || schedulesNames.length === 0 ? "" : schedulesNames}
icon="calendar"
/>
</div>
{canViewAttributes && usersAttributes && usersAttributes?.length > 0 && (
<div className="mt-4 flex flex-col">
<h3 className="text-emphasis mb-5 text-base font-semibold">{t("attributes")}</h3>
<div className="stack-y-4 flex flex-col">
{usersAttributes.map((attribute, index) => (
<>
<DisplayInfo
key={index}
label={attribute.name}
value={
["TEXT", "NUMBER", "SINGLE_SELECT"].includes(attribute.type)
? attribute.options[0].value
: attribute.options.map((option) => option.value)
}
/>
</>
))}
</div>
</div>
)}
</SheetBody>
<SheetFooter>
<SheetFooterControls
canEditAttributesForUser={canEditAttributesForUser}
canChangeMemberRole={canChangeMemberRole}
<h2 className="-mt-8 font-sans font-semibold text-2xl text-emphasis">
{loadedUser?.name || "Nameless User"}
</h2>
<p className="max-h-[3em] overflow-hidden text-ellipsis font-normal text-sm text-subtle">
{loadedUser?.bio || "This user does not have a bio..."}
</p>
</div>
</SheetHeader>
<SheetBody className="stack-y-4 flex flex-col p-4">
<div className="stack-y-4 mb-4 flex flex-col">
<h3 className="mb-1 font-semibold text-base text-emphasis">{t("profile")}</h3>
<DisplayInfo
label="Cal"
value={removeProtocol(`${WEBAPP_URL}/${loadedUser?.username}`)}
icon="external-link"
/>
</SheetFooter>
</>
) : (
<>
<EditForm
selectedUser={loadedUser}
avatarUrl={loadedUser.avatarUrl ?? avatarURL}
domainUrl={orgBranding?.fullDomain ?? WEBAPP_URL}
dispatch={dispatch}
<DisplayInfo label={t("email")} value={loadedUser?.email ?? ""} icon="at-sign" />
<DisplayInfo label={t("role")} value={[loadedUser?.role ?? ""]} icon="fingerprint" />
<DisplayInfo label={t("timezone")} value={loadedUser?.timeZone ?? ""} icon="clock" />
<DisplayInfo
label={t("teams")}
value={!teamNames || teamNames.length === 0 ? "" : teamNames}
icon="users"
coloredBadges
/>
<DisplayInfo
label={t("availability")}
value={!schedulesNames || schedulesNames.length === 0 ? "" : schedulesNames}
icon="calendar"
/>
</div>
</SheetBody>
<SheetFooter>
<SheetFooterControls
canEditAttributesForUser={canEditAttributesForUser}
canChangeMemberRole={canChangeMemberRole}
/>
</>
)}
</>
</SheetFooter>
</>
) : (
<EditForm
selectedUser={loadedUser}
avatarUrl={loadedUser.avatarUrl ?? avatarURL}
domainUrl={WEBAPP_URL}
dispatch={dispatch}
/>
)
) : (
<Loader />
)}
@@ -1,24 +1,11 @@
import { trpc } from "@calcom/trpc/react";
export function OrganizationBanner() {
const {
data: currentOrganisation,
isPending: isPendingOrg,
error,
} = trpc.viewer.organizations.listCurrent.useQuery(undefined, {});
return (
<>
<div
className="block w-full rounded-lg ring-1 ring-[#0000000F]"
style={{
background: "linear-gradient(to top right, var(--cal-bg-emphasis), var(--cal-bg))",
height: currentOrganisation && currentOrganisation?.bannerUrl ? "auto" : "110px",
}}>
{currentOrganisation && currentOrganisation?.bannerUrl && (
<img src={currentOrganisation?.bannerUrl} alt="Organization Banner" className="rounded-lg" />
)}
</div>
</>
<div
className="block w-full rounded-lg ring-1 ring-[#0000000F]"
style={{
background: "linear-gradient(to top right, var(--cal-bg-emphasis), var(--cal-bg))",
height: "110px",
}}
/>
);
}