Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

improvement(ui): migrate secret scanning details and review fields to v3 (#8428)

Andrew Huang770bf3632f07
diff --git a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceConfigFields/SecretScanningDataSourceConfigFields.tsx b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceConfigFields/SecretScanningDataSourceConfigFields.tsx
index 8660f07365..ad6c696315 100644
--- a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceConfigFields/SecretScanningDataSourceConfigFields.tsx
+++ b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceConfigFields/SecretScanningDataSourceConfigFields.tsx
@@ -1,6 +1,6 @@
import { Controller, useFormContext } from "react-hook-form";
-import { FormControl, Switch } from "@app/components/v2";
+import { Field, FieldDescription, FieldError, FieldLabel, Toggle } from "@app/components/v3";
import { RESOURCE_DESCRIPTION_HELPER } from "@app/helpers/secretScanningV2";
import { SecretScanningDataSource } from "@app/hooks/api/secretScanningV2";
@@ -30,27 +30,32 @@ export const SecretScanningDataSourceConfigFields = () => {
<Controller
control={control}
name="isAutoScanEnabled"
- render={({ field: { value, onChange }, fieldState: { error } }) => {
+ render={({ field: { value, onChange, onBlur, ref, name }, fieldState: { error } }) => {
return (
- <FormControl
- helperText={
- value
+ <Field className="mb-4" data-invalid={Boolean(error)}>
+ <div className="flex items-center gap-3">
+ <Toggle
+ ref={ref}
+ name={name}
+ id="auto-scan-enabled"
+ variant="success"
+ onCheckedChange={onChange}
+ onBlur={onBlur}
+ checked={value}
+ aria-invalid={Boolean(error)}
+ aria-describedby={`auto-scan-enabled-help${error ? " auto-scan-enabled-error" : ""}`}
+ />
+ <FieldLabel htmlFor="auto-scan-enabled">
+ Auto-Scan {value ? "Enabled" : "Disabled"}
+ </FieldLabel>
+ </div>
+ <FieldDescription id="auto-scan-enabled-help">
+ {value
? `Scans will automatically be triggered when a ${autoScanDescription.verb} occurs to ${autoScanDescription.pluralNoun} associated with this data source.`
- : "Manually trigger scans to detect secret leaks."
- }
- isError={Boolean(error)}
- errorText={error?.message}
- >
- <Switch
- className="bg-muted/80 shadow-inner data-[state=checked]:bg-success/80"
- id="auto-scan-enabled"
- thumbClassName="bg-surface-raised"
- onCheckedChange={onChange}
- isChecked={value}
- >
- <p className="w-[9.6rem]">Auto-Scan {value ? "Enabled" : "Disabled"}</p>
- </Switch>
- </FormControl>
+ : "Manually trigger scans to detect secret leaks."}
+ </FieldDescription>
+ <FieldError id="auto-scan-enabled-error">{error?.message}</FieldError>
+ </Field>
);
}}
/>
diff --git a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceDetailsFields.tsx b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceDetailsFields.tsx
index a3535c6b75..a73e402cf5 100644
--- a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceDetailsFields.tsx
+++ b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceDetailsFields.tsx
@@ -1,6 +1,13 @@
import { Controller, useFormContext } from "react-hook-form";
-import { FormControl, Input, TextArea } from "@app/components/v2";
+import {
+ Field,
+ FieldDescription,
+ FieldError,
+ FieldLabel,
+ Input,
+ TextArea
+} from "@app/components/v3";
import { TSecretScanningDataSourceForm } from "./schemas";
@@ -13,42 +20,48 @@ export const SecretScanningDataSourceDetailsFields = () => {
Provide a name and description for this Data Source.
</p>
<Controller
- render={({ field: { value, onChange }, fieldState: { error } }) => (
- <FormControl
- helperText="Must be slug-friendly"
- isError={Boolean(error)}
- errorText={error?.message}
- label="Name"
- >
+ render={({ field, fieldState: { error } }) => (
+ <Field className="mb-4" data-invalid={Boolean(error)}>
+ <FieldLabel htmlFor="secret-scanning-data-source-name">Name</FieldLabel>
<Input
+ {...field}
+ id="secret-scanning-data-source-name"
autoFocus
- value={value}
- onChange={onChange}
placeholder="my-data-source"
autoComplete="off"
name="secret-scanning-data-source-name"
+ aria-invalid={Boolean(error)}
+ aria-describedby={`secret-scanning-data-source-name-help${error ? " secret-scanning-data-source-name-error" : ""}`}
/>
- </FormControl>
+ <FieldDescription id="secret-scanning-data-source-name-help">
+ Must be slug-friendly
+ </FieldDescription>
+ <FieldError id="secret-scanning-data-source-name-error">{error?.message}</FieldError>
+ </Field>
)}
control={control}
name="name"
/>
<Controller
- render={({ field: { value, onChange }, fieldState: { error } }) => (
- <FormControl
- isError={Boolean(error)}
- isOptional
- errorText={error?.message}
- label="Description"
- >
+ render={({ field, fieldState: { error } }) => (
+ <Field className="mb-4" data-invalid={Boolean(error)}>
+ <FieldLabel htmlFor="secret-scanning-data-source-description">
+ Description <span className="text-muted">(optional)</span>
+ </FieldLabel>
<TextArea
- value={value ?? ""}
- onChange={onChange}
+ {...field}
+ id="secret-scanning-data-source-description"
+ value={field.value ?? ""}
placeholder="Provide a description for this data source..."
className="resize-none!"
rows={4}
+ aria-invalid={Boolean(error)}
+ aria-describedby={error ? "secret-scanning-data-source-description-error" : undefined}
/>
- </FormControl>
+ <FieldError id="secret-scanning-data-source-description-error">
+ {error?.message}
+ </FieldError>
+ </Field>
)}
control={control}
name="description"
diff --git a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceForm.tsx b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceForm.tsx
index 53b89c5c3e..924729ca3e 100644
--- a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceForm.tsx
+++ b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceForm.tsx
@@ -5,7 +5,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
-import { Button } from "@app/components/v2";
+import { Button } from "@app/components/v3";
import { useProject } from "@app/context";
import { SECRET_SCANNING_DATA_SOURCE_MAP } from "@app/helpers/secretScanningV2";
import {
@@ -165,13 +165,14 @@ export const SecretScanningDataSourceForm = ({
<div className="flex w-full flex-row-reverse justify-between gap-4 pt-4">
<Button
onClick={handleNext}
- isLoading={isSubmitting}
+ type="button"
+ isPending={isSubmitting}
isDisabled={isSubmitting}
- colorSchema="secondary"
+ variant="project"
>
{isFinalStep ? `${dataSource ? "Update" : "Create"} Data Source` : "Next"}
</Button>
- <Button onClick={handlePrev} colorSchema="secondary">
+ <Button type="button" onClick={handlePrev} variant="ghost">
Back
</Button>
</div>
diff --git a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/BitbucketDataSourceReviewFields.tsx b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/BitbucketDataSourceReviewFields.tsx
index 1523cb0adb..dc48336cee 100644
--- a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/BitbucketDataSourceReviewFields.tsx
+++ b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/BitbucketDataSourceReviewFields.tsx
@@ -1,6 +1,6 @@
import { useFormContext } from "react-hook-form";
-import { GenericFieldLabel } from "@app/components/v2";
+import { Detail, DetailLabel, DetailValue } from "@app/components/v3";
import { SecretScanningDataSource } from "@app/hooks/api/secretScanningV2";
import { TSecretScanningDataSourceForm } from "../schemas";
@@ -18,11 +18,20 @@ export const BitbucketDataSourceReviewFields = () => {
return (
<SecretScanningDataSourceConfigReviewSection>
- {connection && <GenericFieldLabel label="Connection">{connection.name}</GenericFieldLabel>}
- <GenericFieldLabel label="Workspace Slug">{workspaceSlug}</GenericFieldLabel>
- <GenericFieldLabel label="Scan Repositories">
- {shouldScanAll ? "All" : includeRepos.join(", ")}
- </GenericFieldLabel>
+ {connection && (
+ <Detail>
+ <DetailLabel>Connection</DetailLabel>
+ <DetailValue>{connection.name || "None"}</DetailValue>
+ </Detail>
+ )}
+ <Detail>
+ <DetailLabel>Workspace Slug</DetailLabel>
+ <DetailValue>{workspaceSlug || "None"}</DetailValue>
+ </Detail>
+ <Detail>
+ <DetailLabel>Scan Repositories</DetailLabel>
+ <DetailValue>{shouldScanAll ? "All" : includeRepos.join(", ") || "None"}</DetailValue>
+ </Detail>
</SecretScanningDataSourceConfigReviewSection>
);
};
diff --git a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/GitHubDataSourceReviewFields.tsx b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/GitHubDataSourceReviewFields.tsx
index 0bea10d3cf..f28df434a2 100644
--- a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/GitHubDataSourceReviewFields.tsx
+++ b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/GitHubDataSourceReviewFields.tsx
@@ -1,6 +1,6 @@
import { useFormContext } from "react-hook-form";
-import { GenericFieldLabel } from "@app/components/v2";
+import { Detail, DetailLabel, DetailValue } from "@app/components/v3";
import { SecretScanningDataSource } from "@app/hooks/api/secretScanningV2";
import { TSecretScanningDataSourceForm } from "../schemas";
@@ -18,10 +18,16 @@ export const GitHubDataSourceReviewFields = () => {
return (
<SecretScanningDataSourceConfigReviewSection>
- {connection && <GenericFieldLabel label="Connection">{connection.name}</GenericFieldLabel>}
- <GenericFieldLabel label="Scan Repositories">
- {shouldScanAll ? "All" : includeRepos.join(", ")}
- </GenericFieldLabel>
+ {connection && (
+ <Detail>
+ <DetailLabel>Connection</DetailLabel>
+ <DetailValue>{connection.name || "None"}</DetailValue>
+ </Detail>
+ )}
+ <Detail>
+ <DetailLabel>Scan Repositories</DetailLabel>
+ <DetailValue>{shouldScanAll ? "All" : includeRepos.join(", ") || "None"}</DetailValue>
+ </Detail>
</SecretScanningDataSourceConfigReviewSection>
);
};
diff --git a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/GitLabDataSourceReviewFields.tsx b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/GitLabDataSourceReviewFields.tsx
index ad421e57e6..190db7235b 100644
--- a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/GitLabDataSourceReviewFields.tsx
+++ b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/GitLabDataSourceReviewFields.tsx
@@ -1,6 +1,6 @@
import { useFormContext } from "react-hook-form";
-import { GenericFieldLabel } from "@app/components/v2";
+import { Detail, DetailLabel, DetailValue } from "@app/components/v3";
import { SecretScanningDataSource } from "@app/hooks/api/secretScanningV2";
import { GitLabDataSourceScope } from "@app/hooks/api/secretScanningV2/types/gitlab-data-source";
@@ -20,11 +20,20 @@ export const GitLabDataSourceReviewFields = () => {
const { projectName, projectId } = config;
return (
<SecretScanningDataSourceConfigReviewSection>
- {connection && <GenericFieldLabel label="Connection">{connection.name}</GenericFieldLabel>}
- <GenericFieldLabel label="Scope" className="capitalize">
- {config.scope}
- </GenericFieldLabel>
- <GenericFieldLabel label="Project">{projectName || projectId}</GenericFieldLabel>
+ {connection && (
+ <Detail>
+ <DetailLabel>Connection</DetailLabel>
+ <DetailValue>{connection.name || "None"}</DetailValue>
+ </Detail>
+ )}
+ <Detail>
+ <DetailLabel>Scope</DetailLabel>
+ <DetailValue>Project</DetailValue>
+ </Detail>
+ <Detail>
+ <DetailLabel>Project</DetailLabel>
+ <DetailValue>{projectName || projectId || "None"}</DetailValue>
+ </Detail>
</SecretScanningDataSourceConfigReviewSection>
);
}
@@ -36,14 +45,24 @@ export const GitLabDataSourceReviewFields = () => {
return (
<SecretScanningDataSourceConfigReviewSection>
- {connection && <GenericFieldLabel label="Connection">{connection.name}</GenericFieldLabel>}
- <GenericFieldLabel label="Scope" className="capitalize">
- {config.scope}
- </GenericFieldLabel>
- <GenericFieldLabel label="Group">{groupName || groupId}</GenericFieldLabel>
- <GenericFieldLabel label="Scan Projects">
- {shouldScanAll ? "All" : includeProjects.join(", ")}
- </GenericFieldLabel>
+ {connection && (
+ <Detail>
+ <DetailLabel>Connection</DetailLabel>
+ <DetailValue>{connection.name || "None"}</DetailValue>
+ </Detail>
+ )}
+ <Detail>
+ <DetailLabel>Scope</DetailLabel>
+ <DetailValue>Group</DetailValue>
+ </Detail>
+ <Detail>
+ <DetailLabel>Group</DetailLabel>
+ <DetailValue>{groupName || groupId || "None"}</DetailValue>
+ </Detail>
+ <Detail>
+ <DetailLabel>Scan Projects</DetailLabel>
+ <DetailValue>{shouldScanAll ? "All" : includeProjects.join(", ") || "None"}</DetailValue>
+ </Detail>
</SecretScanningDataSourceConfigReviewSection>
);
};
diff --git a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/SecretScanningDataSourceReviewFields.tsx b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/SecretScanningDataSourceReviewFields.tsx
index 2285cf5ce4..b564e36219 100644
--- a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/SecretScanningDataSourceReviewFields.tsx
+++ b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/SecretScanningDataSourceReviewFields.tsx
@@ -1,6 +1,12 @@
import { useFormContext } from "react-hook-form";
-import { GenericFieldLabel } from "@app/components/v2";
+import {
+ Detail,
+ DetailGroup,
+ DetailGroupHeader,
+ DetailLabel,
+ DetailValue
+} from "@app/components/v3";
import { SecretScanningDataSource } from "@app/hooks/api/secretScanningV2";
import { TSecretScanningDataSourceForm } from "../schemas";
@@ -24,15 +30,19 @@ export const SecretScanningDataSourceReviewFields = () => {
return (
<div className="mb-4 flex flex-col gap-6">
<Component />
- <div className="flex flex-col gap-3">
- <div className="w-full border-b border-border-control">
- <span className="text-sm text-label">Details</span>
- </div>
+ <DetailGroup>
+ <DetailGroupHeader>Details</DetailGroupHeader>
<div className="flex flex-wrap gap-x-8 gap-y-2">
- <GenericFieldLabel label="Name">{name}</GenericFieldLabel>
- <GenericFieldLabel label="Description">{description}</GenericFieldLabel>
+ <Detail>
+ <DetailLabel>Name</DetailLabel>
+ <DetailValue>{name || "None"}</DetailValue>
+ </Detail>
+ <Detail>
+ <DetailLabel>Description</DetailLabel>
+ <DetailValue>{description || "None"}</DetailValue>
+ </Detail>
</div>
- </div>
+ </DetailGroup>
</div>
);
};
diff --git a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/shared/SecretScanningDataSourceConfigReviewSection.tsx b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/shared/SecretScanningDataSourceConfigReviewSection.tsx
index 2b5ff1c2ae..a74ae1e237 100644
--- a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/shared/SecretScanningDataSourceConfigReviewSection.tsx
+++ b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceReviewFields/shared/SecretScanningDataSourceConfigReviewSection.tsx
@@ -1,16 +1,16 @@
import { ReactNode } from "react";
+import { DetailGroup, DetailGroupHeader } from "@app/components/v3";
+
type Props = {
children: ReactNode;
};
export const SecretScanningDataSourceConfigReviewSection = ({ children }: Props) => {
return (
- <div className="flex flex-col gap-3">
- <div className="w-full border-b border-border-control">
- <span className="text-sm text-label">Configuration</span>
- </div>
+ <DetailGroup>
+ <DetailGroupHeader>Configuration</DetailGroupHeader>
<div className="flex flex-wrap gap-x-8 gap-y-2">{children}</div>
- </div>
+ </DetailGroup>
);
};