fleet/website/api/controllers/view-pricing.js
Mike Thomas 9041f49d7f
Website: update features on pricing page (#20993)
- Removed duplicate and redundant features
- Reordered features by order of operation from the POV of an IT admin
- Consolidated use cases
- Renamed some features for clarity

See [this
doc](https://docs.google.com/document/d/1z7X__TmJIpRXQF-Mx9NK4EChwkX73fj0ymLnIJM2GnQ/edit?usp=sharing)
for more details, including methodology for the organization and
styling.

---------

Co-authored-by: Eric <[email protected]>
Co-authored-by: Noah Talerman <[email protected]>
2024-08-14 09:32:41 +09:00

92 lines
3.5 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 pricingTableFeatures = sails.config.builtStaticContent.pricingTable;
let pricingTable = [];
let pricingTableCategories = ['Deployment', 'Configuration', 'Devices', 'Integrations', 'Support'];
for(let category of pricingTableCategories) {
// Get all the features in that have a pricingTableFeatures array that contains this category.
let featuresInThisCategory = _.filter(pricingTableFeatures, (feature)=>{
return _.contains(feature.pricingTableCategories, category);
});
// Build a dictionary containing the category name, and all features in the category, sorting premium features to the bottom of the list.
let allFeaturesInThisCategory = {
categoryName: category,
features: featuresInThisCategory,
};
// Add the dictionaries to the arrays that we'll use to build the features table.
pricingTable.push(allFeaturesInThisCategory);
}
let pricingTableForSecurity = [];
let categoryOrderForSecurityPricingTable = ['Deployment', 'Configuration', 'Devices', 'Integrations', 'Support'];
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 categoryOrderForITPricingTable = ['Deployment', 'Configuration', 'Devices', 'Integrations', 'Support'];
let pricingTableForIt = [];
// Sort the IT-focused pricing table from the order of the elements in the categoryOrderForITPricingTable array.
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.
return {
pricingTable,
pricingTableForSecurity,
pricingTableForIt
};
}
};