fixed small review findings

This commit is contained in:
Sebastian Sdorra
2020-01-15 10:49:01 +01:00
parent 5e99ee92bf
commit c85e37c665
9 changed files with 33 additions and 28 deletions

View File

@@ -1,12 +1,12 @@
import React, { FC } from "react";
import styled from "styled-components";
import { RouteComponentProps, withRouter } from "react-router-dom";
import { useLocation } from "react-router-dom";
import { Level, BranchSelector } from "@scm-manager/ui-components";
import CodeViewSwitcher from "./CodeViewSwitcher";
import { useTranslation } from "react-i18next";
import { Branch } from "@scm-manager/ui-types";
const ActionBar = styled.div.attrs(() => ({}))`
const ActionBar = styled.div`
background-color: whitesmoke;
border: 1px solid #dbdbdb;
border-radius: 4px;
@@ -18,15 +18,16 @@ const ActionBar = styled.div.attrs(() => ({}))`
margin-bottom: 1em;
`;
type Props = RouteComponentProps & {
type Props = {
selectedBranch?: string;
branches: Branch[];
onSelectBranch: () => void;
switchViewLink: string;
};
const CodeActionBar: FC<Props> = ({ selectedBranch, branches, onSelectBranch, switchViewLink, location }) => {
const CodeActionBar: FC<Props> = ({ selectedBranch, branches, onSelectBranch, switchViewLink }) => {
const { t } = useTranslation("repos");
const location = useLocation();
return (
<ActionBar>
@@ -47,4 +48,4 @@ const CodeActionBar: FC<Props> = ({ selectedBranch, branches, onSelectBranch, sw
);
};
export default withRouter(CodeActionBar);
export default CodeActionBar;

View File

@@ -2,9 +2,8 @@ import React, { FC } from "react";
import styled from "styled-components";
import { Button, ButtonAddons } from "@scm-manager/ui-components";
import { useTranslation } from "react-i18next";
import { Branch } from "@scm-manager/ui-types";
const SmallButton = styled(Button).attrs(() => ({}))`
const SmallButton = styled(Button)`
border-radius: 4px;
font-size: 1rem;
font-weight: 600;
@@ -20,7 +19,7 @@ type Props = {
};
const CodeViewSwitcher: FC<Props> = ({ currentUrl, switchViewLink }) => {
const [t] = useTranslation("repos");
const { t } = useTranslation("repos");
const resolveLocation = () => {
if (currentUrl.includes("/code/branch") || currentUrl.includes("/code/changesets")) {
@@ -52,7 +51,7 @@ const CodeViewSwitcher: FC<Props> = ({ currentUrl, switchViewLink }) => {
label={t("code.sources")}
icon="fa fa-code"
color={isSourcesTab() ? "link is-selected" : undefined}
link={isChangesetsTab() ? switchViewLink: undefined}
link={isChangesetsTab() ? switchViewLink : undefined}
/>
</ButtonAddonsMarginRight>
);

View File

@@ -50,7 +50,7 @@ class CodeOverview extends React.Component<Props> {
}
return (
<div>
<>
<Route
path={`${url}/sources`}
exact={true}
@@ -77,7 +77,7 @@ class CodeOverview extends React.Component<Props> {
/>
)}
/>
</div>
</>
);
}
}