From 27e6f2dcf1c11194cd02b1625c64d2df0f55485f Mon Sep 17 00:00:00 2001 From: Sachin Ramesh Date: Wed, 25 Sep 2024 08:51:19 +0530 Subject: [PATCH] feat(dedicated.ip): select multiple countries for block ip ref: MANAGER-14569 Signed-off-by: Sachin Ramesh --- .../ip/agoraOrder/ipv4/ipv4.controller.js | 21 +++++++++++++++++-- 1 file changed, 19 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 fcc9836ab293..8bb2bc462ba7 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 @@ -261,6 +261,17 @@ export default class AgoraIpV4OrderController { )?.labels; } + static getCountriesFromDatacenter(selectedServiceDatacenter, ipOffers) { + const ipOffer = ipOffers.find((offer) => { + return offer.details.product.configurations + .find((config) => config.name === 'datacenter') + ?.values?.includes(selectedServiceDatacenter); + }); + return ipOffer.details.product.configurations.find( + (config) => config.name === 'country', + )?.values; + } + loadPrivateCloudIpOffers(serviceName) { const countries = this.orderableIpCountries.map((code) => { return { @@ -392,9 +403,15 @@ export default class AgoraIpV4OrderController { get(this.model, 'selectedService.serviceName'), ); } else if (this.isParkingIp) { - const countries = [ + // Country for Single IP selection in parking + const country = [ DATACENTER_TO_COUNTRY[this.model.selectedRegion.datacenter], ]; + // Multiple countries are available for block IP selection in parking and vrack + const countries = AgoraIpV4OrderController.getCountriesFromDatacenter( + this.model.selectedRegion.datacenter, + this.parkingIpOffers, + ).map((value) => value.toLowerCase()); const ipOfferDetails = this.parkingIpOffers.map( this.createOfferDto.bind(this), ); @@ -414,7 +431,7 @@ export default class AgoraIpV4OrderController { this.failoverIpOffers = this.getOfferDetails( failoverIpOfferDetails, ipOffersByDatacenter, - countries, + country, ); this.blockIpOffers = this.getOfferDetails( blockIpOfferDetails,