fix repository form switcher button label translations for plugins

This commit is contained in:
Konstantin Schaper
2021-05-17 09:13:33 +02:00
parent 20bf646c4f
commit cb6806a36f

View File

@@ -26,6 +26,7 @@ import React, { FC } from "react";
import styled from "styled-components"; import styled from "styled-components";
import { Button, ButtonAddons, Icon, Level, urls } from "@scm-manager/ui-components"; import { Button, ButtonAddons, Icon, Level, urls } from "@scm-manager/ui-components";
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import { useTranslation } from "react-i18next";
const MarginIcon = styled(Icon)` const MarginIcon = styled(Icon)`
padding-right: 0.5rem; padding-right: 0.5rem;
@@ -58,11 +59,12 @@ const RepositoryFormButton: FC<RepositoryForm> = ({ path, icon, label }) => {
const location = useLocation(); const location = useLocation();
const href = urls.concat("/repos/create", path); const href = urls.concat("/repos/create", path);
const isSelected = href === location.pathname; const isSelected = href === location.pathname;
const [t] = useTranslation(["repos", "plugins"]);
return ( return (
<SmallButton color={isSelected ? "link is-selected" : undefined} link={!isSelected ? href : undefined}> <SmallButton color={isSelected ? "link is-selected" : undefined} link={!isSelected ? href : undefined}>
<MarginIcon name={icon} color={isSelected ? "white" : "default"} /> <MarginIcon name={icon} color={isSelected ? "white" : "default"} />
<p className="is-hidden-mobile is-hidden-tablet-only">{label}</p> <p className="is-hidden-mobile is-hidden-tablet-only">{t(`plugins:${label}`, label)}</p>
</SmallButton> </SmallButton>
); );
}; };
@@ -75,7 +77,7 @@ const RepositoryFormSwitcher: FC<Props> = ({ forms }) => (
<TopLevel <TopLevel
right={ right={
<ButtonAddons> <ButtonAddons>
{(forms || []).map(form => ( {(forms || []).map((form) => (
<RepositoryFormButton key={form.path} {...form} /> <RepositoryFormButton key={form.path} {...form} />
))} ))}
</ButtonAddons> </ButtonAddons>