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
@@ -1,10 +1,9 @@
|
||||
import type { FilterSegmentOutput } from "@calcom/features/data-table/lib/types";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Dialog, ConfirmationDialogContent } from "@calcom/ui/components/dialog";
|
||||
import { ConfirmationDialogContent, Dialog } from "@calcom/ui/components/dialog";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
import { useDataTable } from "~/data-table/hooks";
|
||||
import type { FilterSegmentOutput } from "@calcom/features/data-table/lib/types";
|
||||
|
||||
export function DeleteSegmentDialog({
|
||||
segment,
|
||||
@@ -17,23 +16,12 @@ export function DeleteSegmentDialog({
|
||||
const utils = trpc.useUtils();
|
||||
const { segmentId, setSegmentId } = useDataTable();
|
||||
|
||||
const { mutate: deleteSegment, isPending } = trpc.viewer.filterSegments.delete.useMutation({
|
||||
onSuccess: ({ id }) => {
|
||||
utils.viewer.filterSegments.list.invalidate();
|
||||
showToast(t("filter_segment_deleted"), "success");
|
||||
if (segmentId && segmentId.type === "user" && segmentId.id === id) {
|
||||
setSegmentId(null);
|
||||
}
|
||||
onClose();
|
||||
},
|
||||
onError: () => {
|
||||
showToast(t("error_deleting_filter_segment"), "error");
|
||||
},
|
||||
});
|
||||
const deleteSegment = { mutate: (_args: Record<string, unknown>) => {}, isPending: false };
|
||||
const isPending = deleteSegment.isPending;
|
||||
|
||||
const handleDelete = () => {
|
||||
if (!segment) return;
|
||||
deleteSegment({ id: segment.id });
|
||||
deleteSegment.mutate({ id: segment.id });
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import type { CombinedFilterSegment } from "@calcom/features/data-table/lib/types";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/components/dialog";
|
||||
import { Form, TextField } from "@calcom/ui/components/form";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useDataTable } from "~/data-table/hooks";
|
||||
import type { CombinedFilterSegment } from "@calcom/features/data-table/lib/types";
|
||||
|
||||
type FormValues = {
|
||||
name: string;
|
||||
@@ -34,17 +32,8 @@ export function DuplicateSegmentDialog({
|
||||
const session = useSession();
|
||||
const isAdminOrOwner = checkAdminOrOwner(session.data?.user?.org?.role);
|
||||
|
||||
const { mutate: createSegment, isPending } = trpc.viewer.filterSegments.create.useMutation({
|
||||
onSuccess: ({ id }) => {
|
||||
utils.viewer.filterSegments.list.invalidate();
|
||||
showToast(t("filter_segment_duplicated"), "success");
|
||||
setSegmentId({ id, type: "user" });
|
||||
onClose();
|
||||
},
|
||||
onError: () => {
|
||||
showToast(t("error_duplicating_filter_segment"), "error");
|
||||
},
|
||||
});
|
||||
const createSegment = { mutate: (_args: Record<string, unknown>) => {}, isPending: false };
|
||||
const isPending = createSegment.isPending;
|
||||
|
||||
const handleSubmit = (data: FormValues) => {
|
||||
if (!segment) {
|
||||
@@ -53,14 +42,14 @@ export function DuplicateSegmentDialog({
|
||||
if (segment.type === "user") {
|
||||
const { type: _type, id: _id, name: _name, team: _team, teamId, ...rest } = segment;
|
||||
if (segment.scope === "TEAM" && isAdminOrOwner) {
|
||||
createSegment({
|
||||
createSegment.mutate({
|
||||
...rest,
|
||||
teamId: teamId ?? 0,
|
||||
scope: "TEAM",
|
||||
name: data.name,
|
||||
});
|
||||
} else {
|
||||
createSegment({
|
||||
createSegment.mutate({
|
||||
...rest,
|
||||
scope: "USER",
|
||||
name: data.name,
|
||||
@@ -68,7 +57,7 @@ export function DuplicateSegmentDialog({
|
||||
}
|
||||
} else if (segment.type === "system") {
|
||||
const { type: _type, ...rest } = segment;
|
||||
createSegment({
|
||||
createSegment.mutate({
|
||||
...rest,
|
||||
scope: "USER",
|
||||
name: data.name,
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
import type { FilterSegmentOutput } from "@calcom/features/data-table/lib/types";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/components/dialog";
|
||||
import { Form, TextField } from "@calcom/ui/components/form";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
import type { FilterSegmentOutput } from "@calcom/features/data-table/lib/types";
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
type FormValues = {
|
||||
name: string;
|
||||
@@ -28,23 +26,15 @@ export function RenameSegmentDialog({
|
||||
});
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const { mutate: updateSegment, isPending } = trpc.viewer.filterSegments.update.useMutation({
|
||||
onSuccess: () => {
|
||||
utils.viewer.filterSegments.list.invalidate();
|
||||
showToast(t("filter_segment_updated"), "success");
|
||||
onClose();
|
||||
},
|
||||
onError: () => {
|
||||
showToast(t("error_updating_filter_segment"), "error");
|
||||
},
|
||||
});
|
||||
const updateSegment = { mutate: (_args: Record<string, unknown>) => {}, isPending: false };
|
||||
const isPending = updateSegment.isPending;
|
||||
|
||||
const handleSubmit = (data: FormValues) => {
|
||||
if (!segment) {
|
||||
return;
|
||||
}
|
||||
if (segment.scope === "TEAM") {
|
||||
updateSegment({
|
||||
updateSegment.mutate({
|
||||
...segment,
|
||||
scope: "TEAM",
|
||||
teamId: segment.teamId ?? 0,
|
||||
@@ -52,7 +42,7 @@ export function RenameSegmentDialog({
|
||||
});
|
||||
return;
|
||||
}
|
||||
updateSegment({
|
||||
updateSegment.mutate({
|
||||
...segment,
|
||||
scope: "USER",
|
||||
name: data.name,
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { type FilterSegmentScope } from "@calcom/prisma/enums";
|
||||
import type { FilterSegmentScope } from "@calcom/prisma/enums";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import {
|
||||
@@ -16,9 +11,12 @@ import {
|
||||
DialogTrigger,
|
||||
} from "@calcom/ui/components/dialog";
|
||||
import { Form, Input, Label, Select, Switch } from "@calcom/ui/components/form";
|
||||
import { RadioGroup, RadioField } from "@calcom/ui/components/radio";
|
||||
import { RadioField, RadioGroup } from "@calcom/ui/components/radio";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
import posthog from "posthog-js";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useDataTable } from "~/data-table/hooks";
|
||||
|
||||
interface FormValues {
|
||||
@@ -28,6 +26,16 @@ interface FormValues {
|
||||
}
|
||||
|
||||
export function SaveFilterSegmentButton() {
|
||||
const createSegmentMutation = {
|
||||
mutate: (_args: Record<string, unknown>) => {},
|
||||
mutateAsync: async (_args: Record<string, unknown>) => ({ id: "" }),
|
||||
};
|
||||
const updateSegmentMutation = {
|
||||
mutate: (_args: Record<string, unknown>) => {},
|
||||
mutateAsync: async (_args: Record<string, unknown>) => ({}),
|
||||
};
|
||||
const createSegment = (args: Record<string, unknown>) => createSegmentMutation.mutate(args);
|
||||
const updateSegment = (args: Record<string, unknown>) => updateSegmentMutation.mutate(args);
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
@@ -70,30 +78,7 @@ export function SaveFilterSegmentButton() {
|
||||
setSaveMode(selectedSegment && selectedSegment.type === "user" ? "update" : "create");
|
||||
}, [selectedSegment, isOpen]);
|
||||
|
||||
const { data: teams } = trpc.viewer.teams.list.useQuery();
|
||||
|
||||
const { mutate: createSegment } = trpc.viewer.filterSegments.create.useMutation({
|
||||
onSuccess: (segment) => {
|
||||
utils.viewer.filterSegments.list.invalidate();
|
||||
showToast(t("filter_segment_saved"), "success");
|
||||
setSegmentId({ id: segment.id, type: "user" }, { type: "user", ...segment });
|
||||
setIsOpen(false);
|
||||
},
|
||||
onError: () => {
|
||||
showToast(t("error_saving_filter_segment"), "error");
|
||||
},
|
||||
});
|
||||
|
||||
const { mutate: updateSegment } = trpc.viewer.filterSegments.update.useMutation({
|
||||
onSuccess: () => {
|
||||
utils.viewer.filterSegments.list.invalidate();
|
||||
showToast(t("filter_segment_updated"), "success");
|
||||
setIsOpen(false);
|
||||
},
|
||||
onError: () => {
|
||||
showToast(t("error_updating_filter_segment"), "error");
|
||||
},
|
||||
});
|
||||
const teams = null as { id: number; name: string; slug: string | null }[] | null;
|
||||
|
||||
const onSubmit = (values: FormValues) => {
|
||||
if (isTeamSegment && !selectedTeamId) {
|
||||
|
||||
Reference in new issue
Block a user