@@ -7,6 +7,7 @@ import { GitExtension } from '../model';
77import { hiddenButtonStyle } from '../style/ActionButtonStyle' ;
88import {
99 historySideBarStyle ,
10+ noHistoryFoundStyle ,
1011 selectedHistoryFileStyle
1112} from '../style/HistorySideBarStyle' ;
1213import { ContextCommandIDs , Git } from '../tokens' ;
@@ -145,40 +146,46 @@ export const HistorySideBar: React.FunctionComponent<IHistorySideBarProps> = (
145146 onDoubleClick = { removeSelectedFile }
146147 />
147148 ) }
148- { commits . map ( ( commit : Git . ISingleCommitInfo ) => {
149- const commonProps = {
150- commit,
151- branches : props . branches ,
152- model : props . model ,
153- commands : props . commands ,
154- trans : props . trans
155- } ;
149+ { commits . length ? (
150+ commits . map ( ( commit : Git . ISingleCommitInfo ) => {
151+ const commonProps = {
152+ commit,
153+ branches : props . branches ,
154+ model : props . model ,
155+ commands : props . commands ,
156+ trans : props . trans
157+ } ;
156158
157- // Only pass down callback when single file history is open
158- // and its diff is viewable
159- const onOpenDiff =
160- props . model . selectedHistoryFile && ! commit . is_binary
161- ? openDiff ( commit ) (
162- props . model . selectedHistoryFile . to ,
163- ! commit . is_binary
164- )
165- : undefined ;
159+ // Only pass down callback when single file history is open
160+ // and its diff is viewable
161+ const onOpenDiff =
162+ props . model . selectedHistoryFile && ! commit . is_binary
163+ ? openDiff ( commit ) (
164+ props . model . selectedHistoryFile . to ,
165+ ! commit . is_binary
166+ )
167+ : undefined ;
166168
167- return (
168- < PastCommitNode
169- key = { commit . commit }
170- { ...commonProps }
171- onOpenDiff = { onOpenDiff }
172- >
173- { ! props . model . selectedHistoryFile && (
174- < SinglePastCommitInfo
175- { ...commonProps }
176- onOpenDiff = { openDiff ( commit ) }
177- />
178- ) }
179- </ PastCommitNode >
180- ) ;
181- } ) }
169+ return (
170+ < PastCommitNode
171+ key = { commit . commit }
172+ { ...commonProps }
173+ onOpenDiff = { onOpenDiff }
174+ >
175+ { ! props . model . selectedHistoryFile && (
176+ < SinglePastCommitInfo
177+ { ...commonProps }
178+ onOpenDiff = { openDiff ( commit ) }
179+ />
180+ ) }
181+ </ PastCommitNode >
182+ ) ;
183+ } )
184+ ) : (
185+ < li className = { noHistoryFoundStyle } >
186+ { props . trans . __ ( 'No history found for the selected file.' ) }
187+ </ li >
188+ ) }
182189 </ ol >
183190 ) ;
184191} ;
0 commit comments