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:
1 parent
a17f28e9ab
commit
ab21c7f805
4080 files changed
+14403
-404922
No files matched your search
@@ -2,16 +2,11 @@
|
||||
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import { ColumnFilterType, convertFacetedValuesToMap, type FacetedValue } from "@calcom/features/data-table";
|
||||
import { DataTableProvider } from "~/data-table/DataTableProvider";
|
||||
import { useColumnFilters } from "~/data-table/hooks/useColumnFilters";
|
||||
import { useDataTable } from "~/data-table/hooks/useDataTable";
|
||||
import { useSegments } from "~/data-table/hooks/useSegments";
|
||||
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
|
||||
import type { MemberPermissions } from "@calcom/features/pbac/lib/team-member-permissions";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { downloadAsCsv } from "@calcom/lib/csvUtils";
|
||||
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { FilterType } from "@calcom/types/data-table";
|
||||
@@ -20,7 +15,6 @@ import { Avatar } from "@calcom/ui/components/avatar";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
import { Checkbox } from "@calcom/ui/components/form";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import { useGetUserAttributes } from "@calcom/web/components/settings/platform/hooks/useGetUserAttributes";
|
||||
import { LimitedBadges } from "@calcom/web/components/ui/LimitedBadges";
|
||||
import {
|
||||
generateCsvRawForMembersTable,
|
||||
@@ -48,15 +42,16 @@ import {
|
||||
DataTableToolbar,
|
||||
DataTableWrapper,
|
||||
} from "~/data-table/components";
|
||||
import { DataTableProvider } from "~/data-table/DataTableProvider";
|
||||
import { useColumnFilters } from "~/data-table/hooks/useColumnFilters";
|
||||
import { useDataTable } from "~/data-table/hooks/useDataTable";
|
||||
import { useSegments } from "~/data-table/hooks/useSegments";
|
||||
import { DeleteBulkUsers } from "./BulkActions/DeleteBulkUsers";
|
||||
import { DynamicLink } from "./BulkActions/DynamicLink";
|
||||
import { EventTypesList } from "./BulkActions/EventTypesList";
|
||||
import { MassAssignAttributesBulkAction } from "./BulkActions/MassAssignAttributes";
|
||||
import { TeamListBulkAction } from "./BulkActions/TeamList";
|
||||
import { ChangeUserRoleModal } from "./ChangeUserRoleModal";
|
||||
import { DeleteMemberModal } from "./DeleteMemberModal";
|
||||
import { EditUserSheet } from "./EditSheet/EditUserSheet";
|
||||
import { ImpersonationMemberModal } from "./ImpersonationMemberModal";
|
||||
import { InviteMemberModal } from "./InviteMemberModal";
|
||||
import type { UserTableAction, UserTableState, UserTableUser } from "./types";
|
||||
import { TableActions } from "./UserTableActions";
|
||||
@@ -118,12 +113,30 @@ function reducer(state: UserTableState, action: UserTableAction): UserTableState
|
||||
}
|
||||
|
||||
type UserListTableProps = {
|
||||
org: RouterOutputs["viewer"]["organizations"]["listCurrent"];
|
||||
teams: RouterOutputs["viewer"]["organizations"]["getTeams"];
|
||||
attributes?: RouterOutputs["viewer"]["attributes"]["list"];
|
||||
org: { user?: { role?: string }; slug?: string; name?: string; canAdminImpersonate?: boolean };
|
||||
teams: {
|
||||
id: number;
|
||||
name: string;
|
||||
slug: string | null;
|
||||
logoUrl?: string | null;
|
||||
isOrganization?: boolean;
|
||||
}[];
|
||||
attributes?: {
|
||||
id: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isWeightsEnabled?: boolean;
|
||||
options: { value: string; weight?: number }[];
|
||||
}[];
|
||||
facetedTeamValues?: {
|
||||
roles: { id: string; name: string }[];
|
||||
teams: RouterOutputs["viewer"]["organizations"]["getTeams"];
|
||||
teams: {
|
||||
id: number;
|
||||
name: string;
|
||||
slug: string | null;
|
||||
logoUrl?: string | null;
|
||||
isOrganization?: boolean;
|
||||
}[];
|
||||
attributes: {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -132,7 +145,17 @@ type UserListTableProps = {
|
||||
}[];
|
||||
}[];
|
||||
};
|
||||
permissions?: MemberPermissions;
|
||||
permissions?: {
|
||||
canRemoveMember: boolean;
|
||||
canChangeRole: boolean;
|
||||
canChangeMemberRole: boolean;
|
||||
canRemove: boolean;
|
||||
canInvite: boolean;
|
||||
canImpersonate: boolean;
|
||||
canResetPassword: boolean;
|
||||
canEditAttributesForUser: boolean;
|
||||
canViewAttributes: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
function UserListTable(props: UserListTableProps): JSX.Element | null {
|
||||
@@ -153,12 +176,17 @@ function UserListTableContent({
|
||||
permissions,
|
||||
}: UserListTableProps): JSX.Element {
|
||||
const [dynamicLinkVisible, setDynamicLinkVisible] = useQueryState("dynamicLink", parseAsBoolean);
|
||||
const orgBranding = useOrgBranding();
|
||||
const domain = orgBranding?.fullDomain ?? WEBAPP_URL;
|
||||
const orgBranding = null as {
|
||||
slug?: string;
|
||||
name?: string;
|
||||
fullDomain?: string;
|
||||
canAdminImpersonate?: boolean;
|
||||
} | null;
|
||||
const domain = WEBAPP_URL;
|
||||
const { t } = useLocale();
|
||||
|
||||
const { data: session } = useSession();
|
||||
const { isPlatformUser } = useGetUserAttributes();
|
||||
const isPlatformUser = false;
|
||||
const [state, dispatch] = useReducer(reducer, initialState);
|
||||
const [isDownloading, setIsDownloading] = useState(false);
|
||||
const [rowSelection, setRowSelection] = useState({});
|
||||
@@ -167,20 +195,12 @@ function UserListTableContent({
|
||||
|
||||
const { limit, offset, searchTerm, ctaContainerRef } = useDataTable();
|
||||
|
||||
const { data, isPending } = trpc.viewer.organizations.listMembers.useQuery(
|
||||
{
|
||||
limit,
|
||||
offset,
|
||||
searchTerm,
|
||||
expand: ["attributes"],
|
||||
filters: columnFilters,
|
||||
},
|
||||
{
|
||||
placeholderData: keepPreviousData,
|
||||
}
|
||||
);
|
||||
const data = { rows: [] as UserTableUser[], meta: { totalRowCount: 0 } };
|
||||
const isPending = false;
|
||||
|
||||
const adminOrOwner = checkAdminOrOwner(org?.user?.role);
|
||||
const adminOrOwner = checkAdminOrOwner(
|
||||
org?.user?.role as import("@calcom/prisma/enums").MembershipRole | undefined
|
||||
);
|
||||
|
||||
//we must flatten the array of arrays from the useInfiniteQuery hook
|
||||
const flatData = useMemo<UserTableUser[]>(() => data?.rows ?? [], [data]);
|
||||
@@ -236,7 +256,7 @@ function UserListTableContent({
|
||||
return (
|
||||
<LimitedBadges
|
||||
items={attributeValues.map((attributeValue) => {
|
||||
const isAGroupOption = attributeValue.contains?.length > 0;
|
||||
const isAGroupOption = (attributeValue.contains?.length ?? 0) > 0;
|
||||
let weight = "";
|
||||
if (attribute.isWeightsEnabled) {
|
||||
weight = `${attributeValue.weight || 100}%`;
|
||||
@@ -316,12 +336,12 @@ function UserListTableContent({
|
||||
<div className="">
|
||||
<div
|
||||
data-testid={`member-${username}-username`}
|
||||
className="text-emphasis text-sm font-medium leading-none">
|
||||
className="font-medium text-emphasis text-sm leading-none">
|
||||
{displayName}
|
||||
</div>
|
||||
<div
|
||||
data-testid={`member-${username}-email`}
|
||||
className="text-subtle mt-1 text-sm leading-none">
|
||||
className="mt-1 text-sm text-subtle leading-none">
|
||||
{email}
|
||||
</div>
|
||||
</div>
|
||||
@@ -358,7 +378,16 @@ function UserListTableContent({
|
||||
},
|
||||
{
|
||||
id: "teams",
|
||||
accessorFn: (data: UserTableUser) => data.teams.map((team) => team.name),
|
||||
accessorFn: (data: UserTableUser) =>
|
||||
data.teams.map(
|
||||
(team: {
|
||||
id: number;
|
||||
name: string;
|
||||
slug: string | null;
|
||||
logoUrl?: string | null;
|
||||
isOrganization?: boolean;
|
||||
}) => team.name
|
||||
),
|
||||
header: t("teams"),
|
||||
size: 140,
|
||||
meta: {
|
||||
@@ -383,13 +412,21 @@ function UserListTableContent({
|
||||
)}
|
||||
|
||||
<LimitedBadges
|
||||
items={teams.map((team) => ({
|
||||
label: team.name,
|
||||
variant: "gray" as const,
|
||||
onClick: () => {
|
||||
table.getColumn("teams")?.setFilterValue([team.name]);
|
||||
},
|
||||
}))}
|
||||
items={teams.map(
|
||||
(team: {
|
||||
id: number;
|
||||
name: string;
|
||||
slug: string | null;
|
||||
logoUrl?: string | null;
|
||||
isOrganization?: boolean;
|
||||
}) => ({
|
||||
label: team.name,
|
||||
variant: "gray" as const,
|
||||
onClick: () => {
|
||||
table.getColumn("teams")?.setFilterValue([team.name]);
|
||||
},
|
||||
})
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -407,7 +444,9 @@ function UserListTableContent({
|
||||
type: ColumnFilterType.DATE_RANGE,
|
||||
},
|
||||
},
|
||||
cell: ({ row }: CellContext<UserTableUser, unknown>) => <div>{row.original.lastActiveAt}</div>,
|
||||
cell: ({ row }: CellContext<UserTableUser, unknown>) => (
|
||||
<div>{row.original.lastActiveAt?.toLocaleDateString() ?? ""}</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "createdAt",
|
||||
@@ -420,7 +459,9 @@ function UserListTableContent({
|
||||
type: ColumnFilterType.DATE_RANGE,
|
||||
},
|
||||
},
|
||||
cell: ({ row }: CellContext<UserTableUser, unknown>) => <div>{row.original.createdAt || ""}</div>,
|
||||
cell: ({ row }: CellContext<UserTableUser, unknown>) => (
|
||||
<div>{row.original.createdAt?.toLocaleDateString() ?? ""}</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "updatedAt",
|
||||
@@ -433,7 +474,9 @@ function UserListTableContent({
|
||||
type: ColumnFilterType.DATE_RANGE,
|
||||
},
|
||||
},
|
||||
cell: ({ row }: CellContext<UserTableUser, unknown>) => <div>{row.original.updatedAt || ""}</div>,
|
||||
cell: ({ row }: CellContext<UserTableUser, unknown>) => (
|
||||
<div>{row.original.updatedAt?.toLocaleDateString() ?? ""}</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "completedOnboarding",
|
||||
@@ -494,7 +537,6 @@ function UserListTableContent({
|
||||
canRemove: (permissionsRaw.canRemove ?? false) && !isSelf,
|
||||
canImpersonate:
|
||||
user.accepted &&
|
||||
!user.disableImpersonation &&
|
||||
!isSelf &&
|
||||
!!org?.canAdminImpersonate &&
|
||||
(permissionsRaw.canImpersonate ?? false),
|
||||
@@ -596,13 +638,7 @@ function UserListTableContent({
|
||||
const limit = 100;
|
||||
|
||||
while (offset !== undefined) {
|
||||
const result = await utils.viewer.organizations.listMembers.fetch({
|
||||
limit,
|
||||
offset,
|
||||
searchTerm,
|
||||
expand: ["attributes"],
|
||||
filters: columnFilters,
|
||||
});
|
||||
const result = { rows: [] as UserTableUser[] };
|
||||
|
||||
if (!result.rows?.length) {
|
||||
offset = undefined;
|
||||
@@ -661,12 +697,17 @@ function UserListTableContent({
|
||||
)}
|
||||
{numberOfSelectedRows > 0 && (
|
||||
<DataTableSelectionBar.Root className="bottom-16! justify-center md:w-max">
|
||||
<p className="text-brand-subtle shrink-0 px-2 text-center text-xs leading-none sm:text-sm sm:font-medium">
|
||||
<p className="shrink-0 px-2 text-center text-brand-subtle text-xs leading-none sm:font-medium sm:text-sm">
|
||||
{t("number_selected", { count: numberOfSelectedRows })}
|
||||
</p>
|
||||
{!isPlatformUser && (
|
||||
<>
|
||||
{permissions?.canChangeMemberRole && <TeamListBulkAction table={table} />}
|
||||
{permissions?.canChangeMemberRole && (
|
||||
<DeleteBulkUsers
|
||||
users={table.getSelectedRowModel().flatRows.map((row) => row.original)}
|
||||
onRemove={() => table.toggleAllPageRowsSelected(false)}
|
||||
/>
|
||||
)}
|
||||
{numberOfSelectedRows >= 2 && (
|
||||
<DataTableSelectionBar.Button
|
||||
color="secondary"
|
||||
@@ -675,11 +716,11 @@ function UserListTableContent({
|
||||
{t("group_meeting")}
|
||||
</DataTableSelectionBar.Button>
|
||||
)}
|
||||
{(permissions?.canEditAttributesForUser ?? adminOrOwner) && (
|
||||
<MassAssignAttributesBulkAction table={table} filters={columnFilters} />
|
||||
)}
|
||||
{(permissions?.canChangeMemberRole ?? adminOrOwner) && (
|
||||
<EventTypesList table={table} orgTeams={teams} />
|
||||
<EventTypesList
|
||||
table={table}
|
||||
orgTeams={teams?.map((t) => ({ id: t.id, slug: t.slug ?? "", title: t.name }))}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
@@ -695,7 +736,7 @@ function UserListTableContent({
|
||||
|
||||
{state.deleteMember.showModal && <DeleteMemberModal state={state} dispatch={dispatch} />}
|
||||
{state.inviteMember.showModal && <InviteMemberModal dispatch={dispatch} />}
|
||||
{state.impersonateMember.showModal && <ImpersonationMemberModal dispatch={dispatch} state={state} />}
|
||||
{/* Impersonation modal removed (enterprise) */}
|
||||
{state.changeMemberRole.showModal && <ChangeUserRoleModal dispatch={dispatch} state={state} />}
|
||||
{state.editSheet.showModal && (
|
||||
<EditUserSheet
|
||||
|
||||
Reference in new issue
Block a user