Skip to content

Commit 62f9f4b

Browse files
GitHub Actionsjmagak
authored andcommitted
Update documentation with why frontend wiring is necessary
1 parent 2b6d5c9 commit 62f9f4b

5 files changed

+138
-0
lines changed

assemblies/dynamic-plugins/assembly-front-end-plugin-wiring.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66

77
You can configure front-end plugins to customize icons, integrate components at mount points, and provide or replace utility APIs.
88

9+
// Frontend plugin wiring
10+
include::../modules/dynamic-plugins/con-frontend-dynamic-plugin-wiring.adoc[leveloffset=+1]
11+
12+
// Understand frontend wiring
13+
include::../modules/dynamic-plugins/con-understand-why-wiring-is-required-for-plugin-deployment.adoc[leveloffset=+2]
14+
15+
// When you skip frontend wiring
16+
include::../modules/dynamic-plugins/con-troubleshoot-why-a-dynamically-loaded-plugin-is-not-visible.adoc[leveloffset=+2]
17+
18+
// When to perform frontend wiring
19+
include::../modules/dynamic-plugins/con-identify-and-register-plugin-features-for-application-use.adoc[leveloffset=+2]
20+
921
// Extending the internal icon catalog
1022
include::../modules/dynamic-plugins/proc-extending-internal-icon-catalog.adoc[leveloffset=+1]
1123

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
:_mod-docs-content-type: CONCEPT
2+
[id="con-frontend-dynamic-plugin-wiring_{context}"]
3+
= Frontend plugin wiring
4+
5+
Frontend plugin wiring allows dynamically loaded frontend plugins to integrate their functionality, such as new pages, UI extensions, icons, and APIs, into {product}.
6+
7+
Dynamic frontend plugins are loaded at runtime. Therefore, the core application must discover and connect the exported assets of the plugin to the appropriate locations and systems within the user interface.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
====
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
:_mod-docs-content-type: CONCEPT
2+
[id="con-troubleshoot-why-a-dynamically-loaded-plugin-is-not-visible_{context}"]
3+
4+
= Troubleshoot why a dynamically loaded plugin is not visible
5+
6+
If you skip frontend wiring, the plugin is discovered but not loaded into the application frontend. As a result, the plugin features do not appear or function. This is expected because backend plugins are automatically discovered and loaded, but frontend plugins are only loaded based on the list defined in the `dynamicPlugins.frontend` configuration.
7+
8+
You can expect the following behavior when you skip frontend wiring:
9+
10+
Functionality is disabled:: The Backstage application does not know how to integrate the plugin exports.
11+
Invisible components:: New pages, sidebar links, or custom cards are not rendered.
12+
Unregistered APIs:: Custom utility APIs or API overrides provided by the plugin fail to register in the application API system, causing plugins or components to fail.
13+
Unused assets:: Icons, translations, and themes are not registered or made available for use.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
:_mod-docs-content-type: CONCEPT
2+
[id="con-understand-why-wiring-is-required-for-plugin-deployment_{context}"]
3+
4+
= Understand why wiring is required for plugin deployment
5+
6+
Frontend wiring bridges the gap between the dynamically loaded plugin code and the structured components of the {product-short} application.
7+
8+
Frontend components need instructions on where to be registered in the application UI. The application does not automatically know where the UI components of a plugin must appear.
9+
10+
Wiring tells the application the following:
11+
12+
* "Add new pages and routes to the main application." (using `dynamicRoutes`)
13+
* "Inject custom components into existing UI pages." (using `mountPoints`)
14+
* "Customize the application with new icons or themes." (using `appIcons`)
15+
16+
Wiring configuration, typically located in `{my-app-config-file}` or `dynamic-plugins-config.yaml`, provides the application with the metadata (including the component names, paths, and integration points) needed to render and use the plugin features.

0 commit comments

Comments
 (0)