From a6e81d1511d1e51d8d75f85775c0b1abda031c73 Mon Sep 17 00:00:00 2001 From: soufien mhelhali Date: Thu, 31 Oct 2024 06:00:12 +0100 Subject: [PATCH] feat(dedicated): correct filter --- .../ip/agoraOrder/ipv4/ipv4.controller.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/manager/apps/dedicated/client/app/components/ip/agoraOrder/ipv4/ipv4.controller.js b/packages/manager/apps/dedicated/client/app/components/ip/agoraOrder/ipv4/ipv4.controller.js index 4065b9f72575..a1b8062f1a22 100644 --- a/packages/manager/apps/dedicated/client/app/components/ip/agoraOrder/ipv4/ipv4.controller.js +++ b/packages/manager/apps/dedicated/client/app/components/ip/agoraOrder/ipv4/ipv4.controller.js @@ -6,6 +6,7 @@ import get from 'lodash/get'; import head from 'lodash/head'; import intersection from 'lodash/intersection'; import last from 'lodash/last'; +import first from 'lodash/first'; import map from 'lodash/map'; import range from 'lodash/range'; import uniq from 'lodash/uniq'; @@ -79,6 +80,7 @@ export default class AgoraIpV4OrderController { params: {}, selectedService: null, selectedServiceRegion: null, + region: null, }; this.loading = {}; this.user = this.$state.params.user; @@ -225,6 +227,7 @@ export default class AgoraIpV4OrderController { request.then((region) => { if (region) { + this.model.region = region; this.model.selectedServiceRegion = this.model.selectedService?.type === PRODUCT_TYPES.dedicatedServer.typeName @@ -271,7 +274,19 @@ export default class AgoraIpV4OrderController { }); return ipOffer.details.product.configurations.find( (config) => config.name === 'country', - )?.values; + )?.values; + } + + static getRegionFromServiceRegion(region) { + const serviceExt = first(region.split('-')); + if (serviceExt === 'eu') { + return SERVER_REGION.EUROPE; + } + if (serviceExt === 'ca') { + return SERVER_REGION.CANADA; + } + + return SERVER_REGION.USA; } loadPrivateCloudIpOffers(serviceName) { @@ -400,6 +415,9 @@ export default class AgoraIpV4OrderController { const REGION = AgoraIpV4OrderController.getRegionFromServiceName( this.model.selectedService.serviceName, ); + const serviceRegion = + this.model.region && + AgoraIpV4OrderController.getRegionFromServiceRegion(this.model.region); this.isPrivateCloudOffer = this.model?.selectedService?.type === PRODUCT_TYPES.privateCloud.typeName; @@ -515,7 +533,7 @@ export default class AgoraIpV4OrderController { (organisations) => { let registry = null; - switch (REGION) { + switch (serviceRegion) { case SERVER_REGION.EUROPE: registry = ORGANISATION_GROUP.RIPE; break; @@ -526,6 +544,7 @@ export default class AgoraIpV4OrderController { default: registry = null; } + this.organisations = registry ? organisations.filter((org) => org.registry === registry) : organisations;