mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 08:28:22 +00:00
feat(frontend): adding tooltip for labels
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
import { cloneElement, ReactNode } from "react";
|
import { cloneElement, ReactNode } from "react";
|
||||||
import { faExclamationTriangle } from "@fortawesome/free-solid-svg-icons";
|
import { faExclamationTriangle, faQuestionCircle } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import * as Label from "@radix-ui/react-label";
|
import * as Label from "@radix-ui/react-label";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
|
import { Tooltip } from "../Tooltip";
|
||||||
|
|
||||||
export type FormLabelProps = {
|
export type FormLabelProps = {
|
||||||
id?: string;
|
id?: string;
|
||||||
isRequired?: boolean;
|
isRequired?: boolean;
|
||||||
@@ -11,9 +13,10 @@ export type FormLabelProps = {
|
|||||||
label?: ReactNode;
|
label?: ReactNode;
|
||||||
icon?: ReactNode;
|
icon?: ReactNode;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
tooltipText?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const FormLabel = ({ id, label, isRequired, icon, className,isOptional }: FormLabelProps) => (
|
export const FormLabel = ({ id, label, isRequired, icon, className,isOptional, tooltipText }: FormLabelProps) => (
|
||||||
<Label.Root
|
<Label.Root
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
"mb-0.5 ml-1 flex items-center text-sm font-normal text-mineshaft-400",
|
"mb-0.5 ml-1 flex items-center text-sm font-normal text-mineshaft-400",
|
||||||
@@ -24,11 +27,20 @@ export const FormLabel = ({ id, label, isRequired, icon, className,isOptional }:
|
|||||||
{label}
|
{label}
|
||||||
{isRequired && <span className="ml-1 text-red">*</span>}
|
{isRequired && <span className="ml-1 text-red">*</span>}
|
||||||
{isOptional && <span className="ml-1 text-gray-500 italic text-xs">- Optional</span>}
|
{isOptional && <span className="ml-1 text-gray-500 italic text-xs">- Optional</span>}
|
||||||
{icon && (
|
{icon && !tooltipText && (
|
||||||
<span className="ml-2 cursor-default text-mineshaft-300 hover:text-mineshaft-200">
|
<span className="ml-2 cursor-default text-mineshaft-300 hover:text-mineshaft-200">
|
||||||
{icon}
|
{icon}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
{tooltipText && (
|
||||||
|
<Tooltip content={tooltipText}>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon={faQuestionCircle}
|
||||||
|
size="1x"
|
||||||
|
className="ml-2"
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
</Label.Root>
|
</Label.Root>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -64,6 +76,7 @@ export type FormControlProps = {
|
|||||||
children: JSX.Element;
|
children: JSX.Element;
|
||||||
className?: string;
|
className?: string;
|
||||||
icon?: ReactNode;
|
icon?: ReactNode;
|
||||||
|
tooltipText?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const FormControl = ({
|
export const FormControl = ({
|
||||||
@@ -76,7 +89,8 @@ export const FormControl = ({
|
|||||||
id,
|
id,
|
||||||
isError,
|
isError,
|
||||||
icon,
|
icon,
|
||||||
className
|
className,
|
||||||
|
tooltipText
|
||||||
}: FormControlProps): JSX.Element => {
|
}: FormControlProps): JSX.Element => {
|
||||||
return (
|
return (
|
||||||
<div className={twMerge("mb-4", className)}>
|
<div className={twMerge("mb-4", className)}>
|
||||||
@@ -87,6 +101,7 @@ export const FormControl = ({
|
|||||||
isRequired={isRequired}
|
isRequired={isRequired}
|
||||||
id={id}
|
id={id}
|
||||||
icon={icon}
|
icon={icon}
|
||||||
|
tooltipText={tooltipText}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
label
|
label
|
||||||
|
|||||||
+1
-10
@@ -7,8 +7,6 @@ import { z } from "zod";
|
|||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import {
|
import {
|
||||||
Alert,
|
|
||||||
AlertDescription,
|
|
||||||
Button,
|
Button,
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
@@ -94,7 +92,6 @@ export const AccessPolicyForm = ({
|
|||||||
const { mutateAsync: createSecretApprovalPolicy } = useCreateSecretApprovalPolicy();
|
const { mutateAsync: createSecretApprovalPolicy } = useCreateSecretApprovalPolicy();
|
||||||
const { mutateAsync: updateSecretApprovalPolicy } = useUpdateSecretApprovalPolicy();
|
const { mutateAsync: updateSecretApprovalPolicy } = useUpdateSecretApprovalPolicy();
|
||||||
|
|
||||||
const enforcementLevel = watch("enforcementLevel");
|
|
||||||
const policyName = policyDetails[watch("policyType")]?.name || "Policy";
|
const policyName = policyDetails[watch("policyType")]?.name || "Policy";
|
||||||
|
|
||||||
const handleCreatePolicy = async (data: TFormSchema) => {
|
const handleCreatePolicy = async (data: TFormSchema) => {
|
||||||
@@ -330,6 +327,7 @@ export const AccessPolicyForm = ({
|
|||||||
label="Enforcement Level"
|
label="Enforcement Level"
|
||||||
isError={Boolean(error)}
|
isError={Boolean(error)}
|
||||||
errorText={error?.message}
|
errorText={error?.message}
|
||||||
|
tooltipText="Choose 'Hard' for required approval or 'Soft' for optional approval"
|
||||||
helperText={
|
helperText={
|
||||||
field.value === EnforcementLevel.Hard
|
field.value === EnforcementLevel.Hard
|
||||||
? "Hard enforcement prevents any request from being deployed without prior approval"
|
? "Hard enforcement prevents any request from being deployed without prior approval"
|
||||||
@@ -352,13 +350,6 @@ export const AccessPolicyForm = ({
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{enforcementLevel === EnforcementLevel.Soft && (
|
|
||||||
<Alert hideTitle variant="warning">
|
|
||||||
<AlertDescription>
|
|
||||||
Soft enforcement allows requesters to bypass approval, which may reduce system security and stability.
|
|
||||||
</AlertDescription>
|
|
||||||
</Alert>
|
|
||||||
)}
|
|
||||||
<div className="mt-8 flex items-center space-x-4">
|
<div className="mt-8 flex items-center space-x-4">
|
||||||
<Button type="submit" isLoading={isSubmitting} isDisabled={isSubmitting}>
|
<Button type="submit" isLoading={isSubmitting} isDisabled={isSubmitting}>
|
||||||
Save
|
Save
|
||||||
|
|||||||
Reference in New Issue
Block a user