@@ -16,6 +16,7 @@ import {
1616 AccordionTrigger ,
1717} from 'components/redpanda-ui/components/accordion' ;
1818import { Card , CardContent } from 'components/redpanda-ui/components/card' ;
19+ import { CopyButton } from 'components/redpanda-ui/components/copy-button' ;
1920import {
2021 FormControl ,
2122 FormDescription ,
@@ -25,49 +26,70 @@ import {
2526 FormMessage ,
2627} from 'components/redpanda-ui/components/form' ;
2728import { Input } from 'components/redpanda-ui/components/input' ;
28- import { Label } from 'components/redpanda-ui/components/label ' ;
29+ import { SkeletonCard } from 'components/redpanda-ui/components/skeleton ' ;
2930import { Slider } from 'components/redpanda-ui/components/slider' ;
3031import { Textarea } from 'components/redpanda-ui/components/textarea' ;
32+ import { Tooltip , TooltipContent , TooltipTrigger } from 'components/redpanda-ui/components/tooltip' ;
3133import { Text } from 'components/redpanda-ui/components/typography' ;
34+ import { InfoIcon } from 'lucide-react' ;
35+ import type { Pipeline } from 'protogen/redpanda/api/dataplane/v1/pipeline_pb' ;
36+ import React from 'react' ;
3237import { useFormContext } from 'react-hook-form' ;
3338
34- import { MAX_TASKS , MIN_TASKS } from '../tasks' ;
39+ import { cpuToTasks , MAX_TASKS , MIN_TASKS } from '../tasks' ;
3540
3641type DetailsProps = {
3742 readonly ?: boolean ;
43+ pipeline ?: Pipeline ;
3844} ;
3945
40- export function Details ( { readonly = false } : DetailsProps ) {
41- const { control, watch } = useFormContext ( ) ;
42- const name = watch ( 'name' ) ;
43- const description = watch ( 'description' ) ;
44- const computeUnits = watch ( 'computeUnits' ) ;
46+ const DetailRow = ( {
47+ label,
48+ value,
49+ copyable = false ,
50+ } : {
51+ label : React . ReactNode ;
52+ value ?: string ;
53+ copyable ?: boolean ;
54+ } ) => (
55+ < div className = "grid h-7 min-w-0 grid-cols-[minmax(0,1.5fr)_minmax(0,2fr)_30px] gap-1" >
56+ { typeof label === 'string' ? < Text variant = "label" > { label } </ Text > : ( label ?? null ) }
57+ < Text className = "truncate" > { value ?? '' } </ Text >
58+ { copyable && value ? < CopyButton content = { value } size = "sm" variant = "ghost" /> : null }
59+ </ div >
60+ ) ;
61+
62+ export function Details ( { readonly = false , pipeline } : DetailsProps ) {
63+ const { control } = useFormContext ( ) ;
4564
4665 if ( readonly ) {
66+ if ( ! pipeline ) {
67+ return < SkeletonCard /> ;
68+ }
4769 return (
4870 < Card size = "full" >
4971 < CardContent >
50- < div className = "flex items-center gap-4" >
51- < Label > Pipeline Name</ Label >
52- < Text > { name } </ Text >
72+ < div className = "flex flex-col gap-4" >
73+ < DetailRow copyable label = "ID" value = { pipeline . id } />
74+ < DetailRow label = "Description" value = { pipeline . description } />
75+ < div className = "flex flex-col" >
76+ < DetailRow
77+ label = {
78+ < Tooltip >
79+ < Text className = "flex items-center gap-1" variant = "label" >
80+ Compute units
81+ < TooltipTrigger >
82+ < InfoIcon className = "-mt-0.5 size-3 cursor-pointer text-muted-foreground" />
83+ </ TooltipTrigger >
84+ </ Text >
85+ < TooltipContent > One compute unit = 0.1 CPU and 400 MB memory</ TooltipContent >
86+ </ Tooltip >
87+ }
88+ value = { `${ cpuToTasks ( pipeline . resources ?. cpuShares ) ?? 0 } ` }
89+ />
90+ </ div >
91+ < DetailRow copyable label = "URL" value = { pipeline . url } />
5392 </ div >
54-
55- < Accordion collapsible type = "single" >
56- < AccordionItem value = "advanced" variant = "outlined" >
57- < AccordionTrigger > Advanced Settings</ AccordionTrigger >
58- < AccordionContent className = "space-y-4" >
59- < div className = "space-y-2" >
60- < Label > Description</ Label >
61- < Text > { description || '-' } </ Text >
62- </ div >
63-
64- < div className = "space-y-2" >
65- < Label > Compute Units: { computeUnits } </ Label >
66- < Text variant = "muted" > One compute unit = 0.1 CPU and 400 MB memory</ Text >
67- </ div >
68- </ AccordionContent >
69- </ AccordionItem >
70- </ Accordion >
7193 </ CardContent >
7294 </ Card >
7395 ) ;
@@ -81,7 +103,7 @@ export function Details({ readonly = false }: DetailsProps) {
81103 name = "name"
82104 render = { ( { field } ) => (
83105 < FormItem >
84- < FormLabel required > Pipeline Name </ FormLabel >
106+ < FormLabel required > Pipeline name </ FormLabel >
85107 < FormControl >
86108 < Input { ...field } placeholder = "Enter pipeline name" />
87109 </ FormControl >
@@ -91,9 +113,9 @@ export function Details({ readonly = false }: DetailsProps) {
91113 />
92114
93115 < Accordion collapsible type = "single" >
94- < AccordionItem value = "advanced" variant = "outlined " >
95- < AccordionTrigger > Advanced Settings </ AccordionTrigger >
96- < AccordionContent className = "space-y-4" >
116+ < AccordionItem value = "advanced" variant = "contained " >
117+ < AccordionTrigger > Advanced settings </ AccordionTrigger >
118+ < AccordionContent className = "space-y-4 pt-4 " >
97119 < FormField
98120 control = { control }
99121 name = "description"
@@ -113,7 +135,7 @@ export function Details({ readonly = false }: DetailsProps) {
113135 name = "computeUnits"
114136 render = { ( { field } ) => (
115137 < FormItem >
116- < FormLabel > Compute Units: { field . value } </ FormLabel >
138+ < FormLabel > Compute units </ FormLabel >
117139 < FormControl >
118140 < div className = "flex items-center gap-2" >
119141 < Slider
0 commit comments