From 3e57c5049a2f1240ac366412624240bbf995c4b6 Mon Sep 17 00:00:00 2001 From: Jason Harris Date: Tue, 23 Jan 2024 09:20:57 -0800 Subject: [PATCH 1/8] truncate commit message in commit view if necessary --- client/web/src/repo/commits/GitCommitNode.tsx | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/client/web/src/repo/commits/GitCommitNode.tsx b/client/web/src/repo/commits/GitCommitNode.tsx index 5d614f31e0061..e652217eecd00 100644 --- a/client/web/src/repo/commits/GitCommitNode.tsx +++ b/client/web/src/repo/commits/GitCommitNode.tsx @@ -83,6 +83,7 @@ export const GitCommitNode: React.FunctionComponent { const [showCommitMessageBody, setShowCommitMessageBody] = useState(false) + const [truncatedCommitMessage, setTruncatedCommitMessage] = useState(true) const [flashCopiedToClipboardMessage, setFlashCopiedToClipboardMessage] = useState(false) const sourceType = node.perforceChangelist ? RepositoryType.PERFORCE_DEPOT : RepositoryType.GIT_REPOSITORY @@ -160,9 +161,37 @@ export const GitCommitNode: React.FunctionComponent -
-                    {node.body && }
-                
+ {truncatedCommitMessage ? ( +
+                        <>
+                            {node.body && (
+                                
+                            )}
+                            
+                        
+                    
+ ) : ( + <> +
+                            {node.body && }
+                        
+ + + )} ) : undefined From 7089103fdc52d01ec92b6d42eb2489052d4cd2b5 Mon Sep 17 00:00:00 2001 From: Jason Harris Date: Tue, 23 Jan 2024 09:32:46 -0800 Subject: [PATCH 2/8] remove superfluous fragment --- client/web/src/repo/commits/GitCommitNode.tsx | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/client/web/src/repo/commits/GitCommitNode.tsx b/client/web/src/repo/commits/GitCommitNode.tsx index e652217eecd00..29b5d70d86148 100644 --- a/client/web/src/repo/commits/GitCommitNode.tsx +++ b/client/web/src/repo/commits/GitCommitNode.tsx @@ -163,19 +163,17 @@ export const GitCommitNode: React.FunctionComponent {truncatedCommitMessage ? (
-                        <>
-                            {node.body && (
-                                
-                            )}
-                            
-                        
+                        {node.body && (
+                            
+                        )}
+                        
                     
) : ( <> From ecdfcf4ea5fffbc294b918845ce2c2ddb7cfcb81 Mon Sep 17 00:00:00 2001 From: Jason Harris Date: Tue, 23 Jan 2024 14:04:27 -0800 Subject: [PATCH 3/8] make it more concise --- client/web/src/repo/commits/GitCommitNode.tsx | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/client/web/src/repo/commits/GitCommitNode.tsx b/client/web/src/repo/commits/GitCommitNode.tsx index 29b5d70d86148..898ab8e8072e0 100644 --- a/client/web/src/repo/commits/GitCommitNode.tsx +++ b/client/web/src/repo/commits/GitCommitNode.tsx @@ -158,37 +158,28 @@ export const GitCommitNode: React.FunctionComponent ) + const commitContent = truncatedCommitMessage && node.body ? `${node.body.slice(0, 240)}...` : node.body + const commitMessageBody = expandCommitMessageBody || showCommitMessageBody ? (
- {truncatedCommitMessage ? ( + {commitContent && node.body && (
-                        {node.body && (
-                            
+                        
+                        {node.body.length > 240 && (
+                            
                         )}
-                        
                     
- ) : ( - <> -
-                            {node.body && }
-                        
- - )}
) : undefined From 8bab4cd1be920e55d7d4bf619d28452d0df58bf9 Mon Sep 17 00:00:00 2001 From: Jason Harris Date: Wed, 24 Jan 2024 13:17:40 -0800 Subject: [PATCH 4/8] make it simpler --- client/web/src/repo/commits/GitCommitNode.tsx | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/client/web/src/repo/commits/GitCommitNode.tsx b/client/web/src/repo/commits/GitCommitNode.tsx index 898ab8e8072e0..6d8036ead46ad 100644 --- a/client/web/src/repo/commits/GitCommitNode.tsx +++ b/client/web/src/repo/commits/GitCommitNode.tsx @@ -158,31 +158,29 @@ export const GitCommitNode: React.FunctionComponent ) - const commitContent = truncatedCommitMessage && node.body ? `${node.body.slice(0, 240)}...` : node.body - - const commitMessageBody = - expandCommitMessageBody || showCommitMessageBody ? ( -
- {commitContent && node.body && ( -
-                        
-                        {node.body.length > 240 && (
-                            
-                        )}
-                    
- )} -
- ) : undefined + const showCommitMessage = expandCommitMessageBody || showCommitMessageBody + const commitContent = truncatedCommitMessage && node.body ? `${node.body.slice(0, 240)}` : node.body + + const commitMessageBody = showCommitMessage && commitContent ? ( +
+
+                
+                {commitContent.length >= 240 &&
+                    
+                }
+            
+
+ ) : undefined const bylineElement = ( Date: Wed, 24 Jan 2024 14:21:44 -0800 Subject: [PATCH 5/8] more simple --- client/web/src/repo/commits/GitCommitNode.tsx | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/client/web/src/repo/commits/GitCommitNode.tsx b/client/web/src/repo/commits/GitCommitNode.tsx index 6d8036ead46ad..96ab8c5bf966b 100644 --- a/client/web/src/repo/commits/GitCommitNode.tsx +++ b/client/web/src/repo/commits/GitCommitNode.tsx @@ -158,29 +158,25 @@ export const GitCommitNode: React.FunctionComponent ) + const handleTruncate = () => setTruncatedCommitMessage(!truncatedCommitMessage) const showCommitMessage = expandCommitMessageBody || showCommitMessageBody - const commitContent = truncatedCommitMessage && node.body ? `${node.body.slice(0, 240)}` : node.body - - const commitMessageBody = showCommitMessage && commitContent ? ( -
-
-                
-                {commitContent.length >= 240 &&
-                    
-                }
-            
-
- ) : undefined + const commitContent = + truncatedCommitMessage && node.body && node.body.length > 240 ? `${node.body.slice(0, 240)}...` : node.body + const truncationNeeded = commitContent && commitContent.length > 240 + + const commitMessageBody = + showCommitMessage && commitContent ? ( +
+
+                    
+                    {truncationNeeded && (
+                        
+                    )}
+                
+
+ ) : undefined const bylineElement = ( Date: Wed, 24 Jan 2024 17:50:55 -0800 Subject: [PATCH 6/8] var name change --- client/web/src/repo/commits/GitCommitNode.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/web/src/repo/commits/GitCommitNode.tsx b/client/web/src/repo/commits/GitCommitNode.tsx index 96ab8c5bf966b..80a9f5c66a4fb 100644 --- a/client/web/src/repo/commits/GitCommitNode.tsx +++ b/client/web/src/repo/commits/GitCommitNode.tsx @@ -83,7 +83,7 @@ export const GitCommitNode: React.FunctionComponent { const [showCommitMessageBody, setShowCommitMessageBody] = useState(false) - const [truncatedCommitMessage, setTruncatedCommitMessage] = useState(true) + const [truncateCommitMessage, setTruncateCommitMessage] = useState(true) const [flashCopiedToClipboardMessage, setFlashCopiedToClipboardMessage] = useState(false) const sourceType = node.perforceChangelist ? RepositoryType.PERFORCE_DEPOT : RepositoryType.GIT_REPOSITORY @@ -158,10 +158,10 @@ export const GitCommitNode: React.FunctionComponent ) - const handleTruncate = () => setTruncatedCommitMessage(!truncatedCommitMessage) + const handleTruncate = () => setTruncateCommitMessage(!truncateCommitMessage) const showCommitMessage = expandCommitMessageBody || showCommitMessageBody const commitContent = - truncatedCommitMessage && node.body && node.body.length > 240 ? `${node.body.slice(0, 240)}...` : node.body + truncateCommitMessage && node.body && node.body.length > 240 ? `${node.body.slice(0, 240)}...` : node.body const truncationNeeded = commitContent && commitContent.length > 240 const commitMessageBody = @@ -171,7 +171,7 @@ export const GitCommitNode: React.FunctionComponent {truncationNeeded && ( )} From 4e76b19ffc93a7d0921f989656c7fb1c96788e99 Mon Sep 17 00:00:00 2001 From: Jason Harris Date: Thu, 25 Jan 2024 10:17:58 -0800 Subject: [PATCH 7/8] tweaks --- client/web/src/repo/commits/GitCommitNode.tsx | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/client/web/src/repo/commits/GitCommitNode.tsx b/client/web/src/repo/commits/GitCommitNode.tsx index 80a9f5c66a4fb..7bdee47de490a 100644 --- a/client/web/src/repo/commits/GitCommitNode.tsx +++ b/client/web/src/repo/commits/GitCommitNode.tsx @@ -21,6 +21,7 @@ import { GitCommitNodeByline } from './GitCommitNodeByline' import styles from './GitCommitNode.module.scss' +const TRUNCATED_COMMIT_MESSAGE_LENGTH = 240 export interface GitCommitNodeProps { node: GitCommitFields @@ -158,25 +159,30 @@ export const GitCommitNode: React.FunctionComponent ) - const handleTruncate = () => setTruncateCommitMessage(!truncateCommitMessage) - const showCommitMessage = expandCommitMessageBody || showCommitMessageBody - const commitContent = - truncateCommitMessage && node.body && node.body.length > 240 ? `${node.body.slice(0, 240)}...` : node.body - const truncationNeeded = commitContent && commitContent.length > 240 - - const commitMessageBody = - showCommitMessage && commitContent ? ( -
-
-                    
-                    {truncationNeeded && (
-                        
-                    )}
-                
-
- ) : undefined + const commitMessage = node.body ?? '' + const truncationNeeded = commitMessage.length > TRUNCATED_COMMIT_MESSAGE_LENGTH + const truncatedCommitMessage = + truncateCommitMessage && truncationNeeded + ? `${commitMessage.slice(0, TRUNCATED_COMMIT_MESSAGE_LENGTH)}...` + : commitMessage + + const commitMessageBody = ( +
+
+                
+                {truncationNeeded && (
+                    
+                )}
+            
+
+ ) const bylineElement = ( Date: Fri, 26 Jan 2024 13:25:24 -0800 Subject: [PATCH 8/8] remove unnessecary commit message body from blobview --- client/web/src/repo/commits/GitCommitNode.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/client/web/src/repo/commits/GitCommitNode.tsx b/client/web/src/repo/commits/GitCommitNode.tsx index 7bdee47de490a..75f8bb45daed2 100644 --- a/client/web/src/repo/commits/GitCommitNode.tsx +++ b/client/web/src/repo/commits/GitCommitNode.tsx @@ -371,7 +371,6 @@ export const GitCommitNode: React.FunctionComponent{oidElement}} {afterElement} - {commitMessageBody} )}