-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Applications UI #83
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
Merged
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
15a9df8
add: applications mock-data
Maiki04 68a3ca3
add: everything like v0
Maiki04 6090e7d
add: all mock data for applications
Maiki04 e6344a2
fix: unnecessary change
Maiki04 2a5b49a
fix: unnecessary properties
Maiki04 fa4d7cc
add: todo
Maiki04 e266e6a
fix: removed barrel file
Maiki04 0fa4c08
feat: new folder structure
Maiki04 ba1d527
Merge branch 'main' into feature/mock-data
alex289 4b0b6ca
feat: Cleanup
alex289 2451db8
faet: Shadcn breadcrumbs
alex289 4a586f4
feat: Sidebar
alex289 fda4998
feat: More cleanup
alex289 2c08e22
feat: Apps data table
alex289 098af0f
fix: Linting
alex289 185637e
feat: Syntax highlighting
alex289 2f73a44
feat: Cleanup status badge
alex289 1711aa8
feat: Add application dialog
alex289 bf3032f
feat: Bundle optimize shiki
alex289 68b0a94
feat: Use more Shadcn components
alex289 a340b73
feat: Connect backend and frontend
alex289 032627a
feat: Minor fixes
alex289 1d31364
feat: Consolidate settings page
alex289 e4e5f94
feat: Use toggle group
alex289 887a81b
feat: UI improvements
alex289 3b6a4ac
Merge branch 'main' into feature/mock-data
alex289 fb7387f
Merge branch 'main' into feature/mock-data
timokoessler 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,144 @@ | ||
| // oxlint-disable react/no-children-prop | ||
| import { Pencil, Plus } from "lucide-react"; | ||
| import { Button } from "../ui/button"; | ||
| import z from "zod"; | ||
| import type { Application } from "@/lib/applications"; | ||
| import { useState } from "react"; | ||
| import { toast } from "sonner"; | ||
| import { useForm } from "@tanstack/react-form"; | ||
| import { | ||
| Dialog, | ||
| DialogContent, | ||
| DialogDescription, | ||
| DialogHeader, | ||
| DialogTitle, | ||
| DialogTrigger, | ||
| } from "../ui/dialog"; | ||
| import { DropdownMenuItem } from "../ui/dropdown-menu"; | ||
| import { Field, FieldError, FieldGroup } from "../ui/field"; | ||
| import { Label } from "../ui/label"; | ||
| import { Input } from "../ui/input"; | ||
|
|
||
| const applicationSchema = z.object({ | ||
| name: z | ||
| .string() | ||
| .trim() | ||
| .min(1, "Name is required") | ||
| .max(128, "Name must be at most 128 characters"), | ||
| }); | ||
|
|
||
| export default function UpsertApplicationDialog({ | ||
| application, | ||
| asDropdownItem = false, | ||
| }: { | ||
| application: Application | null; | ||
| asDropdownItem?: boolean; | ||
| }) { | ||
| const isEditing = !!application; | ||
| const [isSubmitting, setIsSubmitting] = useState(false); | ||
| const [open, setOpen] = useState(false); | ||
|
|
||
| const form = useForm({ | ||
| defaultValues: { | ||
| name: application?.name ?? "", | ||
| }, | ||
| validators: { | ||
| onSubmit: applicationSchema, | ||
| }, | ||
| onSubmit: () => { | ||
| setIsSubmitting(true); | ||
| try { | ||
| if (isEditing && application) { | ||
| toast.success("Application updated"); | ||
| } else { | ||
| toast.success("Application created"); | ||
| } | ||
| setOpen(false); | ||
| } catch (err) { | ||
| toast.error(err instanceof Error ? err.message : "Failed to save application"); | ||
| } finally { | ||
| setIsSubmitting(false); | ||
| } | ||
| }, | ||
| }); | ||
| return ( | ||
| <Dialog open={open} onOpenChange={(open) => setOpen(open)}> | ||
| <DialogTrigger asChild> | ||
| {asDropdownItem ? ( | ||
| <DropdownMenuItem onSelect={(e) => e.preventDefault()}> | ||
| <Pencil className="h-4 w-4" /> | ||
| Edit | ||
| </DropdownMenuItem> | ||
| ) : isEditing ? ( | ||
| <Button variant="ghost" size="icon"> | ||
| <Pencil className="h-4 w-4" /> | ||
| </Button> | ||
| ) : ( | ||
| <Button> | ||
| <Plus className="h-4 w-4" /> | ||
| New Application | ||
| </Button> | ||
| )} | ||
| </DialogTrigger> | ||
| <DialogContent className="sm:max-w-106.25"> | ||
| <DialogHeader> | ||
| <DialogTitle className="flex items-center gap-2"> | ||
| {isEditing ? "Edit Application" : "Add Application"} | ||
| </DialogTitle> | ||
| <DialogDescription className="py-2"> | ||
| {isEditing | ||
| ? "Update the application configuration." | ||
| : "Add a new application to monitor and manage."} | ||
| </DialogDescription> | ||
| </DialogHeader> | ||
|
|
||
| <form | ||
| onSubmit={async (e) => { | ||
| e.preventDefault(); | ||
| await form.handleSubmit(); | ||
| }} | ||
| > | ||
| <FieldGroup> | ||
| <form.Field | ||
| name="name" | ||
| children={(field) => { | ||
| const isInvalid = field.state.meta.isTouched && !field.state.meta.isValid; | ||
| return ( | ||
| <Field data-invalid={isInvalid}> | ||
| <Label htmlFor={field.name}>Name</Label> | ||
| <Input | ||
| id={field.name} | ||
| value={field.state.value} | ||
| onBlur={field.handleBlur} | ||
| onChange={(e) => field.handleChange(e.target.value)} | ||
| placeholder='e.g. "notifications-service"' | ||
| autoFocus | ||
| /> | ||
| {isInvalid && <FieldError errors={field.state.meta.errors} />} | ||
| </Field> | ||
| ); | ||
| }} | ||
| /> | ||
|
|
||
| <div className="flex gap-2 pt-2"> | ||
| <Button type="submit" disabled={isSubmitting}> | ||
| {isSubmitting ? "Saving..." : isEditing ? "Update Application" : "Add Application"} | ||
| </Button> | ||
| <Button | ||
| type="button" | ||
| variant="outline" | ||
| onClick={() => { | ||
| setOpen(false); | ||
| form.reset(); | ||
| }} | ||
| disabled={isSubmitting} | ||
| > | ||
| Cancel | ||
| </Button> | ||
| </div> | ||
| </FieldGroup> | ||
| </form> | ||
| </DialogContent> | ||
| </Dialog> | ||
| ); | ||
| } |
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,71 @@ | ||
| import type { HealthStatus, SyncStatus } from "@/lib/applications"; | ||
| import { cn } from "@/lib/utils"; | ||
|
|
||
| type StatusBadgeProps = | ||
| | { type: "sync"; status: SyncStatus } | ||
| | { type: "health"; status: HealthStatus }; | ||
|
|
||
| const syncConfig: Record<SyncStatus, { label: string; className: string; dotClass: string }> = { | ||
| Synced: { | ||
| label: "Synced", | ||
| className: "bg-emerald-500/20 text-emerald-400 border-emerald-500/30", | ||
| dotClass: "bg-emerald-400", | ||
| }, | ||
| OutOfSync: { | ||
| label: "Out of Sync", | ||
| className: "bg-amber-500/20 text-amber-400 border-amber-500/30", | ||
| dotClass: "bg-amber-400", | ||
| }, | ||
| Progressing: { | ||
| label: "Syncing", | ||
| className: "bg-blue-500/20 text-blue-400 border-blue-500/30", | ||
| dotClass: "bg-blue-400 animate-pulse", | ||
| }, | ||
| Unknown: { | ||
| label: "Unknown", | ||
| className: "bg-zinc-500/20 text-zinc-400 border-zinc-500/30", | ||
| dotClass: "bg-zinc-400", | ||
| }, | ||
| }; | ||
|
|
||
| const healthConfig: Record<HealthStatus, { label: string; className: string; dotClass: string }> = { | ||
| Healthy: { | ||
| label: "Healthy", | ||
| className: "bg-emerald-500/20 text-emerald-400 border-emerald-500/30", | ||
| dotClass: "bg-emerald-400", | ||
| }, | ||
| Degraded: { | ||
| label: "Degraded", | ||
| className: "bg-amber-500/20 text-amber-400 border-amber-500/30", | ||
| dotClass: "bg-amber-400", | ||
| }, | ||
| Progressing: { | ||
| label: "Unhealthy", | ||
| className: "bg-red-500/20 text-red-400 border-red-500/30", | ||
| dotClass: "bg-red-400", | ||
| }, | ||
| Unknown: { | ||
| label: "Unknown", | ||
| className: "bg-zinc-500/20 text-zinc-400 border-zinc-500/30", | ||
| dotClass: "bg-zinc-400", | ||
| }, | ||
| }; | ||
|
|
||
| export function StatusBadge(props: StatusBadgeProps) { | ||
| let config = | ||
| props.type === "sync" | ||
| ? syncConfig[props.status as SyncStatus] | ||
| : healthConfig[props.status as HealthStatus]; | ||
|
|
||
| return ( | ||
| <span | ||
| className={cn( | ||
| "inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border", | ||
| config.className, | ||
| )} | ||
| > | ||
| <span className={cn("h-1.5 w-1.5 rounded-full", config.dotClass)} /> | ||
| {config.label} | ||
| </span> | ||
| ); | ||
| } | ||
108 changes: 108 additions & 0 deletions
108
frontend/src/components/tables/applications/columns.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,108 @@ | ||
| import type { ColumnDef } from "@tanstack/react-table"; | ||
| import { MoreHorizontal } from "lucide-react"; | ||
| import { Button } from "@/components/ui/button"; | ||
| import { | ||
| DropdownMenu, | ||
| DropdownMenuContent, | ||
| DropdownMenuItem, | ||
| DropdownMenuTrigger, | ||
| } from "@/components/ui/dropdown-menu"; | ||
| import { DataTableColumnHeader } from "../data-table-column-header"; | ||
| import type { Application } from "@/lib/applications"; | ||
| import { Link } from "@tanstack/react-router"; | ||
| import { StatusBadge } from "@/components/status-badge"; | ||
|
|
||
| export const columns: ColumnDef<Application>[] = [ | ||
| { | ||
| accessorKey: "name", | ||
| header: ({ column }) => { | ||
| return <DataTableColumnHeader column={column} title="Name" />; | ||
| }, | ||
| cell: ({ row }) => { | ||
| const app = row.original; | ||
| return ( | ||
| <Link | ||
| to="/applications/$id" | ||
| params={{ id: app.id }} | ||
| className="font-medium hover:text-primary" | ||
| > | ||
| {app.name} | ||
| </Link> | ||
| ); | ||
| }, | ||
| }, | ||
| { | ||
| id: "syncStatus", | ||
| accessorFn: (row) => row.syncStatus, | ||
| header: ({ column }) => { | ||
| return <DataTableColumnHeader column={column} title="Sync Status" />; | ||
| }, | ||
| cell: ({ row }) => { | ||
| const app = row.original; | ||
| return <StatusBadge status={app.syncStatus} type="sync" />; | ||
| }, | ||
| }, | ||
| { | ||
| id: "healthStatus", | ||
| accessorFn: (row) => row.healthStatus, | ||
| header: ({ column }) => { | ||
| return <DataTableColumnHeader column={column} title="Health Status" />; | ||
| }, | ||
| cell: ({ row }) => { | ||
| const app = row.original; | ||
| return <StatusBadge status={app.healthStatus} type="health" />; | ||
| }, | ||
| }, | ||
| { | ||
| accessorKey: "repo", | ||
| header: ({ column }) => { | ||
| return <DataTableColumnHeader column={column} title="Repository" />; | ||
| }, | ||
| }, | ||
| { | ||
| accessorKey: "agent", | ||
| header: ({ column }) => { | ||
| return <DataTableColumnHeader column={column} title="Agent" />; | ||
| }, | ||
| }, | ||
| { | ||
| accessorKey: "branch", | ||
| header: ({ column }) => { | ||
| return <DataTableColumnHeader column={column} title="Branch" />; | ||
| }, | ||
| }, | ||
| { | ||
| accessorKey: "path", | ||
| header: ({ column }) => { | ||
| return <DataTableColumnHeader column={column} title="Path" />; | ||
| }, | ||
| }, | ||
| { | ||
| accessorKey: "lastSync", | ||
| header: ({ column }) => { | ||
| return <DataTableColumnHeader column={column} title="Last Sync" />; | ||
| }, | ||
| }, | ||
| { | ||
| id: "actions", | ||
| cell: () => { | ||
| return ( | ||
| <div className="flex justify-end"> | ||
| <DropdownMenu> | ||
| <DropdownMenuTrigger asChild onClick={(e) => e.preventDefault()}> | ||
| <Button variant="ghost" size="icon" className="h-8 w-8"> | ||
| <MoreHorizontal className="h-4 w-4" /> | ||
| </Button> | ||
| </DropdownMenuTrigger> | ||
| <DropdownMenuContent align="end"> | ||
| <DropdownMenuItem>Sync</DropdownMenuItem> | ||
| <DropdownMenuItem>Refresh</DropdownMenuItem> | ||
|
alex289 marked this conversation as resolved.
Outdated
alex289 marked this conversation as resolved.
Outdated
|
||
| <DropdownMenuItem>Settings</DropdownMenuItem> | ||
| <DropdownMenuItem className="text-destructive">Delete</DropdownMenuItem> | ||
| </DropdownMenuContent> | ||
| </DropdownMenu> | ||
| </div> | ||
| ); | ||
| }, | ||
| }, | ||
| ]; | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.