mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 00:15:44 +01:00
do not add JumpToFileButtons if no path exists cause they are broken anyway
This commit is contained in:
committed by
René Pfeuffer
parent
6343eddeb3
commit
fd7f28fc3f
@@ -154,11 +154,11 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
|
||||
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<Props> {
|
||||
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<Props> {
|
||||
}
|
||||
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 }) => <JumpToFileButton tooltip={label} link={url} />);
|
||||
return links ? links.map(({ url, label }) => <JumpToFileButton tooltip={label} link={url} />) : null;
|
||||
};
|
||||
|
||||
const titleComponent = <><Link to={`/repos/${repository.namespace}/`} className={"has-text-dark"}>{repository.namespace}</Link>/{repository.name}</>;
|
||||
const titleComponent = (
|
||||
<>
|
||||
<Link to={`/repos/${repository.namespace}/`} className={"has-text-dark"}>
|
||||
{repository.namespace}
|
||||
</Link>
|
||||
/{repository.name}
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<StateMenuContextProvider>
|
||||
|
||||
Reference in New Issue
Block a user