aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/pages/bug/Message.tsx
diff options
context:
space:
mode:
authorSascha <GlancingMind@outlook.com>2021-03-19 11:21:18 +0100
committerSascha <GlancingMind@outlook.com>2021-03-19 17:53:00 +0100
commitd453abdeedcac5b7593f72d63a5641f9a3e99da0 (patch)
tree6301a63f72ec81e6f29e20847570acc91d2e4f25 /webui/src/pages/bug/Message.tsx
parentdefd1ae00cccce0b46207e03084fe6af32096610 (diff)
downloadgit-bug-d453abdeedcac5b7593f72d63a5641f9a3e99da0.tar.gz
Move toggle button out of history menu
Diffstat (limited to 'webui/src/pages/bug/Message.tsx')
-rw-r--r--webui/src/pages/bug/Message.tsx54
1 files changed, 47 insertions, 7 deletions
diff --git a/webui/src/pages/bug/Message.tsx b/webui/src/pages/bug/Message.tsx
index b117c103..bf3fb6da 100644
--- a/webui/src/pages/bug/Message.tsx
+++ b/webui/src/pages/bug/Message.tsx
@@ -5,6 +5,7 @@ import Paper from '@material-ui/core/Paper';
import Tooltip from '@material-ui/core/Tooltip/Tooltip';
import { makeStyles } from '@material-ui/core/styles';
import EditIcon from '@material-ui/icons/Edit';
+import HistoryIcon from '@material-ui/icons/History';
import Author, { Avatar } from 'src/components/Author';
import Content from 'src/components/Content';
@@ -58,7 +59,6 @@ const useStyles = makeStyles((theme) => ({
...theme.typography.body2,
padding: '0.5rem',
},
- headerActions2: {},
headerActions: {
color: theme.palette.info.contrastText,
padding: '0rem',
@@ -70,11 +70,55 @@ const useStyles = makeStyles((theme) => ({
},
}));
+//TODO move button out of this component and let only menu as component with
+//query. Then the query won't execute unless button click renders menu with
+//query.
+//TODO Fix display of load button spinner.
+//TODO Move this button and menu in separate component directory
+//TODO fix failing pipeline due to eslint error
+type HistBtnProps = {
+ bugId: string;
+ commentId: string;
+};
+function HistoryMenuToggleButton({ bugId, commentId }: HistBtnProps) {
+ const classes = useStyles();
+ const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
+
+ const handleClick = (event: React.MouseEvent<HTMLElement>) => {
+ setAnchorEl(event.currentTarget);
+ };
+
+ const handleClose = () => {
+ setAnchorEl(null);
+ };
+
+ return (
+ <div>
+ <IconButton
+ aria-label="more"
+ aria-controls="long-menu"
+ aria-haspopup="true"
+ onClick={handleClick}
+ className={classes.headerActions}
+ >
+ <HistoryIcon />
+ </IconButton>
+ {anchorEl && (
+ <EditHistoryMenu
+ bugId={bugId}
+ commentId={commentId}
+ anchor={anchorEl}
+ onClose={handleClose}
+ />
+ )}
+ </div>
+ );
+}
+
type Props = {
bug: BugFragment;
op: AddCommentFragment | CreateFragment;
};
-
function Message({ bug, op }: Props) {
const classes = useStyles();
const [editMode, switchToEditMode] = useState(false);
@@ -94,11 +138,7 @@ function Message({ bug, op }: Props) {
<Date date={comment.createdAt} />
</div>
{comment.edited && (
- <EditHistoryMenu
- iconBtnProps={{ className: classes.headerActions }}
- bugId={bug.id}
- commentId={comment.id}
- />
+ <HistoryMenuToggleButton bugId={bug.id} commentId={comment.id} />
)}
<IfLoggedIn>
{() => (