From 0e544d694f5dbf5fa321ed6f029b7865dafcc322 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Mon, 13 Jan 2020 14:49:17 +0100 Subject: [PATCH] fetch changesets for selected branch // fetch changesets for default branch if trying to fetch changesets for specific revision --- .../components/CodeViewSwitcher.tsx | 36 +++++++++++++++---- .../codeSection/containers/CodeOverview.tsx | 14 +++++--- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/scm-ui/ui-webapp/src/repos/codeSection/components/CodeViewSwitcher.tsx b/scm-ui/ui-webapp/src/repos/codeSection/components/CodeViewSwitcher.tsx index 9cfc766402..e8d5c3aa87 100644 --- a/scm-ui/ui-webapp/src/repos/codeSection/components/CodeViewSwitcher.tsx +++ b/scm-ui/ui-webapp/src/repos/codeSection/components/CodeViewSwitcher.tsx @@ -15,16 +15,24 @@ const ButtonAddonsMarginRight = styled(ButtonAddons)` `; type Props = { - url: string; + baseUrl: string; + currentUrl: string; branches: Branch[]; + selectedBranch: string; }; -const CodeViewSwitcher: FC = ({ url, branches }) => { +const CodeViewSwitcher: FC = ({ baseUrl, currentUrl, branches, selectedBranch }) => { const [t] = useTranslation("repos"); - const createDestinationUrl = (destination: string, suffix?: string) => { - let splittedUrl = url.split("/"); + const createDestinationUrl = (destination: string, branch?: string, suffix?: string) => { + if (!branches) { + return baseUrl + "/" + destination + "/"; + } + let splittedUrl = currentUrl.split("/"); splittedUrl[5] = destination; + if (branch) { + splittedUrl[6] = branch; + } splittedUrl.splice(7, splittedUrl.length); if (suffix) { splittedUrl.push(suffix); @@ -37,13 +45,27 @@ const CodeViewSwitcher: FC = ({ url, branches }) => { branch.name === selectedBranch).length === 0 + ? createDestinationUrl( + "branch", + branches.filter(branch => branch.defaultBranch === true)[0].name, + "changesets/" + ) + : createDestinationUrl("branch", selectedBranch, "changesets/") + : createDestinationUrl("changesets") + } /> diff --git a/scm-ui/ui-webapp/src/repos/codeSection/containers/CodeOverview.tsx b/scm-ui/ui-webapp/src/repos/codeSection/containers/CodeOverview.tsx index c48bc7d34c..df87b69440 100644 --- a/scm-ui/ui-webapp/src/repos/codeSection/containers/CodeOverview.tsx +++ b/scm-ui/ui-webapp/src/repos/codeSection/containers/CodeOverview.tsx @@ -82,7 +82,7 @@ class CodeOverview extends React.Component { }; render() { - const { repository, baseUrl, branches, error, loading, t } = this.props; + const { repository, baseUrl, branches, selectedBranch, error, loading, t } = this.props; const url = baseUrl; if (loading) { @@ -103,11 +103,11 @@ class CodeOverview extends React.Component { } - right={} + right={} /> { /> } + render={() => ( + b.name === this.props.selectedBranch)[0]} + /> + )} /> );