React to breaking change

Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com>
This commit is contained in:
Jonathan Mezach
2023-04-18 09:00:23 +02:00
parent f54026a64d
commit f1622e1eaf
3 changed files with 14 additions and 12 deletions
@@ -28,11 +28,11 @@ export const EntityPageOctopusDeploy = (props: { defaultLimit?: number }) => {
const projectId = getProjectIdAnnotationFromEntity(entity);
const spaceId = getSpaceIdAnnotationFromEntity(entity);
const { environments, releases, loading, error } = useReleases(
const { environments, releases, loading, error } = useReleases({
projectId,
spaceId,
props.defaultLimit ?? 3,
);
releaseHistoryCount: props.defaultLimit ?? 3,
});
return (
<ReleaseTable
@@ -21,11 +21,11 @@ import {
OctopusReleaseProgression,
} from '../api';
export function useReleases(
projectId: string,
spaceId: string | null,
releaseHistoryCount: number,
): {
export function useReleases(opts: {
projectId: string;
spaceId?: string;
releaseHistoryCount: number;
}): {
environments?: OctopusEnvironment[];
releases?: OctopusReleaseProgression[];
loading: boolean;
@@ -34,8 +34,8 @@ export function useReleases(
const api = useApi(octopusDeployApiRef);
const { value, loading, error } = useAsync(() => {
return api.getReleaseProgression(projectId, spaceId, releaseHistoryCount);
}, [api, projectId, spaceId, releaseHistoryCount]);
return api.getReleaseProgression(opts);
}, [api, opts]);
return {
environments: value?.Environments,
@@ -32,9 +32,11 @@ export function getProjectIdAnnotationFromEntity(entity: Entity): string {
return annotation;
}
export function getSpaceIdAnnotationFromEntity(entity: Entity): string | null {
export function getSpaceIdAnnotationFromEntity(
entity: Entity,
): string | undefined {
const annotation =
entity.metadata.annotations?.[OCTOPUS_DEPLOY_SPACE_ID_ANNOTATION];
return annotation || null;
return annotation || undefined;
}