Different edit links depending on type. Only github for now though.

This commit is contained in:
Sebastian Qvarfordt
2020-06-05 12:53:16 +02:00
parent c655a133a3
commit bcb50c9325
+9 -2
View File
@@ -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(
<DescriptionWrapper>
{envelope.metadata?.annotations?.description ?? 'placeholder'}
{location?.target ? (
<a href={createEditLink(location?.target)}>
<a href={createEditLink(location)}>
<IconButton size="small">
<Edit fontSize="small" />
</IconButton>