diff --git a/webui/src/components/CloseBugWithCommentButton/CloseBugWithCommentButton.tsx b/webui/src/components/CloseBugWithCommentButton/CloseBugWithCommentButton.tsx
index 1d713f88272339bf4fb0fd0b1974a85ac0a97bae..a0fefa4acee6ee663ab32bacea45626525fb19cf 100644
--- a/webui/src/components/CloseBugWithCommentButton/CloseBugWithCommentButton.tsx
+++ b/webui/src/components/CloseBugWithCommentButton/CloseBugWithCommentButton.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import Button from '@material-ui/core/Button';
+import CircularProgress from '@material-ui/core/CircularProgress';
import { makeStyles, Theme } from '@material-ui/core/styles';
import ErrorOutlineIcon from '@material-ui/icons/ErrorOutline';
@@ -19,9 +20,10 @@ const useStyles = makeStyles((theme: Theme) => ({
interface Props {
bug: BugFragment;
comment: string;
+ postClick?: () => void;
}
-function CloseBugWithCommentButton({ bug, comment }: Props) {
+function CloseBugWithCommentButton({ bug, comment, postClick }: Props) {
const [
addCommentAndCloseBug,
{ loading, error },
@@ -47,10 +49,14 @@ function CloseBugWithCommentButton({ bug, comment }: Props) {
},
],
awaitRefetchQueries: true,
+ }).then(() => {
+ if (postClick) {
+ postClick();
+ }
});
}
- if (loading) return
Loading...
;
+ if (loading) return ;
if (error) return Error
;
return (
diff --git a/webui/src/components/ReopenBugButton/ReopenBugButton.tsx b/webui/src/components/ReopenBugButton/ReopenBugButton.tsx
index e3e792fc2e2bc50add8e1fb5c6380d1a1d2ac144..c9999ec15805278ab08502b1c75dff90e7967aa1 100644
--- a/webui/src/components/ReopenBugButton/ReopenBugButton.tsx
+++ b/webui/src/components/ReopenBugButton/ReopenBugButton.tsx
@@ -9,7 +9,7 @@ import { useOpenBugMutation } from './OpenBug.generated';
interface Props {
bug: BugFragment;
- disabled: boolean;
+ disabled?: boolean;
}
function ReopenBugButton({ bug, disabled }: Props) {
diff --git a/webui/src/components/ReopenBugWithCommentButton/ReopenBugWithComment.graphql b/webui/src/components/ReopenBugWithCommentButton/ReopenBugWithComment.graphql
new file mode 100644
index 0000000000000000000000000000000000000000..4c220208e06ae0a44c4a001ba683c8ce7bced5d3
--- /dev/null
+++ b/webui/src/components/ReopenBugWithCommentButton/ReopenBugWithComment.graphql
@@ -0,0 +1,11 @@
+mutation AddCommentAndReopenBug($input: AddCommentAndReopenBugInput!) {
+ addCommentAndReopen(input: $input) {
+ statusOperation {
+ status
+ }
+ commentOperation {
+ message
+ }
+ }
+}
+
diff --git a/webui/src/components/ReopenBugWithCommentButton/ReopenBugWithCommentButton.tsx b/webui/src/components/ReopenBugWithCommentButton/ReopenBugWithCommentButton.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..0a534f27f0ecb381400c7195969848516a92ca09
--- /dev/null
+++ b/webui/src/components/ReopenBugWithCommentButton/ReopenBugWithCommentButton.tsx
@@ -0,0 +1,65 @@
+import React from 'react';
+
+import Button from '@material-ui/core/Button';
+import CircularProgress from '@material-ui/core/CircularProgress';
+
+import { BugFragment } from 'src/pages/bug/Bug.generated';
+import { TimelineDocument } from 'src/pages/bug/TimelineQuery.generated';
+
+import { useAddCommentAndReopenBugMutation } from './ReopenBugWithComment.generated';
+
+interface Props {
+ bug: BugFragment;
+ comment: string;
+ postClick?: () => void;
+}
+
+function ReopenBugWithCommentButton({ bug, comment, postClick }: Props) {
+ const [
+ addCommentAndReopenBug,
+ { loading, error },
+ ] = useAddCommentAndReopenBugMutation();
+
+ function addCommentAndReopenBugAction() {
+ addCommentAndReopenBug({
+ variables: {
+ input: {
+ prefix: bug.id,
+ message: comment,
+ },
+ },
+ refetchQueries: [
+ // TODO: update the cache instead of refetching
+ {
+ query: TimelineDocument,
+ variables: {
+ id: bug.id,
+ first: 100,
+ },
+ },
+ ],
+ awaitRefetchQueries: true,
+ }).then(() => {
+ if (postClick) {
+ postClick();
+ }
+ });
+ }
+
+ if (loading) return ;
+ if (error) return Error
;
+
+ return (
+
+
+
+ );
+}
+
+export default ReopenBugWithCommentButton;
diff --git a/webui/src/pages/bug/CommentForm.tsx b/webui/src/pages/bug/CommentForm.tsx
index 1a7ebc291a25ecabec29f1e7ab47c2eb80a3e55f..395b955dcab24559c2acaf42cd9ab7b30f8dfb2d 100644
--- a/webui/src/pages/bug/CommentForm.tsx
+++ b/webui/src/pages/bug/CommentForm.tsx
@@ -8,6 +8,7 @@ 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 ReopenBugWithCommentButton from 'src/components/ReopenBugWithCommentButton/ReopenBugWithCommentButton';
import { BugFragment } from './Bug.generated';
import { useAddCommentMutation } from './CommentForm.generated';
@@ -80,12 +81,27 @@ function CommentForm({ bug }: Props) {
function getBugStatusButton() {
if (bug.status === 'OPEN' && issueComment.length > 0) {
- return ;
+ return (
+
+ );
}
if (bug.status === 'OPEN') {
return ;
}
- return 0} />;
+ if (bug.status === 'CLOSED' && issueComment.length > 0) {
+ return (
+
+ );
+ }
+ return ;
}
return (