From d9510bf694d12d0fd626616a8f010b98a37e11fd Mon Sep 17 00:00:00 2001 From: Devansh3712 Date: Sun, 13 Aug 2023 22:20:12 +0530 Subject: [PATCH] pages/Run/index.tsx: Add kill run button Signed-off-by: Devansh3712 --- src/pages/Run/index.tsx | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/pages/Run/index.tsx b/src/pages/Run/index.tsx index e608c1d..925f034 100644 --- a/src/pages/Run/index.tsx +++ b/src/pages/Run/index.tsx @@ -1,9 +1,14 @@ import { useQueryParams, StringParam, NumberParam } from "use-query-params"; import { styled, useTheme } from "@mui/material/styles"; import { useParams } from "react-router-dom"; +import { useState } from "react"; import Typography from "@mui/material/Typography"; import Button from "@mui/material/Button"; import ButtonGroup from "@mui/material/ButtonGroup"; +import Alert from "@mui/material/Alert"; +import Box from "@mui/material/Box"; +import CircularProgress from "@mui/material/CircularProgress"; +import Snackbar from "@mui/material/Snackbar"; import { format } from "date-fns"; import SourceBranch from "mdi-material-ui/SourceBranch"; import { Helmet } from "react-helmet"; @@ -35,6 +40,28 @@ export default function Run() { page: NumberParam, pageSize: NumberParam, }); + const [kill, setKill] = useState(false); + const [success, setSuccess] = useState(false); + const [error, setError] = useState(false); + const killRun = async () => { + setKill(true); + // Using a mock API endpoint for testing + const response = await fetch("https://reqres.in/api/users/2?delay=3"); + const status = response.status; + if (status === 200) setSuccess(true); + else setError(true); + setKill(false); + }; + const handleClose = ( + event?: React.SyntheticEvent | Event, + reason?: string + ) => { + if (reason === "clickaway") { + return; + } + setSuccess(false); + setError(false); + }; const { name } = useParams(); const query = useRun(name === undefined ? "" : name); if (query === null) return 404; @@ -70,6 +97,35 @@ export default function Run() { scheduled on {date} +
+ + {kill ? ( + + + + ) : null} +
+ + + Run killed successfully + + + + + Unable to kill run + +