From fd7f28fc3f718fffab0ad17f8eda993a47304507 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Fri, 13 Nov 2020 12:52:53 +0100 Subject: [PATCH] do not add JumpToFileButtons if no path exists cause they are broken anyway --- .../src/repos/containers/RepositoryRoot.tsx | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx b/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx index 467bdcbecf..f249579012 100644 --- a/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx +++ b/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx @@ -154,11 +154,11 @@ class RepositoryRoot extends React.Component { const fileControlFactoryFactory: (changeset: Changeset) => FileControlFactory = changeset => file => { const baseUrl = `${url}/code/sources`; - const sourceLink = { + const sourceLink = file.newPath && { url: `${baseUrl}/${changeset.id}/${file.newPath}/`, label: t("diff.jumpToSource") }; - const targetLink = changeset._embedded?.parents?.length === 1 && { + const targetLink = file.oldPath && changeset._embedded?.parents?.length === 1 && { url: `${baseUrl}/${changeset._embedded.parents[0].id}/${file.oldPath}`, label: t("diff.jumpToTarget") }; @@ -166,7 +166,9 @@ class RepositoryRoot extends React.Component { const links = []; switch (file.type) { case "add": - links.push(sourceLink); + if (sourceLink) { + links.push(sourceLink); + } break; case "delete": if (targetLink) { @@ -174,17 +176,24 @@ class RepositoryRoot extends React.Component { } break; default: - if (targetLink) { + if (targetLink && sourceLink) { links.push(targetLink, sourceLink); // Target link first because its the previous file - } else { + } else if (sourceLink) { links.push(sourceLink); } } - return links.map(({ url, label }) => ); + return links ? links.map(({ url, label }) => ) : null; }; - const titleComponent = <>{repository.namespace}/{repository.name}; + const titleComponent = ( + <> + + {repository.namespace} + + /{repository.name} + + ); return (