Installing the Entity Scaffolder Content Frontend Plugin#
This guide will help you install and set up the Entity Scaffolder Content frontend plugin in your Backstage instance.
Prerequisites#
Before installing the plugin, ensure you have:
- A working Backstage instance
- The Scaffolder plugin installed and configured
- Access to entity pages where you want to embed templates
Installation Steps#
1. Add the Package#
Install the plugin package using yarn:
yarn --cwd packages/app add @terasky/backstage-plugin-entity-scaffolder-content
2. Add to Entity Page (Legacy Frontend System)#
Modify your entity page configuration in packages/app/src/components/catalog/EntityPage.tsx:
import { EntityScaffolderContent } from '@terasky/backstage-plugin-entity-scaffolder-content';
// Example for system entity page
const systemPage = (
<EntityLayout>
{/* ... other routes ... */}
<EntityLayout.Route path="/scaffolder" title="Templates">
<EntityScaffolderContent
templateGroupFilters={[
{
title: 'System Templates',
filter: (entity, template) =>
template.metadata?.labels?.forEntity === 'system' &&
entity.spec?.type === 'kubernetes-namespace',
},
]}
buildInitialState={(entity, template) => ({
namespace: entity.metadata.name,
// Add other initial state mappings
})}
/>
</EntityLayout.Route>
</EntityLayout>
);
// Add similar configurations for other entity pages as needed
Field extensions (e.g. RepoUrlPicker, EntityPicker) can be passed via the optional ScaffolderFieldExtensions prop. See the Configuration Guide for details.
New Frontend System Support (Alpha)#
The plugin ships a ready-to-use alpha export for the new Backstage frontend system. To use it:
import { createApp } from '@backstage/frontend-defaults';
import { entityScaffolderContentPlugin } from '@terasky/backstage-plugin-entity-scaffolder-content/alpha';
export default createApp({
features: [
// ...
entityScaffolderContentPlugin,
// ...
],
});
This registers the built-in entity content extensions automatically. In this mode field extensions are auto-discovered — any extension registered via FormFieldBlueprint is picked up without additional configuration.
Registering Form Decorators (New Frontend System)#
Form decorators are registered the same way as other Backstage extensions:
import { createApp } from '@backstage/frontend-defaults';
import { createFrontendModule } from '@backstage/frontend-plugin-api';
import { createScaffolderFormDecorator, FormDecoratorBlueprint } from '@backstage/plugin-scaffolder-react/alpha';
import { githubAuthApiRef } from '@backstage/core-plugin-api';
const githubTokenDecorator = createScaffolderFormDecorator({
id: 'github-token',
deps: {
githubApi: githubAuthApiRef,
},
decorator: async ({ setSecrets, secrets }, { githubApi }) => {
const token = await githubApi.getAccessToken(['repo']);
setSecrets({ ...secrets, GITHUB_TOKEN: token });
},
});
const githubTokenDecoratorExtension = FormDecoratorBlueprint.make({
name: 'github-token',
params: {
decorator: githubTokenDecorator,
},
});
export default createApp({
features: [
entityScaffolderContentPlugin,
createFrontendModule({
pluginId: 'scaffolder',
extensions: [githubTokenDecoratorExtension],
}),
],
});
The decorator will run automatically for any template that declares it in spec.formDecorators.
Verification#
After installation, verify that:
- The plugin appears in your
package.jsondependencies - The templates tab appears on configured entity pages
- Templates are properly filtered based on entity context
- Template forms are pre-populated with entity data
- After template submission, an inline task progress view (steps, logs, outputs) is displayed
Troubleshooting#
Common issues and solutions:
-
Templates Tab Not Showing
- Verify
EntityLayout.Routeconfiguration - Check component import path
- Ensure entity page configuration is applied
- Verify
-
Templates Not Filtered
- Review
templateGroupFiltersconfiguration - Check template metadata and labels
- Verify entity type matching
- Review
-
Form Pre-population Issues
- Check
buildInitialStatefunction signature — it now receives bothentityandtemplateas arguments - Verify entity data access
- Review data transformation logic
- Check
-
Field Extensions Not Rendering
- In the new frontend system, ensure extensions are registered via
FormFieldBlueprint - In the legacy system, pass extensions via the
ScaffolderFieldExtensionsprop (see Configuration Guide)
- In the new frontend system, ensure extensions are registered via
-
Form Decorator Not Executing
- Ensure the template declares the decorator in
spec.formDecorators - Verify the decorator is registered via
FormDecoratorBlueprintwith the matchingid - Check the browser console for any API resolution errors
- Ensure the template declares the decorator in
For configuration options and customisation, proceed to the Configuration Guide.