Merge pull request #23007 from deepan10/adr-issue-22102
Fixed: ADR file path in Azure DevOps
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-adr': patch
|
||||
---
|
||||
|
||||
Fixed Azure DevOps ADR file path
|
||||
@@ -25,6 +25,7 @@ export const ANNOTATION_ADR_LOCATION = 'backstage.io/adr-location';
|
||||
export const getAdrLocationUrl: (
|
||||
entity: Entity,
|
||||
scmIntegration: ScmIntegrationRegistry,
|
||||
adrFilePath?: String,
|
||||
) => string;
|
||||
|
||||
// @public
|
||||
|
||||
@@ -57,13 +57,20 @@ export const isAdrAvailable = (entity: Entity) =>
|
||||
export const getAdrLocationUrl = (
|
||||
entity: Entity,
|
||||
scmIntegration: ScmIntegrationRegistry,
|
||||
adrFilePath?: String,
|
||||
) => {
|
||||
if (!isAdrAvailable(entity)) {
|
||||
throw new Error(`Missing ADR annotation: ${ANNOTATION_ADR_LOCATION}`);
|
||||
}
|
||||
|
||||
let url = getAdrLocationDir(entity)!.replace(/\/$/, '');
|
||||
|
||||
if (adrFilePath) {
|
||||
url = `${url}/${adrFilePath}`;
|
||||
}
|
||||
|
||||
return scmIntegration.resolveUrl({
|
||||
url: getAdrLocationDir(entity)!,
|
||||
url,
|
||||
base: getEntitySourceLocation(entity).target,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -45,11 +45,11 @@ export const AdrReader = (props: {
|
||||
const scmIntegrations = useApi(scmIntegrationsApiRef);
|
||||
const adrApi = useApi(adrApiRef);
|
||||
const adrLocationUrl = getAdrLocationUrl(entity, scmIntegrations);
|
||||
const adrFileLocationUrl = getAdrLocationUrl(entity, scmIntegrations, adr);
|
||||
|
||||
const url = `${adrLocationUrl.replace(/\/$/, '')}/${adr}`;
|
||||
const { value, loading, error } = useAsync(
|
||||
async () => adrApi.readAdr(url),
|
||||
[url],
|
||||
async () => adrApi.readAdr(adrFileLocationUrl),
|
||||
[adrFileLocationUrl],
|
||||
);
|
||||
|
||||
const adrContent = useMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user