diff --git a/scm-ui/ui-components/src/repos/DiffFile.tsx b/scm-ui/ui-components/src/repos/DiffFile.tsx index 9ff6ef58a1..4a8291646c 100644 --- a/scm-ui/ui-components/src/repos/DiffFile.tsx +++ b/scm-ui/ui-components/src/repos/DiffFile.tsx @@ -26,7 +26,7 @@ import { withTranslation, WithTranslation } from "react-i18next"; import classNames from "classnames"; import styled from "styled-components"; // @ts-ignore -import { Decoration, getChangeKey, Hunk } from "react-diff-view"; +import { getChangeKey, Hunk } from "react-diff-view"; import { ButtonGroup } from "../buttons"; import Tag from "../Tag"; import Icon from "../Icon"; @@ -38,6 +38,7 @@ import DiffExpander, { ExpandableHunk } from "./DiffExpander"; import HunkExpandLink from "./HunkExpandLink"; import { Modal } from "../modals"; import ErrorNotification from "../ErrorNotification"; +import HunkExpandDivider from "./HunkExpandDivider"; const EMPTY_ANNOTATION_FACTORY = {}; @@ -81,11 +82,6 @@ const ButtonWrapper = styled.div` margin-left: auto; `; -const HunkDivider = styled.div` - background: #98d8f3; - font-size: 0.7rem; -`; - const ChangeTypeTag = styled(Tag)` margin-left: 0.75rem; `; @@ -153,32 +149,28 @@ class DiffFile extends React.Component { if (expandableHunk.maxExpandHeadRange > 0) { if (expandableHunk.maxExpandHeadRange <= 10) { return ( - - - - - + + + ); } else { return ( - - - {" "} - - - + + {" "} + + ); } } @@ -190,32 +182,28 @@ class DiffFile extends React.Component { if (expandableHunk.maxExpandBottomRange > 0) { if (expandableHunk.maxExpandBottomRange <= 10) { return ( - - - - - + + + ); } else { return ( - - - {" "} - - - + + {" "} + + ); } } @@ -226,20 +214,18 @@ class DiffFile extends React.Component { createLastHunkFooter = (expandableHunk: ExpandableHunk) => { if (expandableHunk.maxExpandBottomRange !== 0) { return ( - - - {" "} - - - + + {" "} + + ); } // hunk header must be defined @@ -269,7 +255,6 @@ class DiffFile extends React.Component { }; diffExpansionFailed = (err: any) => { - console.log(err); this.setState({ expansionError: err }); }; diff --git a/scm-ui/ui-components/src/repos/HunkExpandDivider.tsx b/scm-ui/ui-components/src/repos/HunkExpandDivider.tsx new file mode 100644 index 0000000000..f30d248dd9 --- /dev/null +++ b/scm-ui/ui-components/src/repos/HunkExpandDivider.tsx @@ -0,0 +1,42 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import React, { FC } from "react"; +import { Decoration } from "react-diff-view"; +import styled from "styled-components"; + +const HunkDivider = styled.div` + background: #98d8f3; + font-size: 0.7rem; + padding-left: 1.78em; +`; + +const HunkExpandDivider: FC = ({ children }) => { + return ( + + {children} + + ); +}; + +export default HunkExpandDivider; diff --git a/scm-ui/ui-components/src/repos/HunkExpandLink.tsx b/scm-ui/ui-components/src/repos/HunkExpandLink.tsx index dfff80160c..0b337c5bd2 100644 --- a/scm-ui/ui-components/src/repos/HunkExpandLink.tsx +++ b/scm-ui/ui-components/src/repos/HunkExpandLink.tsx @@ -24,6 +24,7 @@ import React, { FC, useState } from "react"; import { useTranslation } from "react-i18next"; import classNames from "classnames"; +import styled from "styled-components"; type Props = { icon: string; @@ -31,6 +32,10 @@ type Props = { onClick: () => Promise; }; +const ExpandLink = styled.span` + cursor: pointer; +`; + const HunkExpandLink: FC = ({ icon, text, onClick }) => { const [t] = useTranslation("repos"); const [loading, setLoading] = useState(false); @@ -44,9 +49,9 @@ const HunkExpandLink: FC = ({ icon, text, onClick }) => { }; return ( - + {loading ? t("diff.expanding") : text} - + ); };