diff --git a/packages/frinx-dashboard/src/api/unistore/converters.ts b/packages/frinx-dashboard/src/api/unistore/converters.ts index 8fbee7f7a..fe31e4618 100644 --- a/packages/frinx-dashboard/src/api/unistore/converters.ts +++ b/packages/frinx-dashboard/src/api/unistore/converters.ts @@ -133,7 +133,7 @@ export function apiRoutingProtocolToClientRoutingProtocol(routingProtocol: Routi bgp: bgpProtocol ? { addressFamily: 'ipv4', - autonomousSystem: bgpProtocol['autonomous-system'], + autonomousSystem: String(bgpProtocol['autonomous-system']), bgpProfile: bgpProtocol['bgp-profiles']['bgp-profile'][0].profile, } : undefined, @@ -151,9 +151,12 @@ export function apiSiteNetworkAccessToClientSiteNetworkAccess( const apiQosProfiles = access.service.qos['qos-profile']['qos-profile']; const [clientQosProfile] = apiQosProfiles.length ? apiQosProfiles.map((p) => p.profile) : ['']; const vpnAttachment = access['vpn-attachment'] ? access['vpn-attachment']['vpn-id'] : null; - const routingProtocols = access['routing-protocols']['routing-protocol'].map((p) => { - return apiRoutingProtocolToClientRoutingProtocol(p); - }); + const routingProtocols = + access['routing-protocols'] && access['routing-protocols']['routing-protocol'] + ? access['routing-protocols']['routing-protocol'].map((p) => { + return apiRoutingProtocolToClientRoutingProtocol(p); + }) + : []; return { siteNetworkAccessId: access['site-network-access-id'], siteNetworkAccessType: access['site-network-access-type'] as SiteNetworkAccessType, @@ -260,7 +263,7 @@ function isValidProtocolPredicate(routingProtocol: RoutingProtocol): boolean { if (!routingProtocol.bgp) { return false; } - return !(!routingProtocol.bgp.bgpProfile || !routingProtocol.bgp.autonomousSystem); + return routingProtocol.bgp.bgpProfile !== null && routingProtocol.bgp.autonomousSystem.length > 0; } return false; @@ -282,7 +285,7 @@ function clientRoutingProtocolsToApiRoutingProtocols(routingProtocols: RoutingPr 'bgp-profile': [{ profile: p.bgp.bgpProfile || '' }] as [{ profile: string }], }, 'address-family': ['ipv4'] as ['ipv4'], - 'autonomous-system': p.bgp.autonomousSystem, + 'autonomous-system': Number(p.bgp.autonomousSystem), }; } if (p.static) { diff --git a/packages/frinx-dashboard/src/api/unistore/network-types.ts b/packages/frinx-dashboard/src/api/unistore/network-types.ts index b379e4414..56a9f06ee 100644 --- a/packages/frinx-dashboard/src/api/unistore/network-types.ts +++ b/packages/frinx-dashboard/src/api/unistore/network-types.ts @@ -214,7 +214,7 @@ export function decodeRoutingProtocolItemOutput(value: unknown): RoutingProtocol } const RoutingProtocolsValidator = t.type({ - 'routing-protocol': t.array(RoutingProtocolItemValidator), + 'routing-protocol': optional(t.array(RoutingProtocolItemValidator)), }); export type RoutingProtocolsOutput = t.TypeOf; @@ -291,7 +291,7 @@ const SiteNetworkAccessValidator = t.type({ }), }), }), - 'routing-protocols': RoutingProtocolsValidator, + 'routing-protocols': optional(RoutingProtocolsValidator), }), ), }); @@ -738,7 +738,7 @@ export type StaticRoutingType = { }; export type BgpRoutingType = { addressFamily: 'ipv4'; - autonomousSystem: number; + autonomousSystem: string; bgpProfile: string | null; }; export type RoutingProtocol = { diff --git a/packages/frinx-dashboard/src/api/unistore/unistore.ts b/packages/frinx-dashboard/src/api/unistore/unistore.ts index 71f96e882..4bc2fac3d 100644 --- a/packages/frinx-dashboard/src/api/unistore/unistore.ts +++ b/packages/frinx-dashboard/src/api/unistore/unistore.ts @@ -46,7 +46,7 @@ export async function createVpnService(vpnService: VpnService): Promise { } export async function getVpnSites(): Promise { - const json = await sendGetRequest(`${UNICONFIG_SERVICE_URL}/gamma-l3vpn-svc:l3vpn-svc/sites`); + const json = await sendGetRequest(`${UNICONFIG_SERVICE_URL}/gamma-l3vpn-svc:l3vpn-svc/sites?content=config`); const data = decodeVpnSitesOutput(json); return data; } diff --git a/packages/frinx-gamma/src/components/forms/converters.ts b/packages/frinx-gamma/src/components/forms/converters.ts index 7b48bc212..818f51606 100644 --- a/packages/frinx-gamma/src/components/forms/converters.ts +++ b/packages/frinx-gamma/src/components/forms/converters.ts @@ -128,7 +128,7 @@ export function apiRoutingProtocolToClientRoutingProtocol(routingProtocol: Routi bgp: bgpProtocol ? { addressFamily: 'ipv4', - autonomousSystem: bgpProtocol['autonomous-system'], + autonomousSystem: String(bgpProtocol['autonomous-system']), bgpProfile: bgpProtocol['bgp-profiles']['bgp-profile'][0].profile, } : undefined, @@ -174,9 +174,12 @@ export function apiSiteNetworkAccessToClientSiteNetworkAccess( const apiQosProfiles = access.service.qos['qos-profile']['qos-profile']; const [clientQosProfile] = apiQosProfiles.length ? apiQosProfiles.map((p) => p.profile) : ['']; const vpnAttachment = access['vpn-attachment'] ? access['vpn-attachment']['vpn-id'] : null; - const routingProtocols = access['routing-protocols']['routing-protocol'].map((p) => { - return apiRoutingProtocolToClientRoutingProtocol(p); - }); + const routingProtocols = + access['routing-protocols'] && access['routing-protocols']['routing-protocol'] + ? access['routing-protocols']['routing-protocol'].map((p) => { + return apiRoutingProtocolToClientRoutingProtocol(p); + }) + : []; return { siteNetworkAccessId: access['site-network-access-id'], siteNetworkAccessType: access['site-network-access-type'] as SiteNetworkAccessType, @@ -306,7 +309,7 @@ function clientRoutingProtocolsToApiRoutingProtocols(routingProtocols: RoutingPr 'bgp-profile': [{ profile: p.bgp.bgpProfile || '' }] as [{ profile: string }], }, 'address-family': ['ipv4'] as ['ipv4'], - 'autonomous-system': p.bgp.autonomousSystem, + 'autonomous-system': Number(p.bgp.autonomousSystem), }; } if (p.static) { diff --git a/packages/frinx-gamma/src/components/forms/routing-protocol-form.tsx b/packages/frinx-gamma/src/components/forms/routing-protocol-form.tsx index d1772f81b..af5325f8d 100644 --- a/packages/frinx-gamma/src/components/forms/routing-protocol-form.tsx +++ b/packages/frinx-gamma/src/components/forms/routing-protocol-form.tsx @@ -111,11 +111,10 @@ const RoutingProtocolForm: VoidFunctionComponent = ({ { - const value = Number(event.target.value); - - if (Number.isNaN(value)) { + const { value } = event.target; + if (Number.isNaN(Number(value))) { return; } @@ -124,7 +123,7 @@ const RoutingProtocolForm: VoidFunctionComponent = ({ type: 'bgp', bgp: { ...oldBgpRoutingProtocol, - autonomousSystem: Number(value), + autonomousSystem: value, }, }; const newProtocols = [newBgpRoutingProtocol, staticProtocol]; diff --git a/packages/frinx-gamma/src/components/forms/site-network-access-form.tsx b/packages/frinx-gamma/src/components/forms/site-network-access-form.tsx index f900164c8..dd50399e8 100644 --- a/packages/frinx-gamma/src/components/forms/site-network-access-form.tsx +++ b/packages/frinx-gamma/src/components/forms/site-network-access-form.tsx @@ -44,7 +44,7 @@ function getDefaultBgpRoutingProtocol(): RoutingProtocol { type: 'bgp', bgp: { addressFamily: 'ipv4', - autonomousSystem: 0, + autonomousSystem: '', bgpProfile: null, }, }; diff --git a/packages/frinx-gamma/src/components/forms/site-types.ts b/packages/frinx-gamma/src/components/forms/site-types.ts index 2d8a8477b..31b319ebd 100644 --- a/packages/frinx-gamma/src/components/forms/site-types.ts +++ b/packages/frinx-gamma/src/components/forms/site-types.ts @@ -53,7 +53,7 @@ export type StaticRoutingType = { }; export type BgpRoutingType = { addressFamily: 'ipv4'; - autonomousSystem: number; + autonomousSystem: string; bgpProfile: string | null; }; export type RoutingProtocol = { diff --git a/packages/frinx-gamma/src/network-types.ts b/packages/frinx-gamma/src/network-types.ts index b34886dba..8f830bd0e 100644 --- a/packages/frinx-gamma/src/network-types.ts +++ b/packages/frinx-gamma/src/network-types.ts @@ -216,7 +216,7 @@ export function decodeRoutingProtocolItemOutput(value: unknown): RoutingProtocol } const RoutingProtocolsValidator = t.type({ - 'routing-protocol': t.array(RoutingProtocolItemValidator), + 'routing-protocol': optional(t.array(RoutingProtocolItemValidator)), }); export type RoutingProtocolsOutput = t.TypeOf; @@ -293,7 +293,7 @@ const SiteNetworkAccessValidator = t.type({ }), }), }), - 'routing-protocols': RoutingProtocolsValidator, + 'routing-protocols': optional(RoutingProtocolsValidator), }), ), }); diff --git a/packages/frinx-gamma/src/pages/create-site-network-access/create-site-network-access.tsx b/packages/frinx-gamma/src/pages/create-site-network-access/create-site-network-access.tsx index a53e8867f..bce06eb29 100644 --- a/packages/frinx-gamma/src/pages/create-site-network-access/create-site-network-access.tsx +++ b/packages/frinx-gamma/src/pages/create-site-network-access/create-site-network-access.tsx @@ -26,7 +26,7 @@ const getDefaultNetworkAccess = (): SiteNetworkAccess => ({ vrrp: 'ipv4', bgp: { addressFamily: 'ipv4', - autonomousSystem: 0, + autonomousSystem: '', bgpProfile: null, }, static: [ diff --git a/packages/frinx-gamma/src/pages/edit-site-network-access/edit-site-network-access.tsx b/packages/frinx-gamma/src/pages/edit-site-network-access/edit-site-network-access.tsx index 1d887f381..f1c61f4ad 100644 --- a/packages/frinx-gamma/src/pages/edit-site-network-access/edit-site-network-access.tsx +++ b/packages/frinx-gamma/src/pages/edit-site-network-access/edit-site-network-access.tsx @@ -103,7 +103,7 @@ const EditSiteNetAccessPage: VoidFunctionComponent = ({ onSuccess, onCanc {selectedSite && selectedNetworkAccess && ( <>