@@ -48,6 +48,28 @@ import { DefaultSkeleton } from '../../../utils/tsxUtils';
4848import DebugBundleLink from '../../debugBundle/DebugBundleLink' ;
4949import { SingleSelect } from '../../misc/Select' ;
5050
51+ // Unit mappings for consistent dropdown handling
52+ const SIZE_UNITS = [
53+ { value : 1 , label : 'Bytes' } ,
54+ { value : 1024 , label : 'KB' } ,
55+ { value : 1024 * 1024 , label : 'MB' } ,
56+ { value : 1024 * 1024 * 1024 , label : 'GB' } ,
57+ ] ;
58+
59+ const TIME_UNITS = [
60+ { value : 1 , label : 'Seconds' } ,
61+ { value : 60 , label : 'Minutes' } ,
62+ ] ;
63+
64+ // Helper functions to get labels from unit values
65+ const getSizeUnitLabel = ( unitValue : number ) : string => {
66+ return SIZE_UNITS . find ( ( unit ) => unit . value === unitValue ) ?. label || "" ;
67+ } ;
68+
69+ const getTimeUnitLabel = ( unitValue : number ) : string => {
70+ return TIME_UNITS . find ( ( unit ) => unit . value === unitValue ) ?. label || "" ;
71+ } ;
72+
5173const Header = ( ) => (
5274 < Text >
5375 Collect environment data that can help debug and diagnose issues with a Redpanda cluster, a broker, or the machine
@@ -185,18 +207,18 @@ const NewDebugBundleForm: FC<{
185207 brokerIds : [ ] as number [ ] ,
186208 tlsEnabled : false ,
187209 tlsInsecureSkipVerify : false ,
188- controllerLogsSizeLimitBytes : 0 as number ,
210+ controllerLogsSizeLimitBytes : 132 as number , // Default 132MB
189211 controllerLogsSizeLimitUnit : 1024 * 1024 , // Default to MB
190- cpuProfilerWaitSeconds : undefined as number | undefined ,
212+ cpuProfilerWaitSeconds : 30 as number | undefined , // Default 30s
191213 cpuProfilerWaitUnit : 1 , // Default to seconds
192- logsSince : undefined as number | undefined ,
193- logsSizeLimitBytes : 0 as number ,
194- logsSizeLimitUnit : 1 ,
214+ logsSince : new Date ( ) . setDate ( new Date ( ) . getDate ( ) - 1 ) as number | undefined , // Default yesterday
215+ logsSizeLimitBytes : 100 as number , // Default 100MB
216+ logsSizeLimitUnit : 1024 * 1024 , // Default to MB
195217 logsUntil : undefined as number | undefined ,
196- metricsIntervalSeconds : 0 as number ,
218+ metricsIntervalSeconds : 10 as number , // Default 10s
197219 metricsIntervalUnit : 1 , // Default to seconds
198- metricsSamples : '' as string ,
199- namespace : '' as string ,
220+ metricsSamples : '2 ' as string , // Default 2 samples
221+ namespace : 'redpanda ' as string , // Default "redpanda"
200222 partitions : [ ] as string [ ] ,
201223 labelSelectors : [ ] as Array < { key : string ; value : string } > ,
202224
@@ -287,9 +309,9 @@ const NewDebugBundleForm: FC<{
287309 cpuProfilerWaitSeconds : formState . cpuProfilerWaitSeconds
288310 ? formState . cpuProfilerWaitSeconds * formState . cpuProfilerWaitUnit
289311 : undefined ,
290- logsSince : formState . logsSince ? timestampFromDate ( new Date ( formState . logsSince ) ) : undefined ,
312+ logsSince : formState . logsSince ? Timestamp . fromDate ( new Date ( formState . logsSince ) ) : undefined ,
291313 logsSizeLimitBytes : formState . logsSizeLimitBytes * formState . logsSizeLimitUnit ,
292- logsUntil : formState . logsUntil ? timestampFromDate ( new Date ( formState . logsUntil ) ) : undefined ,
314+ logsUntil : formState . logsUntil ? Timestamp . fromDate ( new Date ( formState . logsUntil ) ) : undefined ,
293315 metricsIntervalSeconds : formState . metricsIntervalSeconds * formState . metricsIntervalUnit ,
294316 tlsEnabled : formState . tlsEnabled ,
295317 tlsInsecureSkipVerify : formState . tlsInsecureSkipVerify ,
@@ -401,34 +423,10 @@ const NewDebugBundleForm: FC<{
401423 minWidth : 150 ,
402424 } ) ,
403425 } }
404- options = { [
405- {
406- value : 1 ,
407- label : 'Bytes' ,
408- } ,
409- {
410- value : 1024 ,
411- label : 'KB' ,
412- } ,
413- {
414- value : 1024 * 1024 ,
415- label : 'MB' ,
416- } ,
417- {
418- value : 1024 * 1024 * 1024 ,
419- label : 'GB' ,
420- } ,
421- ] }
426+ options = { SIZE_UNITS }
422427 value = { {
423428 value : formState . controllerLogsSizeLimitUnit ,
424- label :
425- formState . controllerLogsSizeLimitUnit === 1
426- ? 'Bytes'
427- : formState . controllerLogsSizeLimitUnit === 1024
428- ? 'KB'
429- : formState . controllerLogsSizeLimitUnit === 1024 * 1024
430- ? 'MB'
431- : 'GB' ,
429+ label : getSizeUnitLabel ( formState . controllerLogsSizeLimitUnit ) ,
432430 } }
433431 onChange = { ( value ) => {
434432 if ( value && isSingleValue ( value ) ) {
@@ -458,19 +456,10 @@ const NewDebugBundleForm: FC<{
458456 minWidth : 150 ,
459457 } ) ,
460458 } }
461- options = { [
462- {
463- value : 1 ,
464- label : 'Seconds' ,
465- } ,
466- {
467- value : 60 ,
468- label : 'Minutes' ,
469- } ,
470- ] }
459+ options = { TIME_UNITS }
471460 value = { {
472461 value : formState . cpuProfilerWaitUnit ,
473- label : formState . cpuProfilerWaitUnit === 1 ? 'Seconds' : 'Minutes' ,
462+ label : getTimeUnitLabel ( formState . cpuProfilerWaitUnit ) ,
474463 } }
475464 onChange = { ( value ) => {
476465 if ( value && isSingleValue ( value ) ) {
@@ -516,24 +505,11 @@ const NewDebugBundleForm: FC<{
516505 minWidth : 150 ,
517506 } ) ,
518507 } }
519- options = { [
520- {
521- value : 1 ,
522- label : 'Bytes' ,
523- } ,
524- {
525- value : 1024 ,
526- label : 'KB' ,
527- } ,
528- {
529- value : 1024 * 1024 ,
530- label : 'MB' ,
531- } ,
532- {
533- value : 1024 * 1024 * 1024 ,
534- label : 'GB' ,
535- } ,
536- ] }
508+ options = { SIZE_UNITS }
509+ value = { {
510+ value : formState . logsSizeLimitUnit ,
511+ label : getSizeUnitLabel ( formState . logsSizeLimitUnit ) ,
512+ } }
537513 onChange = { ( value ) => {
538514 if ( value && isSingleValue ( value ) ) {
539515 formState . setLogsSizeLimitUnit ( value . value ) ;
@@ -562,19 +538,10 @@ const NewDebugBundleForm: FC<{
562538 minWidth : 150 ,
563539 } ) ,
564540 } }
565- options = { [
566- {
567- value : 1 ,
568- label : 'Seconds' ,
569- } ,
570- {
571- value : 60 ,
572- label : 'Minutes' ,
573- } ,
574- ] }
541+ options = { TIME_UNITS }
575542 value = { {
576543 value : formState . metricsIntervalUnit ,
577- label : formState . metricsIntervalUnit === 1 ? 'Seconds' : 'Minutes' ,
544+ label : getTimeUnitLabel ( formState . metricsIntervalUnit ) ,
578545 } }
579546 onChange = { ( value ) => {
580547 if ( value && isSingleValue ( value ) ) {
0 commit comments