fix(ui): fix credential profile field names and list response unwrapping
- credentialProfilesApi.list now unwraps {profiles: [...]} wrapper
- CredentialProfilesPage handles both array and wrapped responses
- Renamed privacy_protocol → priv_protocol to match backend schema
- Renamed privacy_passphrase → priv_passphrase to match backend
- Renamed security_name → username (SNMPv3 uses username field)
- Removed security_name from CredentialProfileCreate type
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -119,7 +119,7 @@ export function CredentialProfilesPage({ tenantId }: CredentialProfilesPageProps
|
|||||||
enabled: !!tenantId,
|
enabled: !!tenantId,
|
||||||
})
|
})
|
||||||
|
|
||||||
const profiles = data?.profiles ?? []
|
const profiles = Array.isArray(data) ? data : (data?.profiles ?? [])
|
||||||
const routerosProfiles = profiles.filter((p) => p.credential_type === 'routeros')
|
const routerosProfiles = profiles.filter((p) => p.credential_type === 'routeros')
|
||||||
const snmpProfiles = profiles.filter((p) => p.credential_type.startsWith('snmp_'))
|
const snmpProfiles = profiles.filter((p) => p.credential_type.startsWith('snmp_'))
|
||||||
|
|
||||||
@@ -401,8 +401,8 @@ export function CredentialProfilesPage({ tenantId }: CredentialProfilesPageProps
|
|||||||
<div>
|
<div>
|
||||||
<Label className="text-xs">Security Name</Label>
|
<Label className="text-xs">Security Name</Label>
|
||||||
<Input
|
<Input
|
||||||
value={form.security_name ?? ''}
|
value={form.username ?? ''}
|
||||||
onChange={(e) => updateForm({ security_name: e.target.value })}
|
onChange={(e) => updateForm({ username: e.target.value })}
|
||||||
placeholder={
|
placeholder={
|
||||||
editingProfile ? 'Leave blank to keep current' : 'snmpuser'
|
editingProfile ? 'Leave blank to keep current' : 'snmpuser'
|
||||||
}
|
}
|
||||||
@@ -473,8 +473,8 @@ export function CredentialProfilesPage({ tenantId }: CredentialProfilesPageProps
|
|||||||
<div>
|
<div>
|
||||||
<Label className="text-xs">Privacy Protocol</Label>
|
<Label className="text-xs">Privacy Protocol</Label>
|
||||||
<Select
|
<Select
|
||||||
value={form.privacy_protocol ?? 'AES128'}
|
value={form.priv_protocol ?? 'AES128'}
|
||||||
onValueChange={(v) => updateForm({ privacy_protocol: v })}
|
onValueChange={(v) => updateForm({ priv_protocol: v })}
|
||||||
>
|
>
|
||||||
<SelectTrigger className="mt-1">
|
<SelectTrigger className="mt-1">
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
@@ -492,9 +492,9 @@ export function CredentialProfilesPage({ tenantId }: CredentialProfilesPageProps
|
|||||||
<Label className="text-xs">Privacy Passphrase</Label>
|
<Label className="text-xs">Privacy Passphrase</Label>
|
||||||
<Input
|
<Input
|
||||||
type="password"
|
type="password"
|
||||||
value={form.privacy_passphrase ?? ''}
|
value={form.priv_passphrase ?? ''}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateForm({ privacy_passphrase: e.target.value })
|
updateForm({ priv_passphrase: e.target.value })
|
||||||
}
|
}
|
||||||
placeholder={
|
placeholder={
|
||||||
editingProfile ? 'Leave blank to keep current' : ''
|
editingProfile ? 'Leave blank to keep current' : ''
|
||||||
|
|||||||
@@ -491,9 +491,8 @@ export interface CredentialProfileCreate {
|
|||||||
security_level?: string
|
security_level?: string
|
||||||
auth_protocol?: string
|
auth_protocol?: string
|
||||||
auth_passphrase?: string
|
auth_passphrase?: string
|
||||||
privacy_protocol?: string
|
priv_protocol?: string
|
||||||
privacy_passphrase?: string
|
priv_passphrase?: string
|
||||||
security_name?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CredentialProfileUpdate extends Partial<CredentialProfileCreate> {}
|
export interface CredentialProfileUpdate extends Partial<CredentialProfileCreate> {}
|
||||||
@@ -505,7 +504,7 @@ export const credentialProfilesApi = {
|
|||||||
`/api/tenants/${tenantId}/credential-profiles`,
|
`/api/tenants/${tenantId}/credential-profiles`,
|
||||||
{ params: credentialType ? { credential_type: credentialType } : undefined },
|
{ params: credentialType ? { credential_type: credentialType } : undefined },
|
||||||
)
|
)
|
||||||
.then((r) => r.data),
|
.then((r) => r.data.profiles),
|
||||||
|
|
||||||
get: (tenantId: string, profileId: string) =>
|
get: (tenantId: string, profileId: string) =>
|
||||||
api
|
api
|
||||||
|
|||||||
Reference in New Issue
Block a user