* init * Fix event limit interlinked switches * wip * WIP * fix bugs * lock hashed link until further notice * lock private url for managed type to stop confusion * fix recurring * prettier fix * early review fixes ... * --WIP to send only changed form fields in updateMutation * WIP with some type fixes * Revert "WIP with some type fixes" This reverts commit 00f10b772d6d08af17e7c9bd2d3601d93035d9b3. * post merge conflict resolution fixes * further type fix * fixed test * fixing e2e tests * fix test --WIP * attempt fix test & type --WIP * fix duplicate locale en entry * fix locked state persistence * adds private URL locked/unlocked functionality * fix tests * Fix issue where locked labels showed up in non-managed events * adds e2e test step * update new test * minor fixes * fix test * address changes request Part 1 fixed width on the lock badge members default location as default selection bugfix for offset toggle duplicate within itself * fixes locked/unlocked label for child event types * enable choice of destination calendar for children * Fixes width for simple lock badge * fix type * fixes workflows list and apps for managed event type * restricts creation of managed event types to EE only * further fixes --WIP * fix unit test for handleChildrenEventTypes * fix test --WIP * fix type err --WIP * fix type err in test * fix childevent payload * fixes hashedLink bug * fix test step title * lock workflow create button when workflow is locked * fix workflow detail * Don't rely on parameter ordering, use object instead * Removed console.log * Missed one --------- Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: Alex van Andel <me@alexvanandel.com>
99 lines
3.6 KiB
TypeScript
99 lines
3.6 KiB
TypeScript
import classNames from "classnames";
|
|
import type { ReactNode } from "react";
|
|
import { forwardRef } from "react";
|
|
import type { IconType } from "react-icons";
|
|
|
|
import { CheckCircle2, Info, XCircle, AlertTriangle } from "@calcom/ui/components/icon";
|
|
|
|
export interface AlertProps {
|
|
title?: ReactNode;
|
|
// @TODO: Message should be children, more flexible?
|
|
message?: ReactNode;
|
|
// @TODO: Provide action buttons so style is always the same.
|
|
actions?: ReactNode;
|
|
className?: string;
|
|
iconClassName?: string;
|
|
// @TODO: Success and info shouldn't exist as per design?
|
|
severity: "success" | "warning" | "error" | "info" | "neutral" | "green";
|
|
CustomIcon?: IconType;
|
|
customIconColor?: string;
|
|
}
|
|
export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
|
|
const { severity, iconClassName, CustomIcon, customIconColor } = props;
|
|
|
|
return (
|
|
<div
|
|
data-testid="alert"
|
|
ref={ref}
|
|
className={classNames(
|
|
"rounded-md p-3",
|
|
props.className,
|
|
severity === "error" && "bg-red-100 text-red-900 dark:bg-red-900 dark:text-red-200",
|
|
severity === "warning" && "text-attention bg-attention dark:bg-orange-900 dark:text-orange-200",
|
|
severity === "info" && "bg-blue-100 text-blue-900 dark:bg-blue-900 dark:text-blue-200",
|
|
severity === "green" && "bg-success text-success",
|
|
severity === "success" && "bg-inverted text-inverted",
|
|
severity === "neutral" && "bg-subtle text-default"
|
|
)}>
|
|
<div className="relative flex md:flex-row">
|
|
{CustomIcon ? (
|
|
<div className="flex-shrink-0">
|
|
<CustomIcon
|
|
data-testid="custom-icon"
|
|
aria-hidden="true"
|
|
className={classNames(`h-5 w-5`, iconClassName, customIconColor ?? "text-default")}
|
|
/>
|
|
</div>
|
|
) : (
|
|
<div className="flex-shrink-0">
|
|
{severity === "error" && (
|
|
<XCircle
|
|
data-testid="x-circle"
|
|
className={classNames("h-5 w-5 text-red-900 dark:text-red-200", iconClassName)}
|
|
aria-hidden="true"
|
|
/>
|
|
)}
|
|
{severity === "warning" && (
|
|
<AlertTriangle
|
|
data-testid="alert-triangle"
|
|
className={classNames("text-attention h-5 w-5 dark:text-orange-200", iconClassName)}
|
|
aria-hidden="true"
|
|
/>
|
|
)}
|
|
{severity === "info" && (
|
|
<Info
|
|
data-testid="info"
|
|
className={classNames("h-5 w-5 text-blue-900 dark:text-blue-200", iconClassName)}
|
|
aria-hidden="true"
|
|
/>
|
|
)}
|
|
{severity === "neutral" && (
|
|
<Info
|
|
data-testid="neutral"
|
|
className={classNames("text-default h-5 w-5 fill-transparent", iconClassName)}
|
|
aria-hidden="true"
|
|
/>
|
|
)}
|
|
{severity === "success" && (
|
|
<CheckCircle2
|
|
data-testid="check-circle-2"
|
|
className={classNames("fill-muted text-default h-5 w-5", iconClassName)}
|
|
aria-hidden="true"
|
|
/>
|
|
)}
|
|
</div>
|
|
)}
|
|
<div className="flex flex-grow flex-col sm:flex-row">
|
|
<div className="ltr:ml-3 rtl:mr-3">
|
|
<h3 className="text-sm font-medium">{props.title}</h3>
|
|
<div className="text-sm">{props.message}</div>
|
|
</div>
|
|
{props.actions && <div className="ml-auto mt-2 text-sm sm:mt-0 md:relative">{props.actions}</div>}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
});
|
|
|
|
Alert.displayName = "Alert";
|