Merge pull request #6602 from backstage/chaseajen/pagerduty-docs

clarify code snippets for PagerDuty plugin installation
This commit is contained in:
Chase Rutherford-Jenkins
2021-07-27 14:39:57 -07:00
committed by GitHub
+34 -9
View File
@@ -35,34 +35,59 @@ If you need help with this plugin, please reach out on the [Backstage Discord se
### Install the plugin
Install the plugin via a CLI:
The file paths mentioned in the following steps are relative to your app's root directory — for example, the directory created by following the [Getting Started](https://backstage.io/docs/getting-started/) guide and creating your app with `npx @backstage/create-app`.
First, install the PagerDuty plugin via a CLI:
```bash
# From your Backstage root directory
# From your Backstage app root directory
cd packages/app
yarn add @backstage/plugin-pagerduty
```
Next, add the plugin to `EntityPage.tsx` by adding the following code snippet where appropriate:
Next, add the plugin to `EntityPage.tsx` in `packages/app/src/components/catalog` by adding the following code snippets.
Add the following imports to the top of the file:
```ts
import {
isPluginApplicableToEntity as isPagerDutyAvailable,
EntityPagerDutyCard,
} from '@backstage/plugin-pagerduty';
// add to code
{
isPagerDutyAvailable(entity) && (
```
Find `const overviewContent` in `EntityPage.tsx`, and add the following snippet inside the outermost `Grid` defined there, just before the closing `</Grid>` tag:
```ts
<EntitySwitch>
<EntitySwitch.Case if={isPagerDutyAvailable}>
<Grid item md={6}>
<EntityPagerDutyCard />
</Grid>
);
}
</EntitySwitch.Case>
</EntitySwitch>
```
When you're done, the `overviewContent` definition should look something like this:
```ts
const overviewContent = (
<Grid ...>
...
<EntitySwitch>
<EntitySwitch.Case if={isPagerDutyAvailable}>
<Grid item md={6}>
<EntityPagerDutyCard />
</Grid>
</EntitySwitch.Case>
</EntitySwitch>
</Grid>
);
```
### Configure the plugin
First, annotate the appropriate entity with the PagerDuty integration key:
First, [annotate](https://backstage.io/docs/features/software-catalog/descriptor-format#annotations-optional) the appropriate entity with the PagerDuty integration key in its `.yaml` configuration file:
```yaml
annotations: