diff --git a/frontend/src/components/v2/Alert/Alert.stories.tsx b/frontend/src/components/v2/Alert/Alert.stories.tsx index ef42a9af4..3cfc983cb 100644 --- a/frontend/src/components/v2/Alert/Alert.stories.tsx +++ b/frontend/src/components/v2/Alert/Alert.stories.tsx @@ -1,8 +1,8 @@ -import { faTriangleExclamation } from "@fortawesome/free-solid-svg-icons"; +import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import type { Meta, StoryObj } from "@storybook/react"; -import { Alert, AlertDescription, AlertTitle } from "./Alert"; +import { Alert, AlertDescription } from "./Alert"; const meta: Meta = { title: "Components/Alert", @@ -14,12 +14,7 @@ export default meta; type Story = StoryObj; -const ExampleComponent = () => ( - <> - this is a title - this is a description - -); +const ExampleComponent = () => this is a description; export const Default: Story = { args: { @@ -41,14 +36,26 @@ export const Destructive: Story = { } }; -export const WithIcon: Story = { +export const WithCustomIcon: Story = { args: { - children: ( - <> - - - - ), - variant: "warning" + children: , + variant: "warning", + icon: + } +}; + +export const WithOutIcon: Story = { + args: { + children: , + variant: "warning", + icon: null + } +}; + +export const WithOutTitle: Story = { + args: { + children: , + variant: "warning", + hideTitle: true } }; diff --git a/frontend/src/components/v2/Alert/Alert.tsx b/frontend/src/components/v2/Alert/Alert.tsx index d28fc059a..7aba947b4 100644 --- a/frontend/src/components/v2/Alert/Alert.tsx +++ b/frontend/src/components/v2/Alert/Alert.tsx @@ -1,10 +1,16 @@ +/* eslint-disable react/prop-types */ import * as React from "react"; +import { + faExclamationCircle, + faExclamationTriangle, + faInfoCircle +} from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { type VariantProps, cva } from "cva"; - -import { cn } from "@app/helpers/classNames"; +import { twMerge } from "tailwind-merge"; const alertVariants = cva( - "relative w-full bg-mineshaft-800 rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7", + "w-full bg-mineshaft-800 rounded-lg border px-4 py-3 text-sm flex items-center gap-x-4", { variants: { variant: { @@ -19,33 +25,62 @@ const alertVariants = cva( } ); +type AlertProps = { + title?: string; + hideTitle?: boolean; + icon?: React.ReactNode; +}; + +const variantTitleMap = { + default: "Info", + destructive: "Danger", + warning: "Warning" +}; + +const variantIconMap = { + default: faInfoCircle, + destructive: faExclamationCircle, + warning: faExclamationTriangle +}; + const Alert = React.forwardRef< HTMLDivElement, - React.HTMLAttributes & VariantProps ->(({ className, variant, ...props }, ref) => ( -
-)); -Alert.displayName = "Alert"; - -const AlertTitle = React.forwardRef>( - ({ className, children, ...props }, ref) => ( -
& VariantProps & AlertProps +>(({ className, variant, title, icon, hideTitle = false, children, ...props }, ref) => { + const defaultTitle = title ?? variantTitleMap[variant ?? "default"]; + return ( +
- {children} -
- ) -); -AlertTitle.displayName = "AlertTitle"; +
+ {typeof icon !== "undefined" ? ( + <>{icon} + ) : ( + + )} +
+
+ {hideTitle ? null : ( +
+ {defaultTitle} +
+ )} + {children} +
+
+ ); +}); +Alert.displayName = "Alert"; const AlertDescription = React.forwardRef< HTMLParagraphElement, React.HTMLAttributes >(({ className, ...props }, ref) => ( -
+
)); AlertDescription.displayName = "AlertDescription"; -export { Alert, AlertDescription, AlertTitle }; +export { Alert, AlertDescription }; diff --git a/frontend/src/components/v2/Alert/index.tsx b/frontend/src/components/v2/Alert/index.tsx index 1b2cdda51..7851a0943 100644 --- a/frontend/src/components/v2/Alert/index.tsx +++ b/frontend/src/components/v2/Alert/index.tsx @@ -1 +1 @@ -export { Alert, AlertDescription, AlertTitle } from "./Alert"; +export { Alert, AlertDescription } from "./Alert"; diff --git a/frontend/src/views/IntegrationsPage/components/IntegrationsSection/IntegrationsSection.tsx b/frontend/src/views/IntegrationsPage/components/IntegrationsSection/IntegrationsSection.tsx index 8a798f2cc..59577aab4 100644 --- a/frontend/src/views/IntegrationsPage/components/IntegrationsSection/IntegrationsSection.tsx +++ b/frontend/src/views/IntegrationsPage/components/IntegrationsSection/IntegrationsSection.tsx @@ -1,5 +1,5 @@ import Link from "next/link"; -import { faArrowRight, faExclamationTriangle, faXmark } from "@fortawesome/free-solid-svg-icons"; +import { faArrowRight, faXmark } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { integrationSlugNameMapping } from "public/data/frequentConstants"; @@ -55,8 +55,7 @@ export const IntegrationsSection = ({ {!bot?.isActive && (
- - + All the active integrations will be disabled. Disable End-to-End Encryption in{" "} diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/E2EESection/E2EESection.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/E2EESection/E2EESection.tsx index 5f691c6e5..2d62034d6 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/E2EESection/E2EESection.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/E2EESection/E2EESection.tsx @@ -1,12 +1,9 @@ -import { faExclamationTriangle } from "@fortawesome/free-solid-svg-icons"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; - import { ProjectPermissionCan } from "@app/components/permissions"; import { decryptAssymmetric, encryptAssymmetric } from "@app/components/utilities/cryptography/crypto"; -import { Alert, AlertDescription, AlertTitle, Checkbox } from "@app/components/v2"; +import { Alert, AlertDescription, Checkbox } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; import { useGetUserWsKey, useGetWorkspaceBot, useUpdateBotActiveStatus } from "@app/hooks/api"; @@ -107,8 +104,6 @@ export const E2EESection = () => {
- - Warning ! Enabling End-to-end encryption disables all the integrations