remove contextPath on switching view to changesets

This commit is contained in:
Eduard Heimbuch
2020-01-09 10:05:12 +01:00
parent bdb02cdfd1
commit 6f6e6f60d4

View File

@@ -17,9 +17,12 @@ type Props = {
const CodeViewSwitcher: FC<Props> = ({ url }) => { const CodeViewSwitcher: FC<Props> = ({ url }) => {
const [t] = useTranslation("repos"); const [t] = useTranslation("repos");
const createDestinationUrl = (destination: string) => { const createDestinationUrl = (destination: string, removePath: boolean) => {
let splittedUrl = url.split("/"); let splittedUrl = url.split("/");
splittedUrl[5] = destination; splittedUrl[5] = destination;
if (removePath) {
splittedUrl.splice(7, splittedUrl.length);
}
return splittedUrl.join("/"); return splittedUrl.join("/");
}; };
@@ -29,13 +32,13 @@ const CodeViewSwitcher: FC<Props> = ({ url }) => {
label={t("code.commits")} label={t("code.commits")}
icon="fa fa-exchange-alt" icon="fa fa-exchange-alt"
color={url.includes("/code/changesets") ? "link is-selected" : undefined} color={url.includes("/code/changesets") ? "link is-selected" : undefined}
link={createDestinationUrl("changesets")} link={createDestinationUrl("changesets", true)}
/> />
<SmallButton <SmallButton
label={t("code.sources")} label={t("code.sources")}
icon="fa fa-code" icon="fa fa-code"
color={url.includes("/code/sources") ? "link is-selected" : undefined} color={url.includes("/code/sources") ? "link is-selected" : undefined}
link={createDestinationUrl("sources")} link={createDestinationUrl("sources", false)}
/> />
</ButtonAddons> </ButtonAddons>
); );