fleet/website/api/controllers/view-app-details.js
Eric 0654172fa2
Website: Add app library & app details page (#24205)
Related to: #23792

Changes:
- Added /app-library, a page that displays information about
Fleet-maintained apps
- Added the app details page (/app-library/{app identifier}), a page
that gives users detailed information about a single Fleet-maintained
app
- Updated the build-static-content script to add information about
Fleet-maintained apps to the website's configuration.
2024-11-27 13:43:23 -06:00

60 lines
1.2 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View app details',
description: 'Display "App details" page.',
inputs: {
appIdentifier: {
type: 'string',
required: true,
description: 'the identifier of an app in Fleet\'s maintained app library.',
example: '1password'
},
},
exits: {
success: {
viewTemplatePath: 'pages/app-details'
},
badConfig: {
responseType: 'badConfig'
},
notFound: {
responseType: 'notFound'
},
},
fn: async function ({appIdentifier}) {
if (!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.appLibrary) || !sails.config.builtStaticContent.appLibrary) {
throw {badConfig: 'builtStaticContent.appLibrary'};
}
let thisApp = _.find(sails.config.builtStaticContent.appLibrary, { identifier: appIdentifier });
if (!thisApp) {
throw 'notFound';
}
// FUTURE: make these better.
let pageTitleForMeta = thisApp.name + ' | Fleet app library';
// let pageDescriptionForMeta = 'TODO'
// Respond with view.
return {
thisApp,
// pageDescriptionForMeta,
pageTitleForMeta,
};
}
};