-
-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create mutation to clear request logs * Add UI for clearing all HTTP request logs * Use consistent naming * Explicitly delete only from http_requests * Check if datebase is open * Add confirmation dialog
- Loading branch information
1 parent
efc115e
commit e59b9d6
Showing
12 changed files
with
383 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React, { useState } from "react"; | ||
import Button from "@material-ui/core/Button"; | ||
import Dialog from "@material-ui/core/Dialog"; | ||
import DialogActions from "@material-ui/core/DialogActions"; | ||
import DialogContent from "@material-ui/core/DialogContent"; | ||
import DialogContentText from "@material-ui/core/DialogContentText"; | ||
import DialogTitle from "@material-ui/core/DialogTitle"; | ||
|
||
export function useConfirmationDialog() { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const close = () => setIsOpen(false); | ||
const open = () => setIsOpen(true); | ||
|
||
return { open, close, isOpen }; | ||
} | ||
|
||
interface ConfirmationDialog { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
onConfirm: () => void; | ||
children: React.ReactNode; | ||
} | ||
|
||
export function ConfirmationDialog(props: ConfirmationDialog) { | ||
const { onClose, onConfirm, isOpen, children } = props; | ||
|
||
function confirm() { | ||
onConfirm(); | ||
onClose(); | ||
} | ||
|
||
return ( | ||
<Dialog | ||
open={isOpen} | ||
onClose={onClose} | ||
aria-labelledby="alert-dialog-title" | ||
aria-describedby="alert-dialog-description" | ||
> | ||
<DialogTitle id="alert-dialog-title">Are you sure?</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText id="alert-dialog-description"> | ||
{children} | ||
</DialogContentText> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={onClose}>Abort</Button> | ||
<Button onClick={confirm} autoFocus> | ||
Confirm | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
admin/src/components/reqlog/hooks/useClearHTTPRequestLog.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { gql, useMutation } from "@apollo/client"; | ||
import { HTTP_REQUEST_LOGS } from "./useHttpRequestLogs"; | ||
|
||
const CLEAR_HTTP_REQUEST_LOG = gql` | ||
mutation ClearHTTPRequestLog { | ||
clearHTTPRequestLog { | ||
success | ||
} | ||
} | ||
`; | ||
|
||
export function useClearHTTPRequestLog() { | ||
return useMutation(CLEAR_HTTP_REQUEST_LOG, { | ||
refetchQueries: [{ query: HTTP_REQUEST_LOGS }], | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { gql, useQuery } from "@apollo/client"; | ||
|
||
export const HTTP_REQUEST_LOGS = gql` | ||
query HttpRequestLogs { | ||
httpRequestLogs { | ||
id | ||
method | ||
url | ||
timestamp | ||
response { | ||
statusCode | ||
statusReason | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export function useHttpRequestLogs() { | ||
return useQuery(HTTP_REQUEST_LOGS, { | ||
pollInterval: 1000, | ||
}); | ||
} |
Oops, something went wrong.