From 78e2f55d0f615bf8aec1d41d570ace5e3c8364a4 Mon Sep 17 00:00:00 2001 From: R Ranathunga Date: Tue, 21 May 2024 14:17:48 -0700 Subject: [PATCH] fix: history files not showing properly --- .../Analyst/History/HistoryFile.tsx | 192 +++++++++--------- 1 file changed, 97 insertions(+), 95 deletions(-) diff --git a/app/components/Analyst/History/HistoryFile.tsx b/app/components/Analyst/History/HistoryFile.tsx index 524527912f..75d68dd298 100644 --- a/app/components/Analyst/History/HistoryFile.tsx +++ b/app/components/Analyst/History/HistoryFile.tsx @@ -32,103 +32,105 @@ const HistoryFile = ({ keepUnchangedValues: true, full: true, }); - return filesDiff && filesDiff?.length > 0 - ? (filesDiff[0][0] === '+' || - filesDiff[0][0] === '-' || - filesDiff[0][0] === '~') && ( - - - {tableTitle && ( - - Files - - )} - - - - {title} - -
- {filesDiff && - filesDiff.map((file) => { - // A file was added - if (file[0] === '+') { - return ( -
- Added file{' '} + + const hasFileChanges = + filesDiff?.filter( + (file) => file[0] === '+' || file[0] === '-' || file[0] === '~' + ).length > 0; + + return hasFileChanges ? ( + + + {tableTitle && ( + + Files + + )} + + + + {title} + +
+ {filesDiff && + filesDiff.map((file) => { + // A file was added + if (file[0] === '+') { + return ( +
+ Added file{' '} + +
+ ); + } + // A file was removed + if (file[0] === '-') { + return ( +
+ Deleted file{' '} + + + +
+ ); + } + // The object was modified (file replacement) + if (file[0] === '~') { + if (filesDiff.length === 1) { + return ( +
+ Replaced file{' '} + + + {' '} + with file{' '} + +
+ ); + } + return ( + <> +
+ Deleted file{' '} + + + {' '} +
+
+ Added file{' '} + -
- ); - } - // A file was removed - if (file[0] === '-') { - return ( -
- Deleted file{' '} - - - -
- ); - } - // The object was modified (file replacement) - if (file[0] === '~') { - if (filesDiff.length === 1) { - return ( -
- Replaced file{' '} - - - {' '} - with file{' '} - -
- ); - } - return ( - <> -
- Deleted file{' '} - - - {' '} -
-
- Added file{' '} - - - {' '} -
- - ); - } - return null; - })} -
- - - -
- ) - : null; + {' '} +
+ + ); + } + return null; + })} +
+ + + +
+ ) : null; }; export default HistoryFile;