feat(secret-sync): add PR suggestions for Zabbix secret sync

This commit is contained in:
Carlos Monastyrski
2025-07-02 10:18:20 -03:00
parent 307e6900ee
commit 9163da291e
5 changed files with 34 additions and 33 deletions
@@ -7,6 +7,7 @@ import {
TZabbixHost,
useZabbixConnectionListHosts,
ZABBIX_SYNC_SCOPES,
ZabbixMacroType,
ZabbixSyncScope
} from "@app/hooks/api/appConnections/zabbix";
import { SecretSync } from "@app/hooks/api/secretSyncs";
@@ -120,7 +121,7 @@ export const ZabbixSyncFields = () => {
<Controller
control={control}
name="destinationConfig.macroType"
defaultValue={0}
defaultValue={ZabbixMacroType.Secret}
render={({ field: { onChange, value }, fieldState: { error } }) => (
<FormControl isError={Boolean(error)} errorText={error?.message} label="Macro Type">
<Select
@@ -131,10 +132,10 @@ export const ZabbixSyncFields = () => {
placeholder="Select a macro type..."
dropdownContainerClassName="max-w-none"
>
<SelectItem value="0" key="text">
<SelectItem value={String(ZabbixMacroType.Text)} key="text">
Text
</SelectItem>
<SelectItem value="1" key="secret">
<SelectItem value={String(ZabbixMacroType.Secret)} key="secret">
Secret
</SelectItem>
</Select>
@@ -1,7 +1,7 @@
import { z } from "zod";
import { BaseSecretSyncSchema } from "@app/components/secret-syncs/forms/schemas/base-secret-sync-schema";
import { ZabbixSyncScope } from "@app/hooks/api/appConnections/zabbix";
import { ZabbixMacroType, ZabbixSyncScope } from "@app/hooks/api/appConnections/zabbix";
import { SecretSync } from "@app/hooks/api/secretSyncs";
export const ZabbixSyncDestinationSchema = BaseSecretSyncSchema().merge(
@@ -12,11 +12,15 @@ export const ZabbixSyncDestinationSchema = BaseSecretSyncSchema().merge(
scope: z.literal(ZabbixSyncScope.Host),
hostId: z.string().trim().min(1, "Host ID required"),
hostName: z.string().trim().min(1, "Host name required"),
macroType: z.number().min(0, "Macro type required").max(1, "Macro type required")
macroType: z.nativeEnum(ZabbixMacroType, {
errorMap: () => ({ message: "Macro type must be either 'text' or 'secret'" })
})
}),
z.object({
scope: z.literal(ZabbixSyncScope.Global),
macroType: z.number().min(0, "Macro type required").max(1, "Macro type required")
macroType: z.nativeEnum(ZabbixMacroType, {
errorMap: () => ({ message: "Macro type must be either 'text' or 'secret'" })
})
})
])
})