-
Notifications
You must be signed in to change notification settings - Fork 59
chore(DATAGO-115917): migrate enterprise reusable components #469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
g-raman
merged 13 commits into
main
from
raman/ai-115916/migrate-enterprise-reusable-components
Nov 10, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
316e6d8
refactor: move button variant type to shared util file
g-raman a0570ce
chore: add confirmation dialog from enterprise
g-raman 1c8a476
chore: add error dialog component from enterprise
g-raman e2406f4
chore: add loading blocker component from enterprise
g-raman 105cb26
chore: add more popover button from enterprise
g-raman a16c4ef
chore: add pagination controls from enterprise
g-raman 79a5935
fix: update export file
g-raman f18363c
cleanup: remove unnecessary components
g-raman 59557b1
fix: enhance confirmation dialog
g-raman 3099dbf
fix: enhance error dialog
g-raman 570b389
fix: add error dialog story
g-raman 7bb9d05
fix: add confirmation dialog stories
g-raman b282f6c
fix: use dialog footer and dialog close for error dialog
g-raman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
client/webui/frontend/src/lib/components/common/ConfirmationDialog.tsx
This file contains hidden or 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,61 @@ | ||
| import { Button } from "@/lib/components/ui/button"; | ||
| import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/lib/components/ui/dialog"; | ||
| import { DialogClose } from "@radix-ui/react-dialog"; | ||
|
|
||
| interface BaseDialogProps { | ||
| title: string; | ||
| message: string | React.ReactNode; | ||
| onConfirm: () => void; | ||
| onClose: () => void; | ||
| } | ||
|
|
||
| type ConfirmationDialogProps = | ||
| | (BaseDialogProps & { | ||
| triggerText: string; | ||
| trigger?: never; | ||
| }) | ||
| | (BaseDialogProps & { | ||
| trigger: React.ReactNode; | ||
| triggerText?: never; | ||
| }); | ||
|
|
||
| export const ConfirmationDialog: React.FC<ConfirmationDialogProps> = ({ title, message, triggerText, trigger, onClose, onConfirm }) => { | ||
| return ( | ||
| <Dialog> | ||
| <DialogTrigger asChild>{trigger ?? <Button>{triggerText}</Button>}</DialogTrigger> | ||
| <DialogContent className="w-xl max-w-xl sm:max-w-xl"> | ||
| <DialogHeader> | ||
| <DialogTitle className="flex max-w-[400px] flex-row gap-1">{title}</DialogTitle> | ||
| <DialogDescription>{message}</DialogDescription> | ||
| </DialogHeader> | ||
|
|
||
| <DialogFooter> | ||
| <DialogClose asChild> | ||
| <Button | ||
| variant="ghost" | ||
| title="Cancel" | ||
| onClick={event => { | ||
| event.stopPropagation(); | ||
| onClose(); | ||
| }} | ||
| > | ||
| Cancel | ||
| </Button> | ||
| </DialogClose> | ||
|
|
||
| <DialogClose> | ||
| <Button | ||
| title="Confirm" | ||
| onClick={event => { | ||
| event.stopPropagation(); | ||
| onConfirm(); | ||
| }} | ||
| > | ||
| Confirm | ||
| </Button> | ||
| </DialogClose> | ||
| </DialogFooter> | ||
| </DialogContent> | ||
| </Dialog> | ||
| ); | ||
| }; |
5 changes: 1 addition & 4 deletions
5
client/webui/frontend/src/lib/components/common/EmptyState.tsx
This file contains hidden or 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
36 changes: 36 additions & 0 deletions
36
client/webui/frontend/src/lib/components/common/ErrorDialog.tsx
This file contains hidden or 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,36 @@ | ||
| import { Button } from "@/lib/components/ui/button"; | ||
| import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/lib/components/ui/dialog"; | ||
| import { CircleX } from "lucide-react"; | ||
|
|
||
| interface ErrorDialogProps { | ||
| title: string; | ||
| error: string; | ||
| errorDetails?: string; | ||
| onClose: () => void; | ||
| } | ||
|
|
||
| export const ErrorDialog: React.FC<ErrorDialogProps> = ({ title, error, errorDetails, onClose }) => { | ||
| return ( | ||
| <Dialog defaultOpen={true}> | ||
| <DialogContent className="w-xl max-w-xl sm:max-w-xl"> | ||
| <DialogHeader> | ||
| <DialogTitle className="flex max-w-[400px] flex-row gap-1">{title}</DialogTitle> | ||
| </DialogHeader> | ||
|
|
||
| <div className="flex flex-row items-center gap-2"> | ||
| <CircleX className="h-6 w-6 flex-shrink-0 self-start text-[var(--color-error-wMain)]" /> | ||
| <div>{error}</div> | ||
| </div> | ||
| {errorDetails && <div className="text-[var(--color-secondary-text-wMain)]">{errorDetails}</div>} | ||
|
|
||
| <DialogFooter> | ||
| <DialogClose asChild> | ||
| <Button variant="outline" testid="closeButton" type="button" title="Close" onClick={onClose}> | ||
| Close | ||
| </Button> | ||
| </DialogClose> | ||
| </DialogFooter> | ||
| </DialogContent> | ||
| </Dialog> | ||
| ); | ||
| }; | ||
19 changes: 19 additions & 0 deletions
19
client/webui/frontend/src/lib/components/common/LoadingBlocker.tsx
This file contains hidden or 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,19 @@ | ||
| import { Loader2 } from "lucide-react"; | ||
|
|
||
| interface LoadingBlockerProps { | ||
| isLoading: boolean; | ||
| message?: string; | ||
| } | ||
|
|
||
| export const LoadingBlocker: React.FC<LoadingBlockerProps> = ({ isLoading, message }) => { | ||
| if (!isLoading) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <div className="fixed inset-0 z-50 flex flex-col items-center justify-center bg-black/50"> | ||
| <Loader2 className="size-8 animate-spin text-[var(--color-brand-wMain)]" /> | ||
| {message && <p className="text-muted-foreground mt-4 text-sm">{message}</p>} | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or 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,4 +1,7 @@ | ||
| export { ConfirmationDialog } from "./ConfirmationDialog"; | ||
| export { EmptyState } from "./EmptyState"; | ||
| export { ErrorDialog } from "./ErrorDialog"; | ||
| export { LoadingBlocker } from "./LoadingBlocker"; | ||
| export { MarkdownHTMLConverter } from "./MarkdownHTMLConverter"; | ||
| export { MessageBanner } from "./MessageBanner"; | ||
| export { EmptyState } from "./EmptyState"; | ||
| export * from "./messageColourVariants"; |
This file contains hidden or 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,4 @@ | ||
| import type { VariantProps } from "class-variance-authority"; | ||
| import type { buttonVariants } from "@/lib/components/ui/button"; | ||
|
|
||
| export type ButtonVariant = VariantProps<typeof buttonVariants>["variant"]; |
45 changes: 45 additions & 0 deletions
45
client/webui/frontend/src/stories/ConfirmationDialog.stories.tsx
This file contains hidden or 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,45 @@ | ||
| import { Button, ConfirmationDialog } from "@/lib"; | ||
| import type { Meta, StoryContext, StoryFn, StoryObj } from "@storybook/react-vite"; | ||
|
|
||
| const meta = { | ||
| title: "Common/ConfirmationDialog", | ||
| component: ConfirmationDialog, | ||
| parameters: { | ||
| layout: "fullscreen", | ||
| docs: { | ||
| description: { | ||
| component: "The button component", | ||
| }, | ||
| }, | ||
| }, | ||
| decorators: [ | ||
| (Story: StoryFn, context: StoryContext) => { | ||
| const storyResult = Story(context.args, context); | ||
|
|
||
| return <div style={{ height: "100vh", width: "100vw", display: "flex", justifyContent: "center", alignItems: "center" }}>{storyResult}</div>; | ||
| }, | ||
| ], | ||
| } satisfies Meta<typeof ConfirmationDialog>; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Default: Story = { | ||
| args: { | ||
| title: "Confirm", | ||
| triggerText: "Open Dialog", | ||
| message: "Are you sure you want to do this action", | ||
| onClose: () => alert("Action cancelled"), | ||
| onConfirm: () => alert("Action confirmed"), | ||
| }, | ||
| }; | ||
|
|
||
| export const CustomTrigger: Story = { | ||
| args: { | ||
| title: "Confirm", | ||
| trigger: <Button variant="outline"> Custom trigger</Button>, | ||
| message: "Are you sure you want to do this action", | ||
| onClose: () => alert("Action cancelled"), | ||
| onConfirm: () => alert("Action confirmed"), | ||
| }, | ||
| }; |
This file contains hidden or 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,42 @@ | ||
| import { ErrorDialog } from "@/lib"; | ||
| import type { Meta, StoryContext, StoryFn, StoryObj } from "@storybook/react-vite"; | ||
|
|
||
| const meta = { | ||
| title: "Common/ErrorDialog", | ||
| component: ErrorDialog, | ||
| parameters: { | ||
| layout: "fullscreen", | ||
| docs: { | ||
| description: { | ||
| component: "The button component", | ||
| }, | ||
| }, | ||
| }, | ||
| decorators: [ | ||
| (Story: StoryFn, context: StoryContext) => { | ||
| const storyResult = Story(context.args, context); | ||
|
|
||
| return <div style={{ height: "100vh", width: "100vw", display: "flex", justifyContent: "center", alignItems: "center" }}>{storyResult}</div>; | ||
| }, | ||
| ], | ||
| } satisfies Meta<typeof ErrorDialog>; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Default: Story = { | ||
| args: { | ||
| title: "Error", | ||
| error: "Something went wrong", | ||
| onClose: () => alert("Action cancelled"), | ||
| }, | ||
| }; | ||
|
|
||
| export const WithErrorDetails = { | ||
| args: { | ||
| title: "Error", | ||
| error: "Something went wrong", | ||
| errorDetails: "This action is forbidden. Ensure you have the right authorization.", | ||
| onClose: () => alert("Action cancelled"), | ||
| }, | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto for this component, feel free to improve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i didn't use a dialog trigger and left it open by default because i assume you wouldn't click into an error dialog