Feature/Routing Forms: Add the concepts of reusable Router and Router Linked Fields. (#5566)
* WIP * Fix all TS errors * Move to using isRouter everywhere * wip * Add Router Picker and fix TS issues * Fix tests and add option to connect during duplication * Misc changes * Fixes * Fixes * Fix TS errors * Disable certain options in Router * Fix connected Form fields not updating * Some fixes * reert shell.tsx * Disable already used router instead of removing it * Import prisma from correct place * Simplify loop using Object.entries * SimpliAdd playwright test and fix issues found
This commit is contained in:
1 parent
37159914cf
commit
38b3563350
25 files changed
+1162
-333
No files matched your search
@@ -13,12 +13,14 @@ const yesNo = (boolean?: boolean) => (boolean === true ? "yes" : boolean === fal
|
||||
export const BooleanToggleGroup = function BooleanToggleGroup({
|
||||
defaultValue = true,
|
||||
value,
|
||||
disabled = false,
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
onValueChange = () => {},
|
||||
}: {
|
||||
defaultValue?: boolean;
|
||||
value?: boolean;
|
||||
onValueChange?: (value?: boolean) => void;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
// Maintain a state because it is not necessary that onValueChange the parent component would re-render. Think react-hook-form
|
||||
// Also maintain a string as boolean isn't accepted as ToggleGroupPrimitive value
|
||||
@@ -37,6 +39,7 @@ export const BooleanToggleGroup = function BooleanToggleGroup({
|
||||
<ToggleGroupPrimitive
|
||||
value={yesNoValue}
|
||||
type="single"
|
||||
disabled={disabled}
|
||||
className="space-x-2 rounded-sm rtl:space-x-reverse"
|
||||
onValueChange={(yesNoValue: "yes" | "no") => {
|
||||
setYesNoValue(yesNoValue);
|
||||
@@ -44,10 +47,12 @@ export const BooleanToggleGroup = function BooleanToggleGroup({
|
||||
}}>
|
||||
<ToggleGroupItemPrimitive
|
||||
className={classNames(boolean(yesNoValue) ? selectedClass : unselectedClass)}
|
||||
disabled={disabled}
|
||||
value="yes">
|
||||
Yes
|
||||
</ToggleGroupItemPrimitive>
|
||||
<ToggleGroupItemPrimitive
|
||||
disabled={disabled}
|
||||
className={classNames(!boolean(yesNoValue) ? selectedClass : unselectedClass)}
|
||||
value="no">
|
||||
No
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import Link from "next/link";
|
||||
|
||||
import { classNames } from "@calcom/lib";
|
||||
|
||||
import { Icon } from "../../..";
|
||||
import { Badge, BadgeProps } from "../../../components";
|
||||
import Divider from "../Divider";
|
||||
|
||||
type Action = { check: () => boolean; fn: () => void };
|
||||
@@ -11,14 +14,16 @@ export default function FormCard({
|
||||
moveUp,
|
||||
moveDown,
|
||||
className,
|
||||
badge,
|
||||
...restProps
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
label?: string;
|
||||
label?: React.ReactNode;
|
||||
deleteField?: Action | null;
|
||||
moveUp?: Action | null;
|
||||
moveDown?: Action | null;
|
||||
className?: string;
|
||||
badge?: { text: string; href?: string; variant: BadgeProps["variant"] } | null;
|
||||
} & JSX.IntrinsicElements["div"]) {
|
||||
className = classNames(
|
||||
className,
|
||||
@@ -47,7 +52,20 @@ export default function FormCard({
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-sm font-semibold leading-none">{label}</span>
|
||||
<div>
|
||||
<span className="text-sm font-semibold leading-none">{label}</span>
|
||||
{badge && (
|
||||
<Badge className="ml-2" variant={badge.variant}>
|
||||
{badge.href ? (
|
||||
<Link href={badge.href}>
|
||||
<a>{badge.text}</a>
|
||||
</Link>
|
||||
) : (
|
||||
badge.text
|
||||
)}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
{deleteField?.check() ? (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in new issue
Block a user