From 098bcd0c1f26d0896e7ede3edb4040b01bc3126a Mon Sep 17 00:00:00 2001 From: Sascha Date: Tue, 25 May 2021 14:07:27 +0200 Subject: WebUI: Add comment-and-close of a bug in one step When a user has some text entered in the comment field, the close bug button will change to "Close bug with comment". This way the user does not have to comment and close a bug in two separate steps. --- webui/src/pages/bug/CommentForm.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'webui/src/pages') diff --git a/webui/src/pages/bug/CommentForm.tsx b/webui/src/pages/bug/CommentForm.tsx index a8ce4319..fb33a8be 100644 --- a/webui/src/pages/bug/CommentForm.tsx +++ b/webui/src/pages/bug/CommentForm.tsx @@ -6,6 +6,7 @@ import { makeStyles, Theme } from '@material-ui/core/styles'; import CommentInput from '../../components/CommentInput/CommentInput'; import CloseBugButton from 'src/components/CloseBugButton/CloseBugButton'; +import CloseBugWithCommentButton from 'src/components/CloseBugWithCommentButton/CloseBugWithCommentButton'; import ReopenBugButton from 'src/components/ReopenBugButton/ReopenBugButton'; import { BugFragment } from './Bug.generated'; @@ -77,12 +78,14 @@ function CommentForm({ bug }: Props) { if (issueComment.length > 0) submit(); }; - function getCloseButton() { - return 0} />; - } - - function getReopenButton() { - return 0} />; + function getBugStatusButton() { + if (bug.status === 'OPEN' && issueComment.length > 0) { + return ; + } else if (bug.status === 'OPEN') { + return ; + } else { + return 0} />; + } } return ( @@ -94,7 +97,7 @@ function CommentForm({ bug }: Props) { onChange={(comment: string) => setIssueComment(comment)} />
- {bug.status === 'OPEN' ? getCloseButton() : getReopenButton()} + {getBugStatusButton()}