From bcb50c9325af02146da3ea20ca52595a5fba6145 Mon Sep 17 00:00:00 2001 From: Sebastian Qvarfordt Date: Fri, 5 Jun 2020 12:53:16 +0200 Subject: [PATCH] Different edit links depending on type. Only github for now though. --- plugins/catalog/src/data/utils.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/catalog/src/data/utils.tsx b/plugins/catalog/src/data/utils.tsx index 5302fd75c2..3f04883e34 100644 --- a/plugins/catalog/src/data/utils.tsx +++ b/plugins/catalog/src/data/utils.tsx @@ -25,7 +25,14 @@ const DescriptionWrapper = styled('span')({ alignItems: 'center', }); -const createEditLink = (url: string): string => url.replace('/blob/', '/edit/'); +const createEditLink = (location: Location): string => { + switch (location.type) { + case 'github': + return location.target.replace('/blob/', '/edit/'); + default: + return location.target; + } +}; export function envelopeToComponent( envelope: Entity, @@ -38,7 +45,7 @@ export function envelopeToComponent( {envelope.metadata?.annotations?.description ?? 'placeholder'} {location?.target ? ( - +