From 2842e953f42d2df618c80aa8281221692b484f93 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 8 Apr 2021 16:37:22 +0100 Subject: [PATCH] as per feedback Signed-off-by: Andrew Johnson --- .changeset/smooth-vans-travel.md | 2 +- plugins/github-deployments/README.md | 21 +++---------------- plugins/github-deployments/package.json | 8 +++---- plugins/github-deployments/src/api/index.ts | 14 ++++++++----- .../src/components/GithubDeploymentsCard.tsx | 2 +- 5 files changed, 18 insertions(+), 29 deletions(-) diff --git a/.changeset/smooth-vans-travel.md b/.changeset/smooth-vans-travel.md index 0038c35e8e..eb074c8ecf 100644 --- a/.changeset/smooth-vans-travel.md +++ b/.changeset/smooth-vans-travel.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-github-deployments': patch +'@backstage/plugin-github-deployments': minor --- Support for GitHub Enterprise with GithubDeploymentsPlugin diff --git a/plugins/github-deployments/README.md b/plugins/github-deployments/README.md index 42f550059c..e1f3d7c2c0 100644 --- a/plugins/github-deployments/README.md +++ b/plugins/github-deployments/README.md @@ -63,6 +63,9 @@ spec: ### Self-hosted / Enterprise GitHub +The plugin will try to use `backstage.io/source-location` or `backstage.io/managed-by-location` +annotations to figure out the location of the source code. + 1. Add the `host` and `apiBaseUrl` to your `app-config.yaml` ```yaml @@ -73,21 +76,3 @@ integrations: - host: 'your-github-host.com' apiBaseUrl: 'https://api.your-github-host.com' ``` - -2. Pass the host into the `EntityGithubDeploymentsCard` - -```typescript -// packages/app/src/components/catalog/EntityPage.tsx - -import { EntityGithubDeploymentsCard } from '@backstage/plugin-github-deployments'; - -const OverviewContent = () => ( - - // ... - - - - // ... - -); -``` diff --git a/plugins/github-deployments/package.json b/plugins/github-deployments/package.json index 528d660ea8..39c7577bb5 100644 --- a/plugins/github-deployments/package.json +++ b/plugins/github-deployments/package.json @@ -20,8 +20,8 @@ "clean": "backstage-cli clean" }, "dependencies": { - "@backstage/catalog-model": "^0.7.4", - "@backstage/core": "^0.7.3", + "@backstage/catalog-model": "^0.7.6", + "@backstage/core": "^0.7.4", "@backstage/errors": "^0.1.1", "@backstage/integration": "^0.5.1", "@backstage/integration-react": "^0.1.1", @@ -37,9 +37,9 @@ "react-use": "^15.3.3" }, "devDependencies": { - "@backstage/cli": "^0.6.6", + "@backstage/cli": "^0.6.7", "@backstage/dev-utils": "^0.1.13", - "@backstage/test-utils": "^0.1.9", + "@backstage/test-utils": "^0.1.10", "@testing-library/jest-dom": "^5.10.1", "@testing-library/react": "^11.2.5", "@testing-library/user-event": "^12.0.7", diff --git a/plugins/github-deployments/src/api/index.ts b/plugins/github-deployments/src/api/index.ts index 221eb3be8a..0deb586e6d 100644 --- a/plugins/github-deployments/src/api/index.ts +++ b/plugins/github-deployments/src/api/index.ts @@ -60,16 +60,20 @@ export type GithubDeployment = { }; }; -type QueryOptions = { +type QueryParams = { owner: string; repo: string; last: number; }; +type QueryOptions = { + locations: string[]; +}; + export interface GithubDeploymentsApi { listDeployments( + params: QueryParams, options: QueryOptions, - location: string[], ): Promise; } @@ -119,10 +123,10 @@ export class GithubDeploymentsApiClient implements GithubDeploymentsApi { } async listDeployments( + params: QueryParams, options: QueryOptions, - locations: string[], ): Promise { - const baseUrl = getBaseUrl(this.scmIntegrationsApi, locations); + const baseUrl = getBaseUrl(this.scmIntegrationsApi, options.locations); const token = await this.githubAuthApi.getAccessToken(['repo']); const graphQLWithAuth = graphql.defaults({ @@ -134,7 +138,7 @@ export class GithubDeploymentsApiClient implements GithubDeploymentsApi { const response: QueryResponse = await graphQLWithAuth( deploymentsQuery, - options, + params, ); return response.repository?.deployments?.nodes?.reverse() || []; } diff --git a/plugins/github-deployments/src/components/GithubDeploymentsCard.tsx b/plugins/github-deployments/src/components/GithubDeploymentsCard.tsx index eccab4089a..fb433338fa 100644 --- a/plugins/github-deployments/src/components/GithubDeploymentsCard.tsx +++ b/plugins/github-deployments/src/components/GithubDeploymentsCard.tsx @@ -45,7 +45,7 @@ const GithubDeploymentsComponent = ({ const [owner, repo] = projectSlug.split('/'); const { loading, value, error, retry: reload } = useAsyncRetry( - async () => await api.listDeployments({ owner, repo, last }, locations), + async () => await api.listDeployments({ owner, repo, last }, { locations }), ); if (error) {