From 329e210003bc66c71326162c2a79446bbff4d1f6 Mon Sep 17 00:00:00 2001 From: Deepankumar Loganathan Date: Wed, 21 Feb 2024 19:46:23 +0100 Subject: [PATCH] added adrFileLocationUrl for adr file read Signed-off-by: Deepankumar Loganathan --- plugins/adr-common/src/index.ts | 9 ++++----- plugins/adr/src/components/AdrReader/AdrReader.tsx | 7 ++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/adr-common/src/index.ts b/plugins/adr-common/src/index.ts index 7b441d091c..85d61cd270 100644 --- a/plugins/adr-common/src/index.ts +++ b/plugins/adr-common/src/index.ts @@ -63,15 +63,14 @@ export const getAdrLocationUrl = ( throw new Error(`Missing ADR annotation: ${ANNOTATION_ADR_LOCATION}`); } + let url = getAdrLocationDir(entity)!.replace(/\/$/, ''); + if (adrFilePath) { - return scmIntegration.resolveUrl({ - url: `${getAdrLocationDir(entity)!.replace(/\/$/, '')}/${adrFilePath}`, - base: getEntitySourceLocation(entity).target, - }); + url = `${url}/${adrFilePath}`; } return scmIntegration.resolveUrl({ - url: getAdrLocationDir(entity)!, + url, base: getEntitySourceLocation(entity).target, }); }; diff --git a/plugins/adr/src/components/AdrReader/AdrReader.tsx b/plugins/adr/src/components/AdrReader/AdrReader.tsx index 2169165288..d0dd8b7444 100644 --- a/plugins/adr/src/components/AdrReader/AdrReader.tsx +++ b/plugins/adr/src/components/AdrReader/AdrReader.tsx @@ -44,11 +44,12 @@ export const AdrReader = (props: { const { entity } = useEntity(); const scmIntegrations = useApi(scmIntegrationsApiRef); const adrApi = useApi(adrApiRef); - const adrLocationUrl = getAdrLocationUrl(entity, scmIntegrations, adr); + const adrLocationUrl = getAdrLocationUrl(entity, scmIntegrations); + const adrFileLocationUrl = getAdrLocationUrl(entity, scmIntegrations, adr); const { value, loading, error } = useAsync( - async () => adrApi.readAdr(adrLocationUrl), - [adrLocationUrl], + async () => adrApi.readAdr(adrFileLocationUrl), + [adrFileLocationUrl], ); const adrContent = useMemo(() => {