From b7ec2404b031257ea30f46d4d7f92a498ac906db Mon Sep 17 00:00:00 2001
From: Cláudio <claudio.engdist@gmail.com>
Date: Tue, 2 Feb 2021 20:27:48 -0300
Subject: Fix #546 - Fixing code review requests

---
 webui/src/components/CloseBugButton/CloseBugButton.tsx | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

(limited to 'webui/src/components/CloseBugButton/CloseBugButton.tsx')

diff --git a/webui/src/components/CloseBugButton/CloseBugButton.tsx b/webui/src/components/CloseBugButton/CloseBugButton.tsx
index 9aca6fdd..19f56cab 100644
--- a/webui/src/components/CloseBugButton/CloseBugButton.tsx
+++ b/webui/src/components/CloseBugButton/CloseBugButton.tsx
@@ -2,22 +2,24 @@ 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 {
-  bugId: string;
+  bug: BugFragment;
+  disabled: boolean;
 }
 
-function CloseBugButton({ bugId }: Props) {
+function CloseBugButton({ bug, disabled }: Props) {
   const [closeBug, { loading, error }] = useCloseBugMutation();
 
   function closeBugAction() {
     closeBug({
       variables: {
         input: {
-          prefix: bugId,
+          prefix: bug.id,
         },
       },
       refetchQueries: [
@@ -25,7 +27,7 @@ function CloseBugButton({ bugId }: Props) {
         {
           query: TimelineDocument,
           variables: {
-            id: bugId,
+            id: bug.id,
             first: 100,
           },
         },
@@ -39,7 +41,11 @@ function CloseBugButton({ bugId }: Props) {
 
   return (
     <div>
-      <Button variant="contained" onClick={() => closeBugAction()}>
+      <Button
+        variant="contained"
+        onClick={() => closeBugAction()}
+        disabled={bug.status === 'CLOSED' || disabled}
+      >
         Close issue
       </Button>
     </div>
-- 
cgit 

