Different edit links depending on type. Only github for now though.
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user