Skip to content

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

1.5 KB
Raw Blame
import { useFormContext } from "react-hook-form";

import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
import { ReviewField } from "@app/components/secret-rotations-v2/forms/shared";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { SecretRotation } from "@app/hooks/api/secretRotationsV2";

import { SecretRotationReviewSection } from "./shared";

export const HpIloRotationReviewFields = () => {
  const { watch } = useFormContext<
    TSecretRotationV2Form & {
      type: SecretRotation.HpIloLocalAccount;
    }
  >();

  const parameters = watch("parameters");
  const secretsMapping = watch("secretsMapping");
  const isSshConnection = watch("connection.app") !== AppConnection.HpeIloRedFish;

  return (
    <>
      <SecretRotationReviewSection label="Parameters">
        <ReviewField label="Username">{parameters.username}</ReviewField>
        {isSshConnection && (
          <ReviewField label="Rotation Method">
            {parameters.rotationMethod?.replace(/-/g, " ") || "Login as target"}
          </ReviewField>
        )}
        <ReviewField label="Password Length">
          {parameters.passwordRequirements?.length || 32} characters
        </ReviewField>
      </SecretRotationReviewSection>
      <SecretRotationReviewSection label="Secrets Mapping">
        <ReviewField label="Username Key">{secretsMapping.username}</ReviewField>
        <ReviewField label="Password Key">{secretsMapping.password}</ReviewField>
      </SecretRotationReviewSection>
    </>
  );
};