Skip to content

Latest commit

 

History

History
118 lines (95 loc) · 3.51 KB

configure-app-with-plugins.md

File metadata and controls

118 lines (95 loc) · 3.51 KB
id title description
configure-app-with-plugins
Configuring App with plugins
Documentation on How Configuring App with plugins

Backstage plugins customize the app for your needs. There is a plugin marketplace with plugins for many common infrastructure needs - CI/CD, monitoring, auditing, and more.

Adding existing plugins to your app

The following steps assume that you have created a Backstage app and want to add an existing plugin to it. We are using the CircleCI plugin in this example.

  1. Add the plugin's npm package to the repo:
yarn workspace app add @backstage/plugin-circleci

Note the plugin is added to the app package, rather than the root package.json. Backstage Apps are set up as monorepos with yarn workspaces. Since CircleCI is a frontend UI plugin, it goes in app rather than backend.

  1. Add the EntityCircleCIContent extension to the entity pages in the app:
 // packages/app/src/components/catalog/EntityPage.tsx
+import {
+  EntityCircleCIContent,
+  isCircleCIAvailable,
+} from '@backstage/plugin-circleci';

...
 const cicdContent = (
   <EntitySwitch>
     ...
+     <EntitySwitch.Case if={isCircleCIAvailable}>
+       <EntityCircleCIContent />
+     </EntitySwitch.Case>;
   </EntitySwitch>
 );

This is just one example, but each Backstage instance may integrate content or cards to suit their needs on different pages, tabs, etc. Note that stand-alone plugins that are not "attached" to the Software Catalog would be added outside the EntityPage.

  1. [Optional] Add proxy config:
// app-config.yaml
proxy:
  '/circleci/api':
    target: https://circleci.com/api/v1.1
    headers:
      Circle-Token: ${CIRCLECI_AUTH_TOKEN}

Adding a plugin page to the Sidebar

In a standard Backstage app created with @backstage/create-app, the sidebar is managed inside packages/app/src/components/Root/Root.tsx. The file exports the entire Sidebar element of your app, which you can extend with additional entries by adding new SidebarItem elements.

For example, if you install the api-docs plugin, a matching SidebarItem could be something like this:

// Import icon from MUI
import ExtensionIcon from '@material-ui/icons/Extension';

// ... inside the AppSidebar component
<SidebarItem icon={ExtensionIcon} to="api-docs" text="APIs" />;

You can also use your own SVGs directly as icon components. Just make sure they are sized according to the Material UI's SvgIcon default of 24x24px, and set the extension to .icon.svg. For example:

import InternalToolIcon from './internal-tool.icon.svg';

On mobile devices the Sidebar is displayed at the bottom of the screen. For customizing the experience you can group SidebarItems in a SidebarGroup (Example 1) or create a SidebarGroup with a link (Example 2). All SidebarGroups are displayed in the bottom navigation with an icon.

// Example 1
<SidebarGroup icon={<MenuIcon />} label="Menu">
  ...
  <SidebarItem icon={ExtensionIcon} to="api-docs" text="APIs" />
  ...
<SidebarGroup />
// Example 2
<SidebarGroup label="Search" icon={<SearchIcon />} to="/search">
  ...
  <SidebarItem icon={ExtensionIcon} to="api-docs" text="APIs" />
  ...
<SidebarGroup />

If no SidebarGroup is provided a default menu will display the Sidebar content.