Website: fix pricing table filtering (#20912)

Changes:
- Fixed the IT and Security filtering on the pricing features table.
This commit is contained in:
Eric 2024-07-31 17:25:18 -05:00 committed by GitHub
parent 8b5094ff37
commit 6fd628463d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -44,36 +44,39 @@ module.exports = {
pricingTable.push(allFeaturesInThisCategory);
}
let pricingTableForSecurity = _.filter(pricingTable, (category)=>{
return category.categoryName !== 'Device management' && (category.usualDepartment === 'Security' || category.usualDepartment === undefined);
});
let pricingTableForSecurity = [];
let categoryOrderForSecurityPricingTable = ['Support', 'Deployment', 'Integrations', 'Endpoint operations', 'Vulnerability management'];
// Sort the security-focused pricing table from the order of the elements in the categoryOrderForSecurityPricingTable array.
pricingTableForSecurity.sort((a, b)=>{
// If there is a category that is not in the list above, sort it to the end of the list.
if(categoryOrderForSecurityPricingTable.indexOf(a.categoryName) === -1){
return 1;
} else if(categoryOrderForSecurityPricingTable.indexOf(b.categoryName) === -1) {
return -1;
}
return categoryOrderForSecurityPricingTable.indexOf(a.categoryName) - categoryOrderForSecurityPricingTable.indexOf(b.categoryName);
});
for(let category of categoryOrderForSecurityPricingTable) {
// Get all the features in that have a pricingTableFeatures array that contains this category.
let featuresInThisCategory = _.filter(pricingTableFeatures, (feature)=>{
return _.contains(feature.pricingTableCategories, category) && (feature.usualDepartment === 'Security' || feature.usualDepartment === undefined);
});
// Build a dictionary containing the category name, and all features in the category
let allSecurityFeaturesInThisCategory = {
categoryName: category,
features: featuresInThisCategory,
};
// Add the dictionaries to the arrays that we'll use to build the features table.
pricingTableForSecurity.push(allSecurityFeaturesInThisCategory);
}
let pricingTableForIt = _.filter(pricingTable, (category)=>{
return category.categoryName !== 'Vulnerability management' && (category.usualDepartment === 'Security' || category.usualDepartment === undefined);
});
let categoryOrderForITPricingTable = [ 'Deployment','Device management', 'Endpoint operations', 'Integrations', 'Support'];
let pricingTableForIt = [];
// Sort the IT-focused pricing table from the order of the elements in the categoryOrderForITPricingTable array.
pricingTableForIt.sort((a, b)=>{
// If there is a category that is not in the list above, sort it to the end of the list.
if(categoryOrderForITPricingTable.indexOf(a.categoryName) === -1){
return 1;
} else if(categoryOrderForITPricingTable.indexOf(b.categoryName) === -1) {
return -1;
}
return categoryOrderForITPricingTable.indexOf(a.categoryName) - categoryOrderForITPricingTable.indexOf(b.categoryName);
});
for(let category of categoryOrderForITPricingTable) {
// Get all the features in that have a pricingTableFeatures array that contains this category.
let featuresInThisCategory = _.filter(pricingTableFeatures, (feature)=>{
return _.contains(feature.pricingTableCategories, category) && (feature.usualDepartment === 'IT' || feature.usualDepartment === undefined);
});
// Build a dictionary containing the category name, and all features in the category, sorting premium features to the bottom of the list.
let allItFeaturesInThisCategory = {
categoryName: category,
features: featuresInThisCategory,
};
// Add the dictionaries to the arrays that we'll use to build the features table.
pricingTableForIt.push(allItFeaturesInThisCategory);
}
// Respond with view.