Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new handle when the backend application is offline (#1550)
✨ (App.tsx): Import the `useNavigate` hook from `react-router-dom` to enable programmatic navigation within the app. 📝 (App.tsx): Add comments to explain the purpose of the `isLoadingHealth` state variable and the `checkApplicationHealth` function. 📝 (App.tsx): Add comments to explain the purpose of the `onHealthCheck` function. 🐛 (App.tsx): Fix a bug where the `checkApplicationHealth` function was not being called when the component mounts. 🐛 (App.tsx): Fix a bug where the `onHealthCheck` function was not being called when the health check was successful. 📝 (App.tsx): Add comments to explain the purpose of the `checkApplicationHealth` function and the `onHealthCheck` function. ✨ (fetchErrorComponent/index.tsx): Import the `BaseModal` component from the `modals/baseModal` module to display the fetch error component in a modal. ✨ (fetchErrorComponent/index.tsx): Import the `Button` component from the `ui/button` module to display a retry button in the fetch error component. ✨ (fetchErrorComponent/index.tsx): Add a retry button to the fetch error component to allow the user to retry the failed request. ✨ (ui/dialog-with-no-close.tsx): Create a new file `ui/dialog-with-no-close.tsx` to define a custom dialog component without a close button. ✨ (ui/dialog-with-no-close.tsx): Define the `Dialog`, `DialogTrigger`, `DialogPortal`, `DialogOverlay`, `DialogContent`, `DialogHeader`, `DialogFooter`, `DialogTitle`, and `DialogDescription` components for the custom dialog component. 📝 (baseModal/index.tsx): add support for a new type prop to switch between modal and dialog mode 🐛 (baseModal/index.tsx): fix typo in import statement for Modal and ModalContent components ♻️ (baseModal/index.tsx): refactor BaseModal component to conditionally render either Modal or Dialog based on the type prop 🐛 (flowsManagerStore.ts): fix issue where isLoading state was not being set to false after catching an error 🐛 (typesStore.ts): fix issue where error alert was not being shown when fetching types failed 🐛 (typesStore.ts): remove unnecessary error alert when fetching types failed ✨ (components/index.ts): add new properties to fetchErrorComponentType to support opening a modal, retrying, and showing loading state
- Loading branch information
1 parent
fd7a0fc
commit 496c2aa
Showing
7 changed files
with
262 additions
and
41 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
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 |
---|---|---|
@@ -1,16 +1,51 @@ | ||
import BaseModal from "../../modals/baseModal"; | ||
import { fetchErrorComponentType } from "../../types/components"; | ||
import IconComponent from "../genericIconComponent"; | ||
import { Button } from "../ui/button"; | ||
|
||
export default function FetchErrorComponent({ | ||
message, | ||
description, | ||
openModal, | ||
setRetry, | ||
isLoadingHealth, | ||
}: fetchErrorComponentType) { | ||
return ( | ||
<div role="status" className="m-auto flex flex-col items-center"> | ||
<IconComponent className={`h-16 w-16`} name="Unplug"></IconComponent> | ||
<br></br> | ||
<span className="text-lg text-almost-medium-blue">{message}</span> | ||
<span className="text-lg text-almost-medium-blue">{description}</span> | ||
</div> | ||
<> | ||
<BaseModal size="small-h-full" open={openModal} type="modal"> | ||
<BaseModal.Content> | ||
<div role="status" className="m-auto flex flex-col items-center"> | ||
<IconComponent | ||
className={`h-16 w-16`} | ||
name="Unplug" | ||
></IconComponent> | ||
<br></br> | ||
<span className="text-lg text-almost-medium-blue">{message}</span> | ||
<span className="text-lg text-almost-medium-blue"> | ||
{description} | ||
</span> | ||
</div> | ||
</BaseModal.Content> | ||
|
||
<BaseModal.Footer> | ||
<div className="m-auto"> | ||
<Button | ||
disabled={isLoadingHealth} | ||
onClick={() => { | ||
setRetry(); | ||
}} | ||
> | ||
{isLoadingHealth ? ( | ||
<div> | ||
<IconComponent name={"Loader2"} className={"animate-spin"} /> | ||
</div> | ||
) : ( | ||
"Retry" | ||
)} | ||
</Button> | ||
</div> | ||
</BaseModal.Footer> | ||
</BaseModal> | ||
</> | ||
); | ||
} |
119 changes: 119 additions & 0 deletions
119
src/frontend/src/components/ui/dialog-with-no-close.tsx
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,119 @@ | ||
import * as DialogPrimitive from "@radix-ui/react-dialog"; | ||
import * as React from "react"; | ||
import { cn } from "../../utils/utils"; | ||
|
||
const Dialog = DialogPrimitive.Root; | ||
|
||
const DialogTrigger = DialogPrimitive.Trigger; | ||
|
||
const DialogPortal = ({ | ||
children, | ||
...props | ||
}: DialogPrimitive.DialogPortalProps) => ( | ||
<DialogPrimitive.Portal {...props}> | ||
<div className="nopan nodelete nodrag noundo nocopy fixed inset-0 z-50 flex items-start justify-center sm:items-center"> | ||
{children} | ||
</div> | ||
</DialogPrimitive.Portal> | ||
); | ||
DialogPortal.displayName = DialogPrimitive.Portal.displayName; | ||
|
||
const DialogOverlay = React.forwardRef< | ||
React.ElementRef<typeof DialogPrimitive.Overlay>, | ||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> | ||
>(({ className, ...props }, ref) => ( | ||
<DialogPrimitive.Overlay | ||
ref={ref} | ||
className={cn( | ||
"nopan nodelete nodrag noundo nocopy fixed inset-0 bottom-0 left-0 right-0 top-0 z-50 overflow-auto bg-blur-shared backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; | ||
|
||
const DialogContent = React.forwardRef< | ||
React.ElementRef<typeof DialogPrimitive.Content>, | ||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> | ||
>(({ className, children, ...props }, ref) => ( | ||
<DialogPortal> | ||
<DialogOverlay /> | ||
<DialogPrimitive.Content | ||
ref={ref} | ||
className={cn( | ||
"fixed z-50 flex w-full max-w-lg flex-col gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] sm:rounded-lg md:w-full", | ||
className | ||
)} | ||
{...props} | ||
> | ||
{children} | ||
</DialogPrimitive.Content> | ||
</DialogPortal> | ||
)); | ||
DialogContent.displayName = DialogPrimitive.Content.displayName; | ||
|
||
const DialogHeader = ({ | ||
className, | ||
...props | ||
}: React.HTMLAttributes<HTMLDivElement>) => ( | ||
<div | ||
className={cn( | ||
"flex flex-col space-y-1.5 text-center sm:text-left", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
); | ||
DialogHeader.displayName = "DialogHeader"; | ||
|
||
const DialogFooter = ({ | ||
className, | ||
...props | ||
}: React.HTMLAttributes<HTMLDivElement>) => ( | ||
<div | ||
className={cn( | ||
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
); | ||
DialogFooter.displayName = "DialogFooter"; | ||
|
||
const DialogTitle = React.forwardRef< | ||
React.ElementRef<typeof DialogPrimitive.Title>, | ||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title> | ||
>(({ className, ...props }, ref) => ( | ||
<DialogPrimitive.Title | ||
ref={ref} | ||
className={cn( | ||
"text-lg font-semibold leading-none tracking-tight", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
DialogTitle.displayName = DialogPrimitive.Title.displayName; | ||
|
||
const DialogDescription = React.forwardRef< | ||
React.ElementRef<typeof DialogPrimitive.Description>, | ||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description> | ||
>(({ className, ...props }, ref) => ( | ||
<DialogPrimitive.Description | ||
ref={ref} | ||
className={cn("text-sm text-muted-foreground", className)} | ||
{...props} | ||
/> | ||
)); | ||
DialogDescription.displayName = DialogPrimitive.Description.displayName; | ||
|
||
export { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogFooter, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
}; |
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
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
Oops, something went wrong.