Skip to content

Commit

Permalink
Add included components and templates
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSurgisonGDS committed Oct 9, 2023
1 parent 7e0a707 commit a5a58f0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
21 changes: 20 additions & 1 deletion lib/manage-prototype-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ function buildPluginData (pluginData) {
updateCommand: latestVersion && `npm install ${packageName}@${latestVersion}`,
uninstallLink: installed && !required ? `${contextPath}/plugins/uninstall?package=${encodeURIComponent(packageName)}${installedLocally ? `&version=${encodeURIComponent(localVersion)}` : ''}` : undefined,
uninstallCommand: `npm uninstall ${packageName}`,
installedVersion
installedVersion,
inThisPlugin: getInThisPluginDetails(pluginConfig)
}
}

Expand Down Expand Up @@ -567,6 +568,24 @@ async function getPluginForRequest (req) {
return chosenPlugin
}

function getInThisPluginDetails (pluginConfig) {
const { nunjucksMacros = [], templates = [] } = pluginConfig || {}
const list = []
if (nunjucksMacros?.length) {
list.push({
title: 'Components',
items: nunjucksMacros.map(({ macroName }) => macroName)
})
}
if (templates?.length) {
list.push({
title: 'Templates',
items: templates.map(({ name }) => name)
})
}
return list
}

function modeIsComplete (mode, { installedVersion, latestVersion, version, installedLocally }) {
switch (mode) {
case 'update':
Expand Down
3 changes: 2 additions & 1 deletion lib/manage-prototype-handlers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ describe('manage-prototype-handlers', () => {
name: pluginDisplayName.name,
packageName,
uninstallCommand: `npm uninstall ${packageName}`,
updateCommand: `npm install ${packageName}@${latestVersion}`
updateCommand: `npm install ${packageName}@${latestVersion}`,
inThisPlugin: []
}

beforeEach(() => {
Expand Down

0 comments on commit a5a58f0

Please sign in to comment.