Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,497 changes: 3,426 additions & 2,071 deletions pipeline-ui/package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion pipeline-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"generate:clean-client-code": "npm run generate:clean && npm run generate:client-code"
},
"dependencies": {
"@radix-ui/react-dialog": "^1.3.1",
"@radix-ui/react-navigation-menu": "^1.2.14",
"@radix-ui/react-slot": "^1.2.4",
"@react-keycloak/web": "^3.4.0",
Expand All @@ -33,7 +34,8 @@
"react-dom": "^19.2.0",
"react-router-dom": "^7.13.1",
"tailwind-merge": "^3.5.0",
"tailwindcss-animate": "^1.0.7"
"tailwindcss-animate": "^1.0.7",
"zustand": "^5.1.0"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
Expand Down
3 changes: 3 additions & 0 deletions pipeline-ui/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { RouterProvider } from "react-router-dom";
import { router } from "./router/router";
import { AuthProvider } from "./auth/authContext";
import ErrorDialog from "./components/common/errorDialogComponent";

function App() {

return (
<AuthProvider>
<RouterProvider router={router} />
<ErrorDialog />
</AuthProvider>
);
}
Expand Down
53 changes: 53 additions & 0 deletions pipeline-ui/src/components/common/errorDialogComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { AlertCircle } from "lucide-react";
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogDescription,
DialogFooter,
DialogClose,
} from "../ui/dialog";
import { useErrorStore } from "../../store/errorStore";

export default function ErrorDialog() {
// Get the error state and action from the error store
// action is optional and can be null if no action is provided, if null no button is shown
const error = useErrorStore((state) => state.error);
const action = useErrorStore((state) => state.action);
const clearError = useErrorStore((state) => state.clearError);

return (
<Dialog open={!!error} onOpenChange={(open) => { if (!open) clearError(); }}>
<DialogContent className="bg-white border border-[#e4e4e7] rounded-lg shadow-md max-w-md p-6 gap-4">
<DialogHeader className="gap-1">
<DialogTitle className="flex items-center gap-2 text-sm font-semibold text-[#dc2626]">
<AlertCircle className="w-4 h-4 flex-shrink-0" />
{error?.title ?? "Something went wrong"}
</DialogTitle>
<DialogDescription className="text-sm text-[#52525b] pl-6">
{error?.message}
</DialogDescription>
</DialogHeader>
<DialogFooter>
{action && (
<button
className="px-4 py-1.5 text-sm font-medium rounded-md bg-white text-[#18181b] border border-[#e4e4e7] hover:bg-[#f4f4f5] transition-colors"
onClick={() => { action.onAction(); clearError(); }}
>
{action.label}
</button>
)}
<DialogClose asChild>
<button
className="px-4 py-1.5 text-sm font-medium rounded-md bg-[#18181b] text-white hover:bg-[#27272a] transition-colors"
onClick={clearError}
>
Dismiss
</button>
</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>
);
}
120 changes: 120 additions & 0 deletions pipeline-ui/src/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import * as React from "react"
import * as DialogPrimitive from "@radix-ui/react-dialog"
import { X } from "lucide-react"

import { cn } from "../../lib/utils"

const Dialog = DialogPrimitive.Root

const DialogTrigger = DialogPrimitive.Trigger

const DialogPortal = DialogPrimitive.Portal

const DialogClose = DialogPrimitive.Close

const DialogOverlay = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Overlay
ref={ref}
className={cn(
"fixed inset-0 z-50 bg-black/80 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 left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] 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%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className
)}
{...props}
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</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,
DialogPortal,
DialogOverlay,
DialogTrigger,
DialogClose,
DialogContent,
DialogHeader,
DialogFooter,
DialogTitle,
DialogDescription,
}
2 changes: 1 addition & 1 deletion pipeline-ui/src/config/authConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ if (isKeycloak) {
});
}

export {idp};
export { idp };
92 changes: 92 additions & 0 deletions pipeline-ui/src/lib/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import type { ErrorType } from "../types/errorType";

export const ERROR_MAP: Record<string, ErrorType> = {

ERROR_FETCH_PIPELINES: {
title: "Error fetching pipelines",
message: "There was an error while fetching the pipelines. Please try again later.",
code: 500,
},
ERROR_FETCHING_PIPELINE: {
title: "Error fetching pipeline",
message: "There was an error while fetching the pipeline. Please try again later.",
code: 500,
},
PIPELINE_NOT_FOUND: {
title: "Pipeline not found",
message: "The requested pipeline could not be found. Please check the pipeline ID and try again.",
code: 404,
},
ERROR_CREATING_PIPELINE: {
title: "Error creating pipeline",
message: "There was an error while creating the pipeline. Please try again later.",
code: 500,
},
ERROR_DELETING_PIPELINE: {
title: "Error deleting pipeline",
message: "There was an error while deleting the pipeline. Please try again later.",
code: 500,
},
ERROR_RUNNING_PIPELINE: {
title: "Error running pipeline",
message: "There was an error while running the pipeline. Please try again later.",
code: 500,
},
ERROR_FETCHING_BUILDS: {
title: "Error fetching builds",
message: "There was an error while fetching the builds. Please try again later.",
code: 500,
},
ERROR_FETCHING_BUILD: {
title: "Error fetching build",
message: "There was an error while fetching the build. Please try again later.",
code: 500,
},
BUILD_NOT_FOUND: {
title: "Build not found",
message: "The requested build could not be found. Please check the build ID and try again.",
code: 404,
},
ERROR_FETCHING_LOGS: {
title: "Error fetching logs",
message: "There was an error while fetching the logs. Please try again later.",
code: 500,
},
ERROR_DELETING_BUILD: {
title: "Error deleting build",
message: "There was an error while deleting the build. Please try again later.",
code: 500,
},
REQUEST_TIMEOUT: {
title: "Request timeout",
message: "The request took too long to complete. Please try again later.",
code: 408,
},
UNAUTHORIZED: {
title: "Unauthorized",
message: "You are not authorized to perform this action. Please check your credentials and try again.",
code: 401,
},
SESSION_EXPIRED: {
title: "Session expired",
message: "Your session has expired. Please log in again to continue.",
code: 440,
},
NETWORK_ERROR: {
title: "Network error",
message: "There was a network error. Please check your internet connection and try again.",
code: 503,
},
UNKNOWN_ERROR: {
title: "Unknown error",
message: "An unknown error occurred. Please try again later.",
code: 520,
}
};

export function getError(key: string): ErrorType {
return ERROR_MAP[key] ?? {
title: "Something went wrong",
message: "An unexpected error occurred. Please try again.",
};
}
14 changes: 7 additions & 7 deletions pipeline-ui/src/pages/BuildsPage/BuildsListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Table, TableHeader, TableRow, TableHead, TableBody, TableCell } from ".
import { pipelineBuildApiInstance } from "../../services/pipelines.api";
import type { PipelineBuild } from "../../gen";
import { PipelineBuildCurrentStateEnum } from "../../gen";
import { ERROR_MAP } from "../../lib/error";

/**
* This page includes the Builds List page.
Expand All @@ -24,14 +25,13 @@ export default function BuildsListPage() {

useEffect(() => {
async function fetchData() {
const { status, data } = await pipelineBuildApiInstance.getAllBuilds();

// TODO: handle error properly
if (status !== 200) {
console.error("Error getting builds");
try {
const { data } = await pipelineBuildApiInstance.getAllBuilds();
setBuilds(data);
} catch (err) {
// error handled by axios interceptor, but log the error for debugging purposes
console.error("[ERROR]:", ERROR_MAP.ERROR_FETCHING_BUILDS.title, err);
}

setBuilds(data);
}
fetchData();
}, []);
Expand Down
Loading
Loading