|
| 1 | +:_mod-docs-content-type: CONCEPT |
| 2 | +[id="con-identify-and-register-plugin-features-for-application-use_{context}"] |
| 3 | + |
| 4 | += Identify and register plugin features for application use |
| 5 | + |
| 6 | +Frontend wiring must be performed whenever a dynamic frontend plugin exports a feature that needs to be integrated into the main {product-custom-resource-type} application UI. |
| 7 | + |
| 8 | +Wiring is specifically required for, but not limited to, the following scenarios: |
| 9 | + |
| 10 | +[cols="1,1,2"] |
| 11 | +|=== |
| 12 | +|Scenario|Wiring configuration|Description |
| 13 | + |
| 14 | +|Enabling new pages/Routes |
| 15 | +|`dynamicRoutes` |
| 16 | +|When adding a full new page and route to the application (for example, `/my-plugin`). |
| 17 | + |
| 18 | +|Extending existing pages/UI |
| 19 | +|`mountPoints` |
| 20 | +|When injecting custom widgets, cards, listeners, or providers into existing pages (for example, the Catalog entity page). |
| 21 | + |
| 22 | +|Customizing sidebar navigation |
| 23 | +|`dynamicRoutes.menuItem`, `menuItems` |
| 24 | +|When adding a new entry to the main sidebar or customizing its order/nesting. |
| 25 | + |
| 26 | +|Integrating custom APIs |
| 27 | +|`apiFactories` |
| 28 | +|When a plugin provides a custom utility API implementation or overrides an existing one. |
| 29 | + |
| 30 | +|Extending entity tabs |
| 31 | +|`entityTabs` |
| 32 | +|When adding a new tab to the Catalog entity view or customizing an existing one. |
| 33 | + |
| 34 | +|Binding routes |
| 35 | +|`routeBindings` |
| 36 | +|When linking a route in one plugin to an external route defined by another plugin. |
| 37 | + |
| 38 | +|Adding icons/Theming |
| 39 | +|`appIcons`, `themes` |
| 40 | +|When adding custom icons to the application catalog or defining a new {product-custom-resource-type} theme. |
| 41 | + |
| 42 | +|Scaffolder/TechDocs extensions |
| 43 | +|`scaffolderFieldExtensions`, `techdocsAddons` |
| 44 | +|When exposing custom field extensions for the Scaffolder or new Addons for TechDocs. |
| 45 | + |
| 46 | +|Translation resources |
| 47 | +|`translationResources` |
| 48 | +|When providing new translation files or overriding default translations of a plugin. |
| 49 | +|=== |
| 50 | + |
| 51 | +.Example of Frontend wiring workflow |
| 52 | + |
| 53 | +The fundamental process for frontend wiring involves configuring the plugin exports in the `{my-app-config-file}` or a dedicated `dynamic-plugins-config.yaml` file. |
| 54 | + |
| 55 | +The dynamic plugin is built to expose components, routes, or APIs. A plugin component (`FooPluginPage`) is exported as an export from a module (for example, `PluginRoot`). |
| 56 | + |
| 57 | +The application administrator defines the wiring in the configuration file, using the plugin package name to register the exports. This step adds a new full page with a sidebar link. |
| 58 | + |
| 59 | +[source,yaml] |
| 60 | +.dynamic-plugins-config.yaml |
| 61 | +---- |
| 62 | +# dynamic-plugins-config.yaml |
| 63 | +plugins: |
| 64 | + - plugin: <plugin_path_or_url> |
| 65 | + disabled: false |
| 66 | + pluginConfig: |
| 67 | + dynamicPlugins: |
| 68 | + frontend: |
| 69 | + my-plugin-package-name: # The plugin's unique package name |
| 70 | + dynamicRoutes: # Wiring for a new page/route |
| 71 | + - path: /my-new-page # The desired URL path |
| 72 | + importName: FooPluginPage # The exported component name |
| 73 | + menuItem: # Wiring for the sidebar entry |
| 74 | + icon: favorite # A registered icon name |
| 75 | + text: My Custom Page |
| 76 | +---- |
| 77 | + |
| 78 | +The application follows these steps when it loads: |
| 79 | + |
| 80 | +. It parses the `dynamic-plugins-config.yaml`. |
| 81 | +. It uses the `<plugin_path_or_url>` to download the plugin bundle using the dynamic loading mechanism. |
| 82 | +. If the plugin exports the plugin object, the application adds this to the list of plugins provided to the Backstage `createApp` API, registering the plugin properly with the Backstage frontend application. |
| 83 | +. It uses the configuration block (`dynamicRoutes`, `menuItem`) to: |
| 84 | +* Add an entry to the internal router mapping `/my-new-page` to the `FooPluginPage` component. |
| 85 | +* Construct and render a new sidebar item labeled _My Custom Page_, pointing to the `/my-new-page` route. |
| 86 | + |
| 87 | +[NOTE] |
| 88 | +==== |
| 89 | +If the configuration is missing, steps 1 and 2 might still happen, but the final wiring in step 3 is skipped, and you do not see any change. |
| 90 | +==== |
0 commit comments