fleet/website/api/controllers/view-script-details.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

49 lines
1.2 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View script details',
description: 'Display "Script details" page.',
inputs: {
slug: { type: 'string', required: true, description: 'A slug uniquely identifying this script in the library.', example: 'macos-uninstall-fleetd' },
},
exits: {
success: { viewTemplatePath: 'pages/script-details' },
notFound: { responseType: 'notFound' },
badConfig: { responseType: 'badConfig' },
},
fn: async function ({slug}) {
if (!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.scripts)) {
throw {badConfig: 'builtStaticContent.scripts'};
}
let thisScript = _.find(sails.config.builtStaticContent.scripts, { slug: slug });
if(!thisScript){
return 'notFound';
}
let pageTitleForMeta = `${thisScript.name} | Fleet controls library`;
let pageDescriptionForMeta = thisScript.description ? thisScript.description : 'View more information about a script in Fleet\'s controls library';
// Respond with view.
return {
thisScript,
pageTitleForMeta,
pageDescriptionForMeta,
algoliaPublicKey: sails.config.custom.algoliaPublicKey,
};
}
};