diff --git a/backend/src/services/secret-sync/zabbix/zabbix-sync-fns.ts b/backend/src/services/secret-sync/zabbix/zabbix-sync-fns.ts index a4048f312..18f9061ec 100644 --- a/backend/src/services/secret-sync/zabbix/zabbix-sync-fns.ts +++ b/backend/src/services/secret-sync/zabbix/zabbix-sync-fns.ts @@ -46,6 +46,9 @@ const handleZabbixResponse = (response: ZabbixApiResponse): T => { const listZabbixSecrets = async (apiToken: string, instanceUrl: string, hostId?: string): Promise => { const apiUrl = `${instanceUrl.replace(TRAILING_SLASH_REGEX, "")}/api_jsonrpc.php`; + // - jsonrpc: Specifies the JSON-RPC protocol version. + // - method: The API method to call, in this case "usermacro.get" for retrieving user macros. + // - id: A unique identifier for the request. Required by JSON-RPC but not used by the API for logic. Typically set to any integer. const payload = { jsonrpc: "2.0" as const, method: "usermacro.get", diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/ZabbixSyncFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/ZabbixSyncFields.tsx index 45ab7bbaa..e00100284 100644 --- a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/ZabbixSyncFields.tsx +++ b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/ZabbixSyncFields.tsx @@ -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 = () => { ( diff --git a/frontend/src/components/secret-syncs/forms/schemas/zabbix-sync-destination-schema.ts b/frontend/src/components/secret-syncs/forms/schemas/zabbix-sync-destination-schema.ts index ae3a279a1..694c6c7af 100644 --- a/frontend/src/components/secret-syncs/forms/schemas/zabbix-sync-destination-schema.ts +++ b/frontend/src/components/secret-syncs/forms/schemas/zabbix-sync-destination-schema.ts @@ -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'" }) + }) }) ]) }) diff --git a/frontend/src/hooks/api/appConnections/zabbix/types.ts b/frontend/src/hooks/api/appConnections/zabbix/types.ts index c5bc1424c..be33ffca2 100644 --- a/frontend/src/hooks/api/appConnections/zabbix/types.ts +++ b/frontend/src/hooks/api/appConnections/zabbix/types.ts @@ -8,6 +8,11 @@ export enum ZabbixSyncScope { Global = "global" } +export enum ZabbixMacroType { + Text = 0, + Secret = 1 +} + export const ZABBIX_SYNC_SCOPES = { [ZabbixSyncScope.Host]: { name: "Host", diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/ZabbixConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/ZabbixConnectionForm.tsx index 93746a8c6..72bbd03f7 100644 --- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/ZabbixConnectionForm.tsx +++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/ZabbixConnectionForm.tsx @@ -2,15 +2,7 @@ import { Controller, FormProvider, useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { - Button, - FormControl, - Input, - ModalClose, - SecretInput, - Select, - SelectItem -} from "@app/components/v2"; +import { Button, FormControl, Input, ModalClose, Select, SelectItem } from "@app/components/v2"; import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections"; import { TZabbixConnection, ZabbixConnectionMethod } from "@app/hooks/api/appConnections"; import { AppConnection } from "@app/hooks/api/appConnections/enums"; @@ -93,6 +85,20 @@ export const ZabbixConnectionForm = ({ appConnection, onSubmit }: Props) => { )} /> + ( + + + + )} + /> { )} /> - ( - - onChange(e.target.value)} - /> - - )} - />