-
Notifications
You must be signed in to change notification settings - Fork 66
Feat: Sandbox details events table #300
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
Open
sarimrmalik
wants to merge
43
commits into
main
Choose a base branch
from
feat/sandbox-details-events-table
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+719
−177
Open
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
149c9b5
feat: add sandbox events page and table component
sarimrmalik 7f418d1
feat: enhance SandboxEventsTable with sorting and empty state
sarimrmalik 7c88ab3
feat: enhance timestamp formatting in SandboxEventsTable
sarimrmalik 147f5f7
refactor: simplify EventTypeCell layout in SandboxEventsTable
sarimrmalik 8ea55bf
feat: add lifecycle event filtering and display in SandboxEvents
sarimrmalik 78e9fee
style: update cell alignment and styling in SandboxEventsTable
sarimrmalik e455d68
refactor: replace DataTable with Table components in SandboxEventsTable
sarimrmalik 2e3ecef
feat: introduce IdBadge component for improved event ID display in Sa…
sarimrmalik 600ed23
style: enhance header cell styling in SandboxEventsTable
sarimrmalik 82e8bd2
refactor: remove listSandboxLifecycleEvents method and related query …
sarimrmalik 9c60048
refactor: simplify SandboxEventTypeBadge and adjust table cell styles
sarimrmalik e859f5e
Merge remote-tracking branch 'origin/main' into feat/sandbox-details-…
sarimrmalik e68d611
refactor: enhance SandboxEventTypeBadge and update EventTypeFilter st…
sarimrmalik a4c92d5
refactor: update event type filter and table styling
sarimrmalik ae0d5f4
refactor: simplify EventDetailsCell and enhance JSON display
sarimrmalik 5935c98
Run biome format
sarimrmalik 7e9f3c1
refactor: remove 'types' parameter from API specifications and relate…
sarimrmalik 0480f6f
refactor: streamline sandbox lifecycle event handling
sarimrmalik d1ef298
Rollback pagination changes
sarimrmalik 30781d7
refactor: rename sandbox event data schema for consistency
sarimrmalik 6451a77
Run biome format
sarimrmalik 21236c2
refactor: simplify SandboxEventsTable and remove unused components
sarimrmalik 1615cab
Merge remote-tracking branch 'origin/main' into feat/sandbox-details-…
sarimrmalik f569522
refactor: update ID badge component to use Button instead of IconButton
sarimrmalik cc323b8
Remove default exports
sarimrmalik fec5e28
Merge remote-tracking branch 'origin/main' into feat/sandbox-details-…
sarimrmalik 5f46012
refactor: enhance event type badge and table components
sarimrmalik 1df7039
refactor: simplify EventTypeFilter component structure
sarimrmalik a1e1a38
Merge branch 'main' into feat/sandbox-details-events-table
ben-fornefeld cb125a8
Refactor: centralize IdBadge component usage
sarimrmalik 4661bbe
feat: enable client-side rendering for event type filter
sarimrmalik 7040cb9
fix: improve event type parsing in EventTypeFilter component
sarimrmalik 12cb290
refactor: update column styles in SandboxEventsTable
sarimrmalik f7b502c
refactor: replace button with Button component in SandboxEventsTable
sarimrmalik 891ad0a
refactor: simplify empty state rendering in SandboxEventsTable
sarimrmalik a01c7cc
refactor: enhance event type parsing in useSandboxEventFilters
sarimrmalik 37879bd
refactor: add comment for event ordering in SandboxEventsView
sarimrmalik fc342ad
refactor: replace WEBHOOK_EVENTS with SandboxLifecycleEventTypeSchema…
sarimrmalik a0d5a1e
refactor: replace log rendering components with virtualized alternatives
sarimrmalik a1d4de2
refactor: remove outdated comment in virtualized table UI
sarimrmalik c5b8778
Remove unused fragment
sarimrmalik 9b433da
refactor: enhance sandbox lifecycle event handling and filtering
sarimrmalik dd645a7
refactor: enhance SandboxEventsTable layout and data display
sarimrmalik 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
5 changes: 5 additions & 0 deletions
5
src/app/dashboard/[teamSlug]/sandboxes/[sandboxId]/events/page.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,5 @@ | ||
| import { SandboxEventsView } from '@/features/dashboard/sandbox/events' | ||
|
|
||
| export default function SandboxEventsPage() { | ||
| return <SandboxEventsView /> | ||
| } |
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,19 @@ | ||
| import { z } from 'zod' | ||
|
|
||
| const SANDBOX_LIFECYCLE_EVENT_TYPE_PREFIX = 'sandbox.lifecycle.' | ||
|
|
||
| const SandboxLifecycleEventTypeSchema = z.enum([ | ||
| `${SANDBOX_LIFECYCLE_EVENT_TYPE_PREFIX}created`, | ||
| `${SANDBOX_LIFECYCLE_EVENT_TYPE_PREFIX}updated`, | ||
| `${SANDBOX_LIFECYCLE_EVENT_TYPE_PREFIX}paused`, | ||
| `${SANDBOX_LIFECYCLE_EVENT_TYPE_PREFIX}resumed`, | ||
| `${SANDBOX_LIFECYCLE_EVENT_TYPE_PREFIX}killed`, | ||
| ]) | ||
|
|
||
| type SandboxLifecycleEventType = z.infer<typeof SandboxLifecycleEventTypeSchema> | ||
|
|
||
| export { | ||
| SANDBOX_LIFECYCLE_EVENT_TYPE_PREFIX, | ||
| SandboxLifecycleEventTypeSchema, | ||
| type SandboxLifecycleEventType, | ||
| } | ||
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
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,53 @@ | ||
| import type { VirtualItem, Virtualizer } from '@tanstack/react-virtual' | ||
| import type { CSSProperties, ReactNode } from 'react' | ||
| import { Loader } from '@/ui/primitives/loader' | ||
| import { TableBody, TableCell, TableRow } from '@/ui/primitives/table' | ||
|
|
||
| export const getVirtualizedRowStyle = ( | ||
| virtualRow: VirtualItem, | ||
| height: number | ||
| ): CSSProperties => ({ | ||
| display: 'flex', | ||
| position: 'absolute', | ||
| left: 0, | ||
| transform: `translateY(${virtualRow.start}px)`, | ||
| minWidth: '100%', | ||
| height, | ||
| }) | ||
|
|
||
| interface VirtualizedTableRowProps { | ||
| virtualRow: VirtualItem | ||
| virtualizer: Virtualizer<HTMLDivElement, Element> | ||
| height: number | ||
| className?: string | ||
| children: ReactNode | ||
| } | ||
|
|
||
| export const VirtualizedTableRow = ({ | ||
| virtualRow, | ||
| virtualizer, | ||
| height, | ||
| className, | ||
| children, | ||
| }: VirtualizedTableRowProps) => ( | ||
| <TableRow | ||
| data-index={virtualRow.index} | ||
| ref={(node) => virtualizer.measureElement(node)} | ||
| className={className} | ||
| style={getVirtualizedRowStyle(virtualRow, height)} | ||
| > | ||
| {children} | ||
| </TableRow> | ||
| ) | ||
|
|
||
| export const VirtualizedTableLoaderBody = () => ( | ||
| <TableBody className="grid"> | ||
| <TableRow className="flex min-w-full mt-2"> | ||
| <TableCell className="flex-1"> | ||
| <div className="h-[35svh] w-full flex justify-center items-center"> | ||
| <Loader variant="slash" size="lg" /> | ||
| </div> | ||
| </TableCell> | ||
| </TableRow> | ||
| </TableBody> | ||
| ) |
24 changes: 24 additions & 0 deletions
24
src/features/dashboard/sandbox/events/event-type-badge.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,24 @@ | ||
| import { SandboxLifecycleEventTypeSchema } from '@/core/modules/sandboxes/lifecycle-event-types' | ||
| import { Badge } from '@/ui/primitives/badge' | ||
| import { SANDBOX_EVENT_TYPE_MAP } from './event-type-map' | ||
|
|
||
| export const SandboxEventTypeBadge = ({ type }: { type: string }) => { | ||
| const parsed = SandboxLifecycleEventTypeSchema.safeParse(type) | ||
|
|
||
| if (!parsed.success) { | ||
| return ( | ||
| <Badge variant="default" size="sm" className="align-middle uppercase"> | ||
| {type} | ||
| </Badge> | ||
| ) | ||
| } | ||
|
|
||
| const { icon: IconComponent, label } = SANDBOX_EVENT_TYPE_MAP[parsed.data] | ||
|
|
||
| return ( | ||
| <Badge variant="default" size="sm" className="align-middle uppercase"> | ||
| <IconComponent /> | ||
| {label} | ||
| </Badge> | ||
| ) | ||
| } |
79 changes: 79 additions & 0 deletions
79
src/features/dashboard/sandbox/events/event-type-filter.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,79 @@ | ||
| 'use client' | ||
|
|
||
| import { | ||
|
sarimrmalik marked this conversation as resolved.
|
||
| type SandboxLifecycleEventType, | ||
| SandboxLifecycleEventTypeSchema, | ||
| } from '@/core/modules/sandboxes/lifecycle-event-types' | ||
| import { Button } from '@/ui/primitives/button' | ||
| import { | ||
| DropdownMenu, | ||
| DropdownMenuCheckboxItem, | ||
| DropdownMenuContent, | ||
| DropdownMenuSeparator, | ||
| DropdownMenuTrigger, | ||
| } from '@/ui/primitives/dropdown-menu' | ||
| import { SandboxEventTypeBadge } from './event-type-badge' | ||
| import { SANDBOX_EVENT_TYPE_MAP } from './event-type-map' | ||
|
|
||
| const getTriggerLabel = (selected: SandboxLifecycleEventType[]) => { | ||
| if (selected.length === SandboxLifecycleEventTypeSchema.options.length) | ||
| return 'All' | ||
| if (selected.length === 0) return 'None' | ||
| const [first] = selected | ||
| if (selected.length === 1 && first) return SANDBOX_EVENT_TYPE_MAP[first].label | ||
| return `${selected.length}/${SandboxLifecycleEventTypeSchema.options.length}` | ||
| } | ||
|
|
||
| interface EventTypeFilterProps { | ||
| types: SandboxLifecycleEventType[] | ||
| onTypesChange: (types: SandboxLifecycleEventType[]) => void | ||
| } | ||
|
|
||
| export const EventTypeFilter = ({ | ||
| types, | ||
| onTypesChange, | ||
| }: EventTypeFilterProps) => { | ||
| const isAllSelected = | ||
| types.length === SandboxLifecycleEventTypeSchema.options.length | ||
|
|
||
| const toggleType = (type: SandboxLifecycleEventType) => { | ||
| const next = types.includes(type) | ||
| ? types.filter((t) => t !== type) | ||
| : [...types, type] | ||
| onTypesChange(next) | ||
| } | ||
|
|
||
| const toggleAll = (checked: boolean) => { | ||
| onTypesChange(checked ? [...SandboxLifecycleEventTypeSchema.options] : []) | ||
| } | ||
|
|
||
| return ( | ||
| <DropdownMenu> | ||
| <DropdownMenuTrigger asChild> | ||
| <Button variant="secondary" className="font-sans w-min normal-case"> | ||
| Events · {getTriggerLabel(types)} | ||
| </Button> | ||
| </DropdownMenuTrigger> | ||
| <DropdownMenuContent align="start"> | ||
| <DropdownMenuCheckboxItem | ||
| checked={isAllSelected} | ||
| onCheckedChange={toggleAll} | ||
| onSelect={(e) => e.preventDefault()} | ||
| > | ||
| All events | ||
| </DropdownMenuCheckboxItem> | ||
| <DropdownMenuSeparator /> | ||
| {SandboxLifecycleEventTypeSchema.options.map((type) => ( | ||
| <DropdownMenuCheckboxItem | ||
| key={type} | ||
| checked={types.includes(type)} | ||
| onCheckedChange={() => toggleType(type)} | ||
| onSelect={(e) => e.preventDefault()} | ||
| > | ||
| <SandboxEventTypeBadge type={type} /> | ||
| </DropdownMenuCheckboxItem> | ||
| ))} | ||
| </DropdownMenuContent> | ||
| </DropdownMenu> | ||
| ) | ||
| } | ||
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,22 @@ | ||
| import type { SandboxLifecycleEventType } from '@/core/modules/sandboxes/lifecycle-event-types' | ||
| import { | ||
| BlockIcon, | ||
| CheckIcon, | ||
| type Icon, | ||
| PausedIcon, | ||
| RefreshIcon, | ||
| RunningIcon, | ||
| } from '@/ui/primitives/icons' | ||
|
|
||
| const SANDBOX_EVENT_TYPE_MAP: Record< | ||
| SandboxLifecycleEventType, | ||
| { icon: Icon; label: string } | ||
| > = { | ||
| 'sandbox.lifecycle.created': { icon: CheckIcon, label: 'Created' }, | ||
| 'sandbox.lifecycle.updated': { icon: RefreshIcon, label: 'Updated' }, | ||
| 'sandbox.lifecycle.paused': { icon: PausedIcon, label: 'Paused' }, | ||
| 'sandbox.lifecycle.resumed': { icon: RunningIcon, label: 'Resumed' }, | ||
| 'sandbox.lifecycle.killed': { icon: BlockIcon, label: 'Killed' }, | ||
| } | ||
|
|
||
| export { SANDBOX_EVENT_TYPE_MAP } |
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.