Files
SCM-Manager/scm-ui/ui-webapp/src/repos/codeSection/components/CodeActionBar.tsx

52 lines
1.3 KiB
TypeScript
Raw Normal View History

2020-01-14 18:07:57 +01:00
import React, { FC } from "react";
import styled from "styled-components";
2020-01-15 10:49:01 +01:00
import { useLocation } from "react-router-dom";
2020-01-14 18:07:57 +01:00
import { Level, BranchSelector } from "@scm-manager/ui-components";
import CodeViewSwitcher from "./CodeViewSwitcher";
import { useTranslation } from "react-i18next";
import { Branch } from "@scm-manager/ui-types";
2020-01-15 10:49:01 +01:00
const ActionBar = styled.div`
2020-01-14 18:07:57 +01:00
background-color: whitesmoke;
border: 1px solid #dbdbdb;
border-radius: 4px;
color: #363636;
font-size: 1.25em;
font-weight: 300;
line-height: 1.25;
padding: 0.5em 0.75em;
margin-bottom: 1em;
`;
2020-01-15 10:49:01 +01:00
type Props = {
2020-01-14 18:07:57 +01:00
selectedBranch?: string;
branches: Branch[];
onSelectBranch: () => void;
switchViewLink: string;
};
2020-01-15 10:49:01 +01:00
const CodeActionBar: FC<Props> = ({ selectedBranch, branches, onSelectBranch, switchViewLink }) => {
2020-01-14 18:07:57 +01:00
const { t } = useTranslation("repos");
2020-01-15 10:49:01 +01:00
const location = useLocation();
2020-01-14 18:07:57 +01:00
return (
<ActionBar>
<Level
left={
branches?.length > 0 && (
<BranchSelector
label={t("code.branchSelector")}
branches={branches}
selectedBranch={selectedBranch}
onSelectBranch={onSelectBranch}
/>
)
}
right={<CodeViewSwitcher currentUrl={location.pathname} switchViewLink={switchViewLink} />}
/>
</ActionBar>
);
};
2020-01-15 10:49:01 +01:00
export default CodeActionBar;