From e7e542bd0519cb6ade61b7e37b7c41f72b924dc3 Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Mon, 18 Dec 2023 15:40:25 +0100 Subject: [PATCH] docs: draft extension overrides arch Signed-off-by: Camila Belo --- .../architecture/05-extension-overrides.md | 105 +++++++++++++++--- 1 file changed, 87 insertions(+), 18 deletions(-) diff --git a/docs/frontend-system/architecture/05-extension-overrides.md b/docs/frontend-system/architecture/05-extension-overrides.md index e722145552..20476c24b0 100644 --- a/docs/frontend-system/architecture/05-extension-overrides.md +++ b/docs/frontend-system/architecture/05-extension-overrides.md @@ -10,38 +10,107 @@ description: Frontend extension overrides ## Introduction - +- When you just want to configure a plugin, such as changing the attachment point, a path or any other setting. Be sure to read the extension documentation before overriding an extension to make sure you cannot configure it to work the way you want; +- It is already possible to enable an extension that is already provided by the plugin. Imagine we have a Search plugin that provides a default search result item extension for rendering search results. Consider also that we have a Catalog plugin with a disabled Catalog search result item extension. To change the way Catalog search result items are rendered, you don't need to override the default result item extension. The only thing you need to do is enable the Catalog search result extension via the config file. For other types of search results, the default Search result item will continue to be used. -## Creating a Extension Override +## Creating an Extension Override - +For this example, we are creating overrides for the light and dark theme extensions and exporting the overrides from the plugin index file. Now we are able to use the overrides in a Backstage app: + +```tsx +// packages/app/src/App.tsx +import { createApp } from '@backstage/frontend-app-api'; +import apertureOverrides from ‘@backstage/plugin-aperture-overrides’ + +const app = createApp({ + features: [ apertureOverrides ], +}); + +export default app.createRoot(). +``` + +If the plugin you want to change is internal to your company or you just want to replace one of the application's core extensions, you can decide to create replacements directly in the application for local replacements. See an example below: + +```tsx +// packages/app/src/themes.ts +import { createExtensionOverrides } from from '@backstage/frontend-plugin-api'; + +// Creating the light theme extension; +export const apertureLightTheme = createThemeApi({ … }); + +// Creating the light theme extension; +const apertureDarkTheme = createThemeApi({ … }); + +// Exporting your custom extensions +export default [apertureLightTheme, apertureDarkTheme]; + +// packages/app/src/App.tsx +import { createApp } from '@backstage/frontend-app-api'; +import themes from ‘./themes’ + +const app = createApp({ + features: [ + createExtensionOverrides({ + extensions: [ + ...themes, + ], + }), + ], +}); + +export default app.createRoot(); +``` + +Note that it can still be a good idea to split your overrides out into separate packages in large projects. But it's up to you to decide how to group the extensions into extension overrides. ## Overriding Existing Extensions - +We recommend that plugin developes share the extension ids in their plugin documentations, but usually you can infer the id by following the (Naming pattern)[./08-naming-patterns] standars.