11import React , { useState , useEffect , useLayoutEffect , useRef , useCallback , useMemo } from 'react' ;
22import { Icons } from './Icons' ;
3+ import { FileIcon } from './FileIcon' ;
34import './ChangesPanel.css' ;
45
56const COMMIT_MESSAGE_STORAGE_KEY = 'commitMessage' ;
@@ -20,6 +21,7 @@ interface ChangesPanelProps {
2021 branch : string ;
2122 branches : { name : string ; is_current : boolean } [ ] ;
2223 isSwitchingBranch : boolean ;
24+ fileIconsStyle ?: 'colored' | 'monochrome' | 'disabled' ;
2325 onFileClick : ( path : string ) => void ;
2426 onRefresh : ( ) => void ;
2527 onBranchChange : ( branch : string ) => Promise < boolean > ;
@@ -106,6 +108,7 @@ interface ChangesPanelItemProps {
106108 mode : 'merge' | 'staged' | 'changed' | 'flat' ;
107109 isActive : boolean ;
108110 isSelected : boolean ;
111+ fileIconsStyle ?: 'colored' | 'monochrome' | 'disabled' ;
109112 onClick : ( rowId : string , path : string ) => void ;
110113 onRevert : ( path : string ) => void ;
111114 onStage : ( path : string ) => void ;
@@ -139,6 +142,7 @@ const ChangesPanelItemImpl: React.FC<ChangesPanelItemProps> = ({
139142 mode,
140143 isActive,
141144 isSelected,
145+ fileIconsStyle = 'colored' ,
142146 onClick,
143147 onRevert,
144148 onStage,
@@ -182,6 +186,7 @@ const ChangesPanelItemImpl: React.FC<ChangesPanelItemProps> = ({
182186 >
183187 < div className = "changes-file-info" >
184188 < div className = "changes-file-main" >
189+ < FileIcon path = { file . path } styleType = { fileIconsStyle } className = "changes-file-icon" />
185190 < span
186191 className = { `changes-filename ${ statusTextColors [ file . status ] } ` }
187192 title = { file . path }
@@ -222,6 +227,7 @@ const areChangesPanelItemsEqual = (
222227 && prev . mode === next . mode
223228 && prev . isActive === next . isActive
224229 && prev . isSelected === next . isSelected
230+ && prev . fileIconsStyle === next . fileIconsStyle
225231 && prev . onClick === next . onClick
226232 && prev . onRevert === next . onRevert
227233 && prev . onStage === next . onStage
@@ -239,6 +245,7 @@ const ChangesPanelImpl: React.FC<ChangesPanelProps> = ({
239245 branch,
240246 branches,
241247 isSwitchingBranch,
248+ fileIconsStyle = 'colored' ,
242249 onFileClick,
243250 onRefresh,
244251 onBranchChange,
@@ -519,6 +526,7 @@ const ChangesPanelImpl: React.FC<ChangesPanelProps> = ({
519526 mode = { mode }
520527 isActive = { activeFilePath === file . path }
521528 isSelected = { selectedRowId === `${ mode } ::${ file . path } ` }
529+ fileIconsStyle = { fileIconsStyle }
522530 onClick = { handleItemClick }
523531 onRevert = { onRevert }
524532 onStage = { onStage }
@@ -527,7 +535,7 @@ const ChangesPanelImpl: React.FC<ChangesPanelProps> = ({
527535 setStatsRef = { setStatsRef }
528536 />
529537 ) )
530- ) , [ activeFilePath , handleItemClick , onRevert , onStage , onUnstage , selectedRowId , setItemRef , setStatsRef ] ) ;
538+ ) , [ activeFilePath , handleItemClick , onRevert , onStage , onUnstage , selectedRowId , setItemRef , setStatsRef , fileIconsStyle ] ) ;
531539
532540 return (
533541 < div className = "changes-panel" >
@@ -774,6 +782,10 @@ const areBranchesEqual = (
774782} ;
775783
776784const areEqual = ( prev : ChangesPanelProps , next : ChangesPanelProps ) : boolean => {
785+ if ( prev . fileIconsStyle !== next . fileIconsStyle ) {
786+ return false ;
787+ }
788+
777789 if ( prev . branch !== next . branch || prev . isSwitchingBranch !== next . isSwitchingBranch ) {
778790 return false ;
779791 }
0 commit comments