Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web.hosting): fix the order of web cloud database #9734

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
ghyenne marked this conversation as resolved.
Show resolved Hide resolved

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() {
darsene marked this conversation as resolved.
Show resolved Hide resolved
const { productName } = this.model.dbCategory;
return productName;
}

getServiceNameToAddProduct() {
darsene marked this conversation as resolved.
Show resolved Hide resolved
return this.model.dbCategory.productName === WEBHOSTING_PRODUCT_NAME
? this.serviceName
: '';
}

getOnGetConfiguration() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getOnGet ? the function name is not very clear

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just add get begining the name of object required by product offer module

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)
darsene marked this conversation as resolved.
Show resolved Hide resolved
? 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,
darsene marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +179 to +181
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: This is pretty confusing. Can we just maintain this.productName to be always string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact i need to have something to dynamic. Because in my order funnel database the all type of database haven't same product name and one need service name because is an option other no because is individual service.

serviceName,
checkoutInformations.product,
)
: this.WucOrderCartService.addProductToCart(
this.cartId,
this.productName,
isFunction(this.productName)
? this.productName()
: this.productName,
darsene marked this conversation as resolved.
Show resolved Hide resolved
checkoutInformations.product,
),
)
Expand Down
Loading