diff options
Diffstat (limited to 'webui/src/pages/bug/CommentForm.tsx')
-rw-r--r-- | webui/src/pages/bug/CommentForm.tsx | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/webui/src/pages/bug/CommentForm.tsx b/webui/src/pages/bug/CommentForm.tsx index a8ce4319..6d917889 100644 --- a/webui/src/pages/bug/CommentForm.tsx +++ b/webui/src/pages/bug/CommentForm.tsx @@ -5,8 +5,10 @@ import Paper from '@material-ui/core/Paper'; import { makeStyles, Theme } from '@material-ui/core/styles'; import CommentInput from '../../components/CommentInput/CommentInput'; -import CloseBugButton from 'src/components/CloseBugButton/CloseBugButton'; -import ReopenBugButton from 'src/components/ReopenBugButton/ReopenBugButton'; +import CloseBugButton from 'src/components/CloseBugButton'; +import CloseBugWithCommentButton from 'src/components/CloseBugWithCommentButton'; +import ReopenBugButton from 'src/components/ReopenBugButton'; +import ReopenBugWithCommentButton from 'src/components/ReopenBugWithCommentButton'; import { BugFragment } from './Bug.generated'; import { useAddCommentMutation } from './CommentForm.generated'; @@ -77,12 +79,29 @@ function CommentForm({ bug }: Props) { if (issueComment.length > 0) submit(); }; - function getCloseButton() { - return <CloseBugButton bug={bug} disabled={issueComment.length > 0} />; - } - - function getReopenButton() { - return <ReopenBugButton bug={bug} disabled={issueComment.length > 0} />; + function getBugStatusButton() { + if (bug.status === 'OPEN' && issueComment.length > 0) { + return ( + <CloseBugWithCommentButton + bug={bug} + comment={issueComment} + postClick={resetForm} + /> + ); + } + if (bug.status === 'OPEN') { + return <CloseBugButton bug={bug} />; + } + if (bug.status === 'CLOSED' && issueComment.length > 0) { + return ( + <ReopenBugWithCommentButton + bug={bug} + comment={issueComment} + postClick={resetForm} + /> + ); + } + return <ReopenBugButton bug={bug} />; } return ( @@ -94,7 +113,7 @@ function CommentForm({ bug }: Props) { onChange={(comment: string) => setIssueComment(comment)} /> <div className={classes.actions}> - {bug.status === 'OPEN' ? getCloseButton() : getReopenButton()} + {getBugStatusButton()} <Button className={classes.greenButton} variant="contained" |