@@ -32,19 +32,22 @@ import {
3232 WhitespaceMode ,
3333 LayoutRadioButtons ,
3434 useLayoutState ,
35- devices
35+ devices ,
3636} from "@scm-manager/ui-components" ;
3737import { Comment } from "../types/PullRequest" ;
3838import PartialNotification from "./PartialNotification" ;
3939import styled from "styled-components" ;
4040import { useHistory , useLocation } from "react-router-dom" ;
41+ import { Icon } from "@scm-manager/ui-core" ;
42+ import classNames from "classnames" ;
4143
4244type LoadingDiffProps = DiffObjectProps & {
4345 diffUrl : string ;
4446 actions : any ;
4547 pullRequestComments : Comment [ ] ;
4648 refetchOnWindowFocus ?: boolean ;
4749 stickyHeader ?: boolean | number ;
50+ reviewedFiles ?: string [ ] ;
4851} ;
4952
5053const StickyContainer = styled . div < { top : number } > `
@@ -57,6 +60,22 @@ const StickyContainer = styled.div<{ top: number }>`
5760 z-index: 11;
5861` ;
5962
63+ export const StackedSpan = styled . span `
64+ width: 3em;
65+ height: 3em;
66+ font-size: 0.5em;
67+ ` ;
68+
69+ export const StyledIcon = styled ( Icon ) < { isSmaller ?: boolean } > `
70+ ${ ( { isSmaller } ) =>
71+ isSmaller &&
72+ `
73+ font-size: 0.5em;
74+ margin-top: 0.05rem;
75+ ` }
76+ min-width: 1.5rem;
77+ ` ;
78+
6079export const StickyTreeContainer = styled . div `
6180 @media (min-width: ${ devices . widescreen . width } px) {
6281 position: sticky;
@@ -75,7 +94,14 @@ export const Divider = styled.div`
7594 box-shadow: 0 24px 3px -24px var(--scm-border-color);
7695` ;
7796
78- const LoadingDiff : FC < LoadingDiffProps > = ( { diffUrl, actions, pullRequestComments, stickyHeader, ...props } ) => {
97+ const LoadingDiff : FC < LoadingDiffProps > = ( {
98+ diffUrl,
99+ actions,
100+ pullRequestComments,
101+ stickyHeader,
102+ reviewedFiles,
103+ ...props
104+ } ) => {
79105 const [ t ] = useTranslation ( "plugins" ) ;
80106 const [ ignoreWhitespace , setIgnoreWhitespace ] = useState < WhitespaceMode > ( "NONE" ) ;
81107 const [ layout , setLayout ] = useLayoutState ( ) ;
@@ -140,8 +166,7 @@ const LoadingDiff: FC<LoadingDiffProps> = ({ diffUrl, actions, pullRequestCommen
140166 </ div >
141167 < StickyTreeContainer
142168 className = {
143- ( layout === "Both" ? "column pl-3" : "column pl-3 is-full" ) +
144- ( layout !== "Diff" ? "" : " is-hidden" )
169+ ( layout === "Both" ? "column pl-3" : "column pl-3 is-full" ) + ( layout !== "Diff" ? "" : " is-hidden" )
145170 }
146171 >
147172 < FileTreeContent isBorder = { layout !== "Diff" } >
@@ -152,6 +177,46 @@ const LoadingDiff: FC<LoadingDiffProps> = ({ diffUrl, actions, pullRequestCommen
152177 tree = { data . tree }
153178 currentFile = { decodeURIComponent ( getFileNameFromHash ( location . hash ) ?? "" ) }
154179 setCurrentFile = { setFilePath }
180+ FileTreeNodeWrapper = { ( {
181+ path,
182+ name,
183+ isFile,
184+ iconName,
185+ iconColor,
186+ changeType,
187+ children,
188+ isCurrentFile,
189+ } ) => {
190+ if ( isFile && reviewedFiles ?. find ( ( file ) => file === path ) ) {
191+ console . log ( "rendering reviewed icon for" , name ) ;
192+ const lightIcon = (
193+ < StackedSpan className = "fa-stack" >
194+ < StyledIcon
195+ className = { classNames ( "fa-stack-2x" , `has-text-${ iconColor } ` ) }
196+ type = "far"
197+ alt = { t ( "diff.showContent" ) }
198+ >
199+ file
200+ </ StyledIcon >
201+ < StyledIcon
202+ className = { classNames ( "fa-stack-1x" , "is-relative" , `has-text-${ iconColor } ` ) }
203+ isSmaller = { iconName === "circle" }
204+ alt = { t ( `diff.changes.${ changeType } ` ) }
205+ >
206+ { iconName }
207+ </ StyledIcon >
208+ </ StackedSpan >
209+ ) ;
210+ return (
211+ < >
212+ { lightIcon }
213+ < div className = { classNames ( "ml-1" , "has-text-secondary has-hover-color-blue" , isCurrentFile ? "has-text-weight-bold" : "" ) } > { name } </ div >
214+ </ >
215+ ) ;
216+ } else {
217+ return children ;
218+ }
219+ } }
155220 />
156221 ) }
157222 </ FileTreeContent >
0 commit comments