fleet/website/api/controllers/view-pricing.js
Eric 37682f2047
Website: Change pricing table based on selected use case (#12148)
Closes #11965

Changes:
- Updated the pricing table on the pricing page to be rendered by the
server.
- Updated the pricing page's view action to create another version of
the pricing table that does not have the "Device management" category
and that has security features sorted to the top of the table.
- Moved two features from the "Device management" category to "Security
and compliance" in `pricing-features-table.yml`.
2023-06-09 16:52:39 -05:00

69 lines
2.0 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View pricing',
description: 'Display "Pricing" page.',
exits: {
success: {
viewTemplatePath: 'pages/pricing'
},
badConfig: {
responseType: 'badConfig'
},
},
fn: async function () {
if(!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.pricingTable)) {
throw {badConfig: 'builtStaticContent.pricingTable'};
}
let pricingTable = sails.config.builtStaticContent.pricingTable;
// Create a filtered version of the pricing table array that does not have the "Device management" category that will be used for the security-focused pricing table.
let pricingTableForSecurity = pricingTable.filter((category)=>{
return category.categoryName !== 'Device management';
});
// Create an array used to sort the pricing table for secuirty focused buyers
// To change the order of the pricing table for the security focused buyers, rearrange the values in the array below.
// Note: The category names must match existing categories in the pricing-features-table.yml file.
let categoryOrderForSecurityPricingTable = [
'Security and compliance',
'Monitoring',
'Inventory management',
'Collaboration',
'Support',
'Data outputs',
'Deployment'
];
// 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);
});
// Respond with view.
return {
pricingTable,
pricingTableForSecurity,
};
}
};