From 2468e96d89022a5694c4e7ceda35ee026eadec1c Mon Sep 17 00:00:00 2001 From: Niek Rossen Date: Mon, 18 Mar 2024 15:17:37 +0100 Subject: [PATCH] Implement PR feedback Signed-off-by: Niek Rossen --- plugins/octopus-deploy/README.md | 6 +++--- plugins/octopus-deploy/src/api/index.ts | 8 ++++++-- .../ScaffolderDropdown/ProjectGroupDropdown.tsx | 10 ++++++++-- plugins/octopus-deploy/src/hooks/useProjectGroups.ts | 4 ++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/plugins/octopus-deploy/README.md b/plugins/octopus-deploy/README.md index fabd3c4737..745a1793e8 100644 --- a/plugins/octopus-deploy/README.md +++ b/plugins/octopus-deploy/README.md @@ -23,7 +23,7 @@ This plugin (currently) uses the Backstage proxy to securely communicate with th To use it, you will need to generate an [API Key](https://octopus.com/docs/octopus-rest-api/how-to-create-an-api-key) within Octopus Deploy. -1. Add the following to your app-config.yaml to enable the proxy: +Add the following to your app-config.yaml to enable the proxy: ``` // app-config.yaml @@ -44,7 +44,7 @@ octopusdeploy: #### Adding the Entities -1. Add the following to `EntityPage.tsx` to display Octopus Releases +Add the following to `EntityPage.tsx` to display Octopus Releases ``` // In packages/app/src/components/catalog/EntityPage.tsx @@ -63,7 +63,7 @@ const cicdContent = ( ) ``` -2. Add `octopus.com/project-id` annotation in the catalog descriptor file. +Add `octopus.com/project-id` annotation in the catalog descriptor file. To obtain a projects ID you will have to query the Octopus API. In the future we'll add support for using a projects slug as well. diff --git a/plugins/octopus-deploy/src/api/index.ts b/plugins/octopus-deploy/src/api/index.ts index 15451cd79f..dae508d172 100644 --- a/plugins/octopus-deploy/src/api/index.ts +++ b/plugins/octopus-deploy/src/api/index.ts @@ -165,8 +165,7 @@ export class OctopusDeployClient implements OctopusDeployApi { } async getProjectGroups(): Promise { - const proxyUrl = await this.discoveryApi.getBaseUrl('proxy'); - const url = `${proxyUrl}${this.proxyPathBase}/projectgroups/all`; + const url = await this.getProjectGroupApiUrl(); const response = await this.fetchApi.fetch(url); let responseJson; @@ -217,4 +216,9 @@ export class OctopusDeployClient implements OctopusDeployApi { projectReference.projectId, )}`; } + + private async getProjectGroupApiUrl(): Promise { + const proxyUrl = await this.discoveryApi.getBaseUrl('proxy'); + return `${proxyUrl}${this.proxyPathBase}/projectgroups/all`; + } } diff --git a/plugins/octopus-deploy/src/components/ScaffolderDropdown/ProjectGroupDropdown.tsx b/plugins/octopus-deploy/src/components/ScaffolderDropdown/ProjectGroupDropdown.tsx index 7d70bcd28e..410d07f15e 100644 --- a/plugins/octopus-deploy/src/components/ScaffolderDropdown/ProjectGroupDropdown.tsx +++ b/plugins/octopus-deploy/src/components/ScaffolderDropdown/ProjectGroupDropdown.tsx @@ -15,8 +15,12 @@ */ import React from 'react'; -import FormControl from '@material-ui/core/FormControl'; -import { InputLabel, Input, FormHelperText } from '@material-ui/core'; +import { + InputLabel, + Input, + FormControl, + FormHelperText, +} from '@material-ui/core'; import { Select, SelectItem } from '@backstage/core-components'; import { useProjectGroups } from '../../hooks/useProjectGroups'; import { ProjectGroupDropdownProps } from './schema'; @@ -50,6 +54,8 @@ export const ProjectGroupDropdown = ({