mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 12:27:31 +00:00
add helper text and tooltip for secret path
This commit is contained in:
@@ -8,12 +8,17 @@ export type FormLabelProps = {
|
|||||||
id?: string;
|
id?: string;
|
||||||
isRequired?: boolean;
|
isRequired?: boolean;
|
||||||
label?: ReactNode;
|
label?: ReactNode;
|
||||||
|
icon?: ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const FormLabel = ({ id, label, isRequired }: FormLabelProps) => (
|
export const FormLabel = ({ id, label, isRequired, icon }: FormLabelProps) => (
|
||||||
<Label.Root className="mb-0.5 ml-1 block text-sm font-normal text-mineshaft-400" htmlFor={id}>
|
<Label.Root
|
||||||
|
className="mb-0.5 ml-1 block flex items-center text-sm font-normal text-mineshaft-400"
|
||||||
|
htmlFor={id}
|
||||||
|
>
|
||||||
{label}
|
{label}
|
||||||
{isRequired && <span className="ml-1 text-red">*</span>}
|
{isRequired && <span className="ml-1 text-red">*</span>}
|
||||||
|
{icon && <span className="ml-2 cursor-pointer text-white">{icon}</span>}
|
||||||
</Label.Root>
|
</Label.Root>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -47,6 +52,7 @@ export type FormControlProps = {
|
|||||||
errorText?: ReactNode;
|
errorText?: ReactNode;
|
||||||
children: JSX.Element;
|
children: JSX.Element;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
icon?: ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const FormControl = ({
|
export const FormControl = ({
|
||||||
@@ -57,12 +63,13 @@ export const FormControl = ({
|
|||||||
errorText,
|
errorText,
|
||||||
id,
|
id,
|
||||||
isError,
|
isError,
|
||||||
|
icon,
|
||||||
className
|
className
|
||||||
}: FormControlProps): JSX.Element => {
|
}: FormControlProps): JSX.Element => {
|
||||||
return (
|
return (
|
||||||
<div className={twMerge("mb-4", className)}>
|
<div className={twMerge("mb-4", className)}>
|
||||||
{typeof label === "string" ? (
|
{typeof label === "string" ? (
|
||||||
<FormLabel label={label} isRequired={isRequired} id={id} />
|
<FormLabel label={label} isRequired={isRequired} id={id} icon={icon} />
|
||||||
) : (
|
) : (
|
||||||
label
|
label
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export type TooltipProps = Omit<TooltipPrimitive.TooltipContentProps, "open" | "
|
|||||||
asChild?: boolean;
|
asChild?: boolean;
|
||||||
onOpenChange?: (isOpen: boolean) => void;
|
onOpenChange?: (isOpen: boolean) => void;
|
||||||
defaultOpen?: boolean;
|
defaultOpen?: boolean;
|
||||||
|
position?: "top" | "bottom" | "left" | "right";
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Tooltip = ({
|
export const Tooltip = ({
|
||||||
@@ -20,6 +21,7 @@ export const Tooltip = ({
|
|||||||
defaultOpen,
|
defaultOpen,
|
||||||
className,
|
className,
|
||||||
asChild = true,
|
asChild = true,
|
||||||
|
position = "top",
|
||||||
...props
|
...props
|
||||||
}: TooltipProps) => (
|
}: TooltipProps) => (
|
||||||
<TooltipPrimitive.Root
|
<TooltipPrimitive.Root
|
||||||
@@ -30,7 +32,7 @@ export const Tooltip = ({
|
|||||||
>
|
>
|
||||||
<TooltipPrimitive.Trigger asChild={asChild}>{children}</TooltipPrimitive.Trigger>
|
<TooltipPrimitive.Trigger asChild={asChild}>{children}</TooltipPrimitive.Trigger>
|
||||||
<TooltipPrimitive.Content
|
<TooltipPrimitive.Content
|
||||||
side="top"
|
side={position}
|
||||||
align="center"
|
align="center"
|
||||||
sideOffset={5}
|
sideOffset={5}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
+46
-3
@@ -1,5 +1,7 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Controller, useForm } from "react-hook-form";
|
import { Controller, useForm } from "react-hook-form";
|
||||||
|
import { faInfo } from "@fortawesome/free-solid-svg-icons";
|
||||||
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { yupResolver } from "@hookform/resolvers/yup";
|
import { yupResolver } from "@hookform/resolvers/yup";
|
||||||
import * as yup from "yup";
|
import * as yup from "yup";
|
||||||
|
|
||||||
@@ -11,7 +13,8 @@ import {
|
|||||||
ModalClose,
|
ModalClose,
|
||||||
ModalContent,
|
ModalContent,
|
||||||
Select,
|
Select,
|
||||||
SelectItem
|
SelectItem,
|
||||||
|
Tooltip
|
||||||
} from "@app/components/v2";
|
} from "@app/components/v2";
|
||||||
|
|
||||||
const formSchema = yup.object({
|
const formSchema = yup.object({
|
||||||
@@ -45,6 +48,7 @@ export const AddWebhookForm = ({
|
|||||||
} = useForm<TFormSchema>({
|
} = useForm<TFormSchema>({
|
||||||
resolver: yupResolver(formSchema)
|
resolver: yupResolver(formSchema)
|
||||||
});
|
});
|
||||||
|
const [showTip, setShowTip] = useState<boolean>(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
@@ -85,11 +89,50 @@ export const AddWebhookForm = ({
|
|||||||
/>
|
/>
|
||||||
<FormControl
|
<FormControl
|
||||||
label="Secret Path"
|
label="Secret Path"
|
||||||
|
icon={
|
||||||
|
<Tooltip
|
||||||
|
isOpen={showTip}
|
||||||
|
onOpenChange={() => setShowTip(false)}
|
||||||
|
content={
|
||||||
|
<div>
|
||||||
|
<h4 className="mb-2">Here are some examples of glob patterns:</h4>
|
||||||
|
<div className="ol-listStyleType">
|
||||||
|
<li>
|
||||||
|
<code className="text-primary">/</code> - Matches all files and
|
||||||
|
directories in the current directory
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code className="text-primary">**/*</code> - Matches all files and
|
||||||
|
directories in the current directory and its subdirectories
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code className="text-primary">{"/{dir1,dir2}"}</code> - Matches all files
|
||||||
|
and directories in dir1 and dir2
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
position="right"
|
||||||
|
className="text-xs"
|
||||||
|
>
|
||||||
|
<div className="flex h-3.5 w-3.5 items-center justify-center rounded-full border border-[1px] border-white">
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon={faInfo}
|
||||||
|
onClick={() => setShowTip(true)}
|
||||||
|
className="h-2 w-2"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
isRequired
|
isRequired
|
||||||
isError={Boolean(errors?.secretPath)}
|
isError={Boolean(errors?.secretPath)}
|
||||||
errorText={errors?.secretPath?.message}
|
errorText={errors?.secretPath?.message}
|
||||||
|
helperText="Glob patterns are used to match multiple files or directories"
|
||||||
>
|
>
|
||||||
<Input placeholder="/, /**/*" {...register("secretPath")} />
|
<Input
|
||||||
|
placeholder="glob pattern / or /**/* or /{dir1,dir2}"
|
||||||
|
{...register("secretPath")}
|
||||||
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl
|
<FormControl
|
||||||
label="Secret Key"
|
label="Secret Key"
|
||||||
|
|||||||
Reference in New Issue
Block a user