diff --git a/packages/manager/apps/web/client/app/hosting/database/order/public/hosting-database-order-public.constants.js b/packages/manager/apps/web/client/app/hosting/database/order/public/hosting-database-order-public.constants.js index cae6c531c9f2..808427afc165 100644 --- a/packages/manager/apps/web/client/app/hosting/database/order/public/hosting-database-order-public.constants.js +++ b/packages/manager/apps/web/client/app/hosting/database/order/public/hosting-database-order-public.constants.js @@ -1,21 +1,30 @@ export const PRODUCT_NAME = 'webHosting'; +export const DATACENTER_CONFIGURATION_KEY = 'dc'; + +export const ENGINE_CONFIGURATION_KEY = 'engine'; + export const DB_OFFERS = { STARTER: { PLAN_CODE_PREFIX: 'sql_optional_', CATEGORY: 'starter', FAMILY: null, TRACKING: 'Start_SQL', + PRODUCT_NAME: 'webHosting', }, PRIVATE: { PLAN_CODE_PREFIX: 'private_sql_', CATEGORY: 'private', FAMILY: 'cloud-db', TRACKING: 'Web_Cloud_database', + PRODUCT_NAME: 'cloudDB', }, }; -export const OFFERS_WITHOUT_START_SQL = ['HOSTING_STARTER']; +export const OFFERS_WITHOUT_START_SQL = [ + 'HOSTING_STARTER', + 'HOSTING_STARTER_OVH', +]; export const REGEX_DB_OFFER_SORT = /(?:-|_)(\d+)(?:-|_)/; @@ -24,4 +33,6 @@ export default { DB_OFFERS, REGEX_DB_OFFER_SORT, OFFERS_WITHOUT_START_SQL, + DATACENTER_CONFIGURATION_KEY, + ENGINE_CONFIGURATION_KEY, }; diff --git a/packages/manager/apps/web/client/app/hosting/database/order/public/hosting-database-order-public.controller.js b/packages/manager/apps/web/client/app/hosting/database/order/public/hosting-database-order-public.controller.js index c74ecf1af767..8cd0db16def0 100644 --- a/packages/manager/apps/web/client/app/hosting/database/order/public/hosting-database-order-public.controller.js +++ b/packages/manager/apps/web/client/app/hosting/database/order/public/hosting-database-order-public.controller.js @@ -4,7 +4,11 @@ import { } from '@ovh-ux/manager-product-offers'; import { WEBHOSTING_PRODUCT_NAME } from '../../hosting-database.constants'; -import { DB_OFFERS } from './hosting-database-order-public.constants'; +import { + DB_OFFERS, + DATACENTER_CONFIGURATION_KEY, + ENGINE_CONFIGURATION_KEY, +} from './hosting-database-order-public.constants'; import { DATABASES_TRACKING } from '../../../hosting.constants'; export default class HostingDatabaseOrderPublicCtrl { @@ -20,10 +24,11 @@ export default class HostingDatabaseOrderPublicCtrl { workflowOptions: { catalog, catalogItemTypeName, - productName: WEBHOSTING_PRODUCT_NAME, - serviceNameToAddProduct: this.serviceName, + productName: this.getProductName.bind(this), + serviceNameToAddProduct: this.getServiceNameToAddProduct.bind(this), getPlanCode: this.getPlanCode.bind(this), getRightCatalogConfig: this.getRightCatalogConfig.bind(this), + onGetConfiguration: this.getOnGetConfiguration.bind(this), }, workflowType: workflowConstants.WORKFLOW_TYPES.ORDER, }; @@ -39,6 +44,41 @@ export default class HostingDatabaseOrderPublicCtrl { return selectEngineVersion?.planCode || selectVersion?.planCode; } + getProductName() { + const { productName } = this.model.dbCategory; + return productName; + } + + getServiceNameToAddProduct() { + return this.model.dbCategory.productName === WEBHOSTING_PRODUCT_NAME + ? this.serviceName + : ''; + } + + getOnGetConfiguration() { + const { productName } = this.model.dbCategory; + if (productName === DB_OFFERS.PRIVATE.PRODUCT_NAME) { + const { db } = this.model.dbCategory.selectEngine.selectEngineVersion; + const [ + datacenterValue, + ] = this.model.dbCategory.selectVersion.configurations.find( + (item) => item.name === DATACENTER_CONFIGURATION_KEY, + )?.values; + + return [ + { + label: ENGINE_CONFIGURATION_KEY, + value: db, + }, + { + label: DATACENTER_CONFIGURATION_KEY, + value: datacenterValue, + }, + ]; + } + return []; + } + isValidDbConfig() { const { category, selectVersion, selectEngine } = this.model.dbCategory; const { selectEngineVersion } = selectEngine || {}; diff --git a/packages/manager/apps/web/client/app/hosting/database/order/public/hosting-database-order-public.service.js b/packages/manager/apps/web/client/app/hosting/database/order/public/hosting-database-order-public.service.js index fbe627c40d9a..813b8641c1c0 100644 --- a/packages/manager/apps/web/client/app/hosting/database/order/public/hosting-database-order-public.service.js +++ b/packages/manager/apps/web/client/app/hosting/database/order/public/hosting-database-order-public.service.js @@ -156,15 +156,17 @@ export default class { [DB_OFFERS.STARTER.CATEGORY]: { versions: startSqlCategory, tracking: DB_OFFERS.STARTER.TRACKING, + productName: DB_OFFERS.STARTER.PRODUCT_NAME, }, }), [DB_OFFERS.PRIVATE.CATEGORY]: { versions: webCloudCategory, tracking: DB_OFFERS.PRIVATE.TRACKING, + productName: DB_OFFERS.PRIVATE.PRODUCT_NAME, }, }; const dbCategories = Object.keys(groupedCategories).map((category) => { - const { versions, tracking } = groupedCategories[category]; + const { versions, tracking, productName } = groupedCategories[category]; return { category, @@ -172,6 +174,7 @@ export default class { tracking, selectVersion: versions[0], selectEngine: null, + productName, }; }); diff --git a/packages/manager/modules/product-offers/src/workflows/product-offers-order-workflow.class.js b/packages/manager/modules/product-offers/src/workflows/product-offers-order-workflow.class.js index 8be9f9945c43..338e7471bd40 100644 --- a/packages/manager/modules/product-offers/src/workflows/product-offers-order-workflow.class.js +++ b/packages/manager/modules/product-offers/src/workflows/product-offers-order-workflow.class.js @@ -165,7 +165,9 @@ export default class OrderWorkflow extends Workflow { configuration, }; - const serviceName = this.serviceNameToAddProduct; + const serviceName = isFunction(this.serviceNameToAddProduct) + ? this.serviceNameToAddProduct() + : this.serviceNameToAddProduct; return this.$q .when() @@ -174,13 +176,17 @@ export default class OrderWorkflow extends Workflow { isString(serviceName) && !isEmpty(serviceName) ? this.WucOrderCartService.addProductServiceOptionToCart( this.cartId, - this.productName, + isFunction(this.productName) + ? this.productName() + : this.productName, serviceName, checkoutInformations.product, ) : this.WucOrderCartService.addProductToCart( this.cartId, - this.productName, + isFunction(this.productName) + ? this.productName() + : this.productName, checkoutInformations.product, ), )