fleet/website/api/controllers/view-scripts.js
Eric 048fcd13ed
Website: Add controls library pages (#33143)
Related to: https://github.com/fleetdm/confidential/issues/10737

Changes:
- Added `docs/scripts.yml`, a YAML file that contains a list of scripts
- Added `docs/mdm-commands.yml`, a YAML file that contains Windows and
Apple MDM commands
- Added `/mdm-commands`, a page that contains a list of MDM commands for
Windows and Apple commands
- Added `/scripts`, a page that contains a list of scripts
- Updated the `<docs-nav-and-search>` component to have a link to the
controls library, and reordered the lists.
- Updated the build static content script to add the scripts and mdm
commands from scripts.yml and mdm-commands.yml to the website's
`builtStaticContent` configuration.
- Updated the layout of the os-settings page to match the latest
wireframes
2025-09-19 12:02:55 -05:00

46 lines
978 B
JavaScript
Vendored

module.exports = {
friendlyName: 'View scripts',
description: 'Display "Scripts" page.',
exits: {
success: {
viewTemplatePath: 'pages/scripts'
},
badConfig: { responseType: 'badConfig' },
},
fn: async function () {
if (!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.scripts)) {
throw {badConfig: 'builtStaticContent.scripts'};
}
let scripts = sails.config.builtStaticContent.scripts;
let macOsScripts = _.filter(scripts, (script)=>{
return script.platform === 'macos';
});
let windowsScripts = _.filter(scripts, (script)=>{
return script.platform === 'windows';
});
let linuxScripts = _.filter(scripts, (script)=>{
return script.platform === 'linux';
});
// Respond with view.
return {
macOsScripts,
windowsScripts,
linuxScripts,
algoliaPublicKey: sails.config.custom.algoliaPublicKey,
};
}
};