import { TIntegrationWithEnv } from "@app/hooks/api/integrations/types"; import { OctopusDeployScopeValues } from "./OctopusDeployScopeValues"; type Props = { integration: TIntegrationWithEnv; }; type Metadata = NonNullable; type MetadataKey = keyof Metadata; type MetadataValue = Metadata[K]; const metadataMappings: Record, string> = { githubVisibility: "Github Visibility", githubVisibilityRepoIds: "Github Visibility Repo Ids", shouldAutoRedeploy: "Auto Redeploy Target Application When Secrets Change", secretAWSTag: "Tags For Secrets Stored In AWS", azureLabel: "Azure Label", kmsKeyId: "AWS KMS Key ID", secretSuffix: "Secret Suffix", secretPrefix: "Secret Prefix", syncBehavior: "Secrets Sync behavior", initialSyncBehavior: "Initial Sync Behavior", mappingBehavior: "Secrets Mapping Behavior", scope: "Scope", org: "Organization", project: "Project", environment: "Environment", shouldDisableDelete: "AWS Secret Deletion Disabled", shouldMaskSecrets: "GitLab Secrets Masking Enabled", shouldProtectSecrets: "GitLab Secret Protection Enabled", shouldEnableDelete: "GitHub Secret Deletion Enabled", octopusDeployScopeValues: "Octopus Deploy Scope Values", awsIamRole: "AWS IAM Role", region: "Region", metadataSyncMode: "Metadata Sync Mode" } as const; export const IntegrationSettingsSection = ({ integration }: Props) => { const renderValue = (key: K, value: MetadataValue) => { if (!value) return null; if (key === "octopusDeployScopeValues") return ; // If it's a boolean, we render a generic "Yes" or "No" response. if (typeof value === "boolean") { return value ? "Yes" : "No"; } // When the value is an object or array, or array of objects, we need to handle some special cases. if (typeof value === "object") { if (key === "secretAWSTag") { return (value as MetadataValue<"secretAWSTag">)!.map(({ key: tagKey, value: tagValue }) => (

{tagKey}={tagValue}

)); } if (key === "githubVisibilityRepoIds") { return (value as string[]).join(", "); } } if (typeof value === "string") { return value.length ? value : "N/A"; } if (typeof value === "number") { return value; } return null; }; if (!integration.metadata || Object.keys(integration.metadata).length === 0) { return null; } // eslint-disable-next-line no-nested-ternary return (

Integration Settings

{integration.metadata && Object.entries(integration.metadata).map(([key, value]) => (

{!!value && metadataMappings[key as keyof typeof metadataMappings]}

{renderValue(key as MetadataKey, value)}

))}
); };