Change API to use projectReference
Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
DiscoveryApi,
|
||||
FetchApi,
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { ProjectReference } from '../utils/getAnnotationFromEntity';
|
||||
|
||||
/** @public */
|
||||
export type OctopusProgression = {
|
||||
@@ -58,8 +59,7 @@ const DEFAULT_PROXY_PATH_BASE = '/octopus-deploy';
|
||||
/** @public */
|
||||
export interface OctopusDeployApi {
|
||||
getReleaseProgression(opts: {
|
||||
projectId: string;
|
||||
spaceId?: string;
|
||||
projectReference: ProjectReference;
|
||||
releaseHistoryCount: number;
|
||||
}): Promise<OctopusProgression>;
|
||||
}
|
||||
@@ -81,8 +81,7 @@ export class OctopusDeployClient implements OctopusDeployApi {
|
||||
}
|
||||
|
||||
async getReleaseProgression(opts: {
|
||||
projectId: string;
|
||||
spaceId?: string;
|
||||
projectReference: ProjectReference;
|
||||
releaseHistoryCount: number;
|
||||
}): Promise<OctopusProgression> {
|
||||
const url = await this.getApiUrl(opts);
|
||||
@@ -109,24 +108,23 @@ export class OctopusDeployClient implements OctopusDeployApi {
|
||||
}
|
||||
|
||||
private async getApiUrl(opts: {
|
||||
projectId: string;
|
||||
spaceId?: string;
|
||||
projectReference: ProjectReference;
|
||||
releaseHistoryCount: number;
|
||||
}) {
|
||||
const proxyUrl = await this.discoveryApi.getBaseUrl('proxy');
|
||||
const queryParameters = new URLSearchParams({
|
||||
releaseHistoryCount: opts.releaseHistoryCount.toString(),
|
||||
});
|
||||
if (opts.spaceId !== undefined) {
|
||||
if (opts.projectReference.spaceId !== undefined) {
|
||||
return `${proxyUrl}${this.proxyPathBase}/${encodeURIComponent(
|
||||
opts.spaceId,
|
||||
opts.projectReference.spaceId,
|
||||
)}/projects/${encodeURIComponent(
|
||||
opts.projectId,
|
||||
opts.projectReference.projectId,
|
||||
)}/progression?${queryParameters}`;
|
||||
}
|
||||
|
||||
return `${proxyUrl}${this.proxyPathBase}/projects/${encodeURIComponent(
|
||||
opts.projectId,
|
||||
opts.projectReference.projectId,
|
||||
)}/progression?${queryParameters}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,7 @@ export function useReleases(
|
||||
|
||||
const { value, loading, error } = useAsync(() => {
|
||||
return api.getReleaseProgression({
|
||||
projectId,
|
||||
spaceId,
|
||||
projectReference: { projectId, spaceId },
|
||||
releaseHistoryCount,
|
||||
});
|
||||
}, [api, projectId, spaceId, releaseHistoryCount]);
|
||||
|
||||
@@ -17,6 +17,7 @@ import { OCTOPUS_DEPLOY_PROJECT_ID_ANNOTATION } from '../constants';
|
||||
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
|
||||
/** @public */
|
||||
export type ProjectReference = { projectId: string; spaceId?: string };
|
||||
|
||||
export function getProjectReferenceAnnotationFromEntity(
|
||||
|
||||
Reference in New Issue
Block a user