aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src
diff options
context:
space:
mode:
authorSascha <GlancingMind@outlook.com>2021-03-22 13:47:44 +0100
committerSascha <GlancingMind@outlook.com>2021-03-24 14:26:45 +0100
commitbd6159a25b548f8f939f137b70dcf77a722e70dc (patch)
tree9a4b537983a74fd6149cdc1fa617084b259e7f5b /webui/src
parent4a2e04df61d6bf1264a7f353af621e8e6207653d (diff)
downloadgit-bug-bd6159a25b548f8f939f137b70dcf77a722e70dc.tar.gz
Treat description not as edit
Diffstat (limited to 'webui/src')
-rw-r--r--webui/src/pages/bug/MessageHistoryDialog.tsx29
1 files changed, 20 insertions, 9 deletions
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 (
+ <>
+ <Tooltip title={moment(date).format('LLLL')}>
+ <span>
+ {desc}
+ <Moment date={date} format="on ll" />
+ {mostRecent}
+ </span>
+ </Tooltip>
+ </>
+ );
+ };
+
return (
<Dialog
onClose={onClose}
@@ -190,7 +208,7 @@ function MessageHistoryDialog({ bugId, commentId, open, onClose }: Props) {
maxWidth="md"
>
<DialogTitle id="customized-dialog-title" onClose={onClose}>
- Edited {history?.length} times.
+ {`Edited ${editCount} ${editCount > 1 ? 'times' : 'time'}.`}
</DialogTitle>
<DialogContent dividers>
{history?.map((edit, index) => (
@@ -204,14 +222,7 @@ function MessageHistoryDialog({ bugId, commentId, open, onClose }: Props) {
aria-controls="panel1d-content"
id="panel1d-header"
>
- <Typography>
- {`#${history?.length - index} • Edited `}
- <Tooltip title={moment(edit.date).format('LLLL')}>
- <Moment date={edit.date} format="on ll" />
- </Tooltip>
- {index === 0 && ' (most recent edit)'}
- {index === history?.length - 1 && ' (Initial description)'}
- </Typography>
+ <Typography>{getSummary(index, edit.date)}</Typography>
</AccordionSummary>
<AccordionDetails>{edit.message}</AccordionDetails>
</Accordion>