aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src
diff options
context:
space:
mode:
authorSascha <GlancingMind@outlook.com>2021-03-18 15:45:20 +0100
committerSascha <GlancingMind@outlook.com>2021-03-19 17:52:57 +0100
commitdefd1ae00cccce0b46207e03084fe6af32096610 (patch)
treed30d550ba6dce1898be74958ae6faa66a87a9b38 /webui/src
parent25d3aca9adac3441da14d53f489b2609fefac21f (diff)
downloadgit-bug-defd1ae00cccce0b46207e03084fe6af32096610.tar.gz
Populate history menu with edit steps
Diffstat (limited to 'webui/src')
-rw-r--r--webui/src/pages/bug/EditHistoryMenu.tsx54
-rw-r--r--webui/src/pages/bug/Message.tsx2
-rw-r--r--webui/src/pages/bug/MessageCommentFragment.graphql4
-rw-r--r--webui/src/pages/bug/MessageCreateFragment.graphql4
-rw-r--r--webui/src/pages/bug/MessageEditHistory.graphql15
5 files changed, 55 insertions, 24 deletions
diff --git a/webui/src/pages/bug/EditHistoryMenu.tsx b/webui/src/pages/bug/EditHistoryMenu.tsx
index 10b66f8f..a916a1a8 100644
--- a/webui/src/pages/bug/EditHistoryMenu.tsx
+++ b/webui/src/pages/bug/EditHistoryMenu.tsx
@@ -1,36 +1,43 @@
import React from 'react';
+import CircularProgress from '@material-ui/core/CircularProgress';
import IconButton, { IconButtonProps } from '@material-ui/core/IconButton';
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
import HistoryIcon from '@material-ui/icons/History';
-const options = [
- 'None',
- 'Atria',
- 'Callisto',
- 'Dione',
- 'Ganymede',
- 'Hangouts Call',
- 'Luna',
- 'Oberon',
- 'Phobos',
- 'Pyxis',
- 'Sedna',
- 'Titania',
- 'Triton',
- 'Umbriel',
-];
+import Date from 'src/components/Date';
+
+import { AddCommentFragment } from './MessageCommentFragment.generated';
+import { CreateFragment } from './MessageCreateFragment.generated';
+import { useMessageEditHistoryQuery } from './MessageEditHistory.generated';
const ITEM_HEIGHT = 48;
type Props = {
+ bugId: string;
+ commentId: string;
iconBtnProps?: IconButtonProps;
};
-function EditHistoryMenu({ iconBtnProps }: Props) {
+function EditHistoryMenu({ iconBtnProps, bugId, commentId }: Props) {
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const open = Boolean(anchorEl);
+ const { loading, error, data } = useMessageEditHistoryQuery({
+ variables: { bugIdPrefix: bugId },
+ });
+ if (loading) return <CircularProgress />;
+ if (error) return <p>Error: {error}</p>;
+
+ const comments = data?.repository?.bug?.timeline.comments as (
+ | AddCommentFragment
+ | CreateFragment
+ )[];
+ // NOTE Searching for the changed comment could be dropped if GraphQL get
+ // filter by id argument for timelineitems
+ const comment = comments.find((elem) => elem.id === commentId);
+ const history = comment?.history;
+
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};
@@ -63,13 +70,12 @@ function EditHistoryMenu({ iconBtnProps }: Props) {
},
}}
>
- {options.map((option) => (
- <MenuItem
- key={option}
- selected={option === 'Pyxis'}
- onClick={handleClose}
- >
- {option}
+ <MenuItem key={0} disabled>
+ Edited {history?.length} times.
+ </MenuItem>
+ {history?.map((edit, index) => (
+ <MenuItem key={index} onClick={handleClose}>
+ <Date date={edit.date} />
</MenuItem>
))}
</Menu>
diff --git a/webui/src/pages/bug/Message.tsx b/webui/src/pages/bug/Message.tsx
index d36b1044..b117c103 100644
--- a/webui/src/pages/bug/Message.tsx
+++ b/webui/src/pages/bug/Message.tsx
@@ -96,6 +96,8 @@ function Message({ bug, op }: Props) {
{comment.edited && (
<EditHistoryMenu
iconBtnProps={{ className: classes.headerActions }}
+ bugId={bug.id}
+ commentId={comment.id}
/>
)}
<IfLoggedIn>
diff --git a/webui/src/pages/bug/MessageCommentFragment.graphql b/webui/src/pages/bug/MessageCommentFragment.graphql
index 337eade0..c852b4b0 100644
--- a/webui/src/pages/bug/MessageCommentFragment.graphql
+++ b/webui/src/pages/bug/MessageCommentFragment.graphql
@@ -6,4 +6,8 @@ fragment AddComment on AddCommentTimelineItem {
...authored
edited
message
+ history {
+ message
+ date
+ }
}
diff --git a/webui/src/pages/bug/MessageCreateFragment.graphql b/webui/src/pages/bug/MessageCreateFragment.graphql
index 81f80afb..1f4647b6 100644
--- a/webui/src/pages/bug/MessageCreateFragment.graphql
+++ b/webui/src/pages/bug/MessageCreateFragment.graphql
@@ -6,4 +6,8 @@ fragment Create on CreateTimelineItem {
...authored
edited
message
+ history {
+ message
+ date
+ }
}
diff --git a/webui/src/pages/bug/MessageEditHistory.graphql b/webui/src/pages/bug/MessageEditHistory.graphql
new file mode 100644
index 00000000..6fde8d45
--- /dev/null
+++ b/webui/src/pages/bug/MessageEditHistory.graphql
@@ -0,0 +1,15 @@
+#import "./MessageCommentFragment.graphql"
+#import "./MessageCreateFragment.graphql"
+
+query MessageEditHistory($bugIdPrefix: String!) {
+ repository {
+ bug(prefix: $bugIdPrefix) {
+ timeline {
+ comments: nodes {
+ ...Create
+ ...AddComment
+ }
+ }
+ }
+ }
+}