From bd6159a25b548f8f939f137b70dcf77a722e70dc Mon Sep 17 00:00:00 2001 From: Sascha Date: Mon, 22 Mar 2021 13:47:44 +0100 Subject: Treat description not as edit --- webui/src/pages/bug/MessageHistoryDialog.tsx | 29 +++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'webui/src/pages/bug/MessageHistoryDialog.tsx') diff --git a/webui/src/pages/bug/MessageHistoryDialog.tsx b/webui/src/pages/bug/MessageHistoryDialog.tsx index 139eb4a5..0ed33642 100644 --- a/webui/src/pages/bug/MessageHistoryDialog.tsx +++ b/webui/src/pages/bug/MessageHistoryDialog.tsx @@ -173,6 +173,7 @@ function MessageHistoryDialog({ bugId, commentId, open, onClose }: Props) { // Sort by most recent edit. Must create a copy of constant history as // reverse() modifies inplace. const history = comment?.history.slice().reverse(); + const editCount = history?.length === undefined ? 0 : history?.length - 1; const handleChange = (panel: string) => ( event: React.ChangeEvent<{}>, @@ -181,6 +182,23 @@ function MessageHistoryDialog({ bugId, commentId, open, onClose }: Props) { setExpanded(newExpanded ? panel : false); }; + const getSummary = (index: number, date: Date) => { + const desc = + index === editCount ? 'Created ' : `#${editCount - index} • Edited `; + const mostRecent = index === 0 ? ' (most recent)' : ''; + return ( + <> + + + {desc} + + {mostRecent} + + + + ); + }; + return ( - Edited {history?.length} times. + {`Edited ${editCount} ${editCount > 1 ? 'times' : 'time'}.`} {history?.map((edit, index) => ( @@ -204,14 +222,7 @@ function MessageHistoryDialog({ bugId, commentId, open, onClose }: Props) { aria-controls="panel1d-content" id="panel1d-header" > - - {`#${history?.length - index} • Edited `} - - - - {index === 0 && ' (most recent edit)'} - {index === history?.length - 1 && ' (Initial description)'} - + {getSummary(index, edit.date)} {edit.message} -- cgit