diff --git a/webui/src/components/CloseBugButton/CloseBug.graphql b/webui/src/components/CloseBugButton/CloseBug.graphql new file mode 100644 index 0000000000000000000000000000000000000000..e2f4bff2e221c4f0875fc4c8a12f8380ed8d66aa --- /dev/null +++ b/webui/src/components/CloseBugButton/CloseBug.graphql @@ -0,0 +1,8 @@ +# Write your query or mutation here +mutation closeBug($input: CloseBugInput!) { + closeBug(input: $input) { + bug { + id + } + } +} \ No newline at end of file diff --git a/webui/src/components/CloseBugButton/CloseBugButton.tsx b/webui/src/components/CloseBugButton/CloseBugButton.tsx new file mode 100644 index 0000000000000000000000000000000000000000..19f56cab6c9df8a57b66ff85c73489a09bd1c3a9 --- /dev/null +++ b/webui/src/components/CloseBugButton/CloseBugButton.tsx @@ -0,0 +1,55 @@ +import React from 'react'; + +import Button from '@material-ui/core/Button'; + +import { BugFragment } from 'src/pages/bug/Bug.generated'; +import { TimelineDocument } from 'src/pages/bug/TimelineQuery.generated'; + +import { useCloseBugMutation } from './CloseBug.generated'; + +interface Props { + bug: BugFragment; + disabled: boolean; +} + +function CloseBugButton({ bug, disabled }: Props) { + const [closeBug, { loading, error }] = useCloseBugMutation(); + + function closeBugAction() { + closeBug({ + variables: { + input: { + prefix: bug.id, + }, + }, + refetchQueries: [ + // TODO: update the cache instead of refetching + { + query: TimelineDocument, + variables: { + id: bug.id, + first: 100, + }, + }, + ], + awaitRefetchQueries: true, + }); + } + + if (loading) return
Loading...
; + if (error) return
Error
; + + return ( +
+ +
+ ); +} + +export default CloseBugButton; diff --git a/webui/src/layout/CommentInput/CommentInput.tsx b/webui/src/layout/CommentInput/CommentInput.tsx index 8a91baf6ddfba239855b4cd42ff0bc1cc87089b7..86cc7dbbdf8fa885668c4b3e7f6ef25510fd7e09 100644 --- a/webui/src/layout/CommentInput/CommentInput.tsx +++ b/webui/src/layout/CommentInput/CommentInput.tsx @@ -23,10 +23,6 @@ const useStyles = makeStyles((theme) => ({ borderBottom: `solid 3px ${theme.palette.grey['200']}`, minHeight: '5rem', }, - actions: { - display: 'flex', - justifyContent: 'flex-end', - }, })); type TabPanelProps = { diff --git a/webui/src/pages/bug/Bug.tsx b/webui/src/pages/bug/Bug.tsx index f2a116f863fcf6d3603d11e00686d39558d425b0..bd6e44c41fa0fa1e6c06bda2fcd5db5f9362379f 100644 --- a/webui/src/pages/bug/Bug.tsx +++ b/webui/src/pages/bug/Bug.tsx @@ -82,7 +82,7 @@ function Bug({ bug }: Props) { {() => (
- +
)}
diff --git a/webui/src/pages/bug/CommentForm.tsx b/webui/src/pages/bug/CommentForm.tsx index c39f30c22dbfd30833912423d3842043cd8bc0a4..128e4d3245901773c69904fbf9e1eee854a4cc52 100644 --- a/webui/src/pages/bug/CommentForm.tsx +++ b/webui/src/pages/bug/CommentForm.tsx @@ -5,7 +5,9 @@ import Paper from '@material-ui/core/Paper'; import { makeStyles, Theme } from '@material-ui/core/styles'; import CommentInput from '../../layout/CommentInput/CommentInput'; +import CloseBugButton from 'src/components/CloseBugButton/CloseBugButton'; +import { BugFragment } from './Bug.generated'; import { useAddCommentMutation } from './CommentForm.generated'; import { TimelineDocument } from './TimelineQuery.generated'; @@ -28,6 +30,7 @@ const useStyles = makeStyles((theme) => ({ justifyContent: 'flex-end', }, greenButton: { + marginLeft: '8px', backgroundColor: '#2ea44fd9', color: '#fff', '&:hover': { @@ -37,10 +40,10 @@ const useStyles = makeStyles((theme) => ({ })); type Props = { - bugId: string; + bug: BugFragment; }; -function CommentForm({ bugId }: Props) { +function CommentForm({ bug }: Props) { const [addComment, { loading }] = useAddCommentMutation(); const [issueComment, setIssueComment] = useState(''); const [inputProp, setInputProp] = useState(''); @@ -51,7 +54,7 @@ function CommentForm({ bugId }: Props) { addComment({ variables: { input: { - prefix: bugId, + prefix: bug.id, message: issueComment, }, }, @@ -60,7 +63,7 @@ function CommentForm({ bugId }: Props) { { query: TimelineDocument, variables: { - id: bugId, + id: bug.id, first: 100, }, }, @@ -89,6 +92,7 @@ function CommentForm({ bugId }: Props) { onChange={(comment: string) => setIssueComment(comment)} />
+ 0} />