From e5153b4fa9c7332f74f8adf9dd6a0fa5b210fbf2 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 12 Jun 2020 09:08:35 +0200 Subject: [PATCH] display only new annotations --- scm-ui/ui-components/src/Annotate.tsx | 36 +++++++++++++++++---------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/scm-ui/ui-components/src/Annotate.tsx b/scm-ui/ui-components/src/Annotate.tsx index b71d78023b..e0e1768611 100644 --- a/scm-ui/ui-components/src/Annotate.tsx +++ b/scm-ui/ui-components/src/Annotate.tsx @@ -53,12 +53,29 @@ type Props = { source: AnnotatedSource; }; -const Author = styled.a` +type LineElementProps = { + newAnnotation: boolean; +}; + +const Author = styled.a` width: 8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; float: left; + + visibility: ${({ newAnnotation }) => (newAnnotation ? "visible" : "hidden")}; +`; + +const When = styled.span` + width: 6.5em; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + float: left; + + margin: 0 0.5em; + visibility: ${({ newAnnotation }) => (newAnnotation ? "visible" : "hidden")}; `; const LineNumber = styled.span` @@ -76,19 +93,10 @@ const LineNumber = styled.span` padding: 0 0.5em; `; -const When = styled.span` - width: 90px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - float: left; - - margin: 0 0.5em; -`; - const Annotate: FC = ({ source }) => { // @ts-ignore const defaultRenderer = ({ rows, stylesheet, useInlineStyles }) => { + let lastRevision = ""; // @ts-ignore return rows.map((node, i) => { const line = createElement({ @@ -100,10 +108,12 @@ const Annotate: FC = ({ source }) => { if (i + 1 < rows.length) { const annotation = source.lines[i]; + const newAnnotation = annotation.revision !== lastRevision; + lastRevision = annotation.revision; return ( - {annotation.author.name}{" "} - + {annotation.author.name}{" "} + {" "} {i + 1} {line}