Skip to content

Commit

Permalink
fix(web.hosting): fix the order of web cloud database
Browse files Browse the repository at this point in the history
ref: MANAGER-11651

Signed-off-by: Guillaume Hyenne <[email protected]>
  • Loading branch information
ghyenne committed Jul 27, 2023
1 parent 37c5ddb commit 4540328
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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+)(?:-|_)/;

Expand All @@ -24,4 +33,6 @@ export default {
DB_OFFERS,
REGEX_DB_OFFER_SORT,
OFFERS_WITHOUT_START_SQL,
DATACENTER_CONFIGURATION_KEY,
ENGINE_CONFIGURATION_KEY,
};
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
};
Expand All @@ -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 || {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,25 @@ 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,
versions,
tracking,
selectVersion: versions[0],
selectEngine: null,
productName,
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
),
)
Expand Down

0 comments on commit 4540328

Please sign in to comment.