fleet/website/api/controllers/docs/view-script-details.js
Eric e890981e1c
Website: Move documentation pages into docs/ folder, rename scripts to script-library (#42510)
Changes:
- Moved documentation pages into the docs/ folder
- Updated routes, poicies, and importer.less
- Renamed the "scripts" page to "script-library" to be consistent with
the other landing pages for YAML documentation
- removed a stray console.log() in the new-licence page script
2026-03-26 15:32:48 -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/docs/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){
throw '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,
};
}
};