17
17
import { useEffect , useState } from 'react'
18
18
import { GroupBase } from 'react-select'
19
19
import { useParams } from 'react-router-dom'
20
- import ReactSelect from 'react-select'
21
20
import {
22
21
Progressing ,
23
22
DeleteDialog ,
@@ -34,16 +33,8 @@ import {
34
33
getSelectPickerOptionByValue ,
35
34
} from '@devtron-labs/devtron-fe-common-lib'
36
35
import Tippy from '@tippyjs/react'
37
- import {
38
- DropdownIndicator ,
39
- EnvFormatOptions ,
40
- formatHighlightedText ,
41
- getCommonSelectStyle ,
42
- GroupHeading ,
43
- Option ,
44
- } from '../../common/ReactSelect.utils'
45
36
import { ReactComponent as Error } from '../../../../assets/icons/ic-warning.svg'
46
- import { importComponentFromFELibrary , Select } from '../../../common'
37
+ import { importComponentFromFELibrary } from '../../../common'
47
38
import { ReactComponent as Close } from '../../assets/icons/ic-close.svg'
48
39
import { ReactComponent as EditIcon } from '../../../../assets/icons/ic-pencil.svg'
49
40
import { AUTO_GENERATE_GITOPS_REPO , GITOPS_REPO_REQUIRED , GITOPS_REPO_REQUIRED_FOR_ENV } from './constant'
@@ -76,7 +67,6 @@ import {
76
67
import { DeploymentAppTypeNameMapping , REQUIRED_FIELD_MSG } from '../../../../config/constantMessaging'
77
68
import { ReactComponent as ArgoCD } from '../../../../assets/icons/argo-cd-app.svg'
78
69
import { ReactComponent as Helm } from '../../../../assets/icons/helm-app.svg'
79
- import { envGroupStyle } from './ChartValuesView.utils'
80
70
import { DELETE_ACTION , repoType } from '../../../../config'
81
71
import UserGitRepo from '../../../gitOps/UserGitRepo'
82
72
import { getChartValuesFiltered } from '@Components/charts/charts.helper'
@@ -92,18 +82,17 @@ export const ChartEnvironmentSelector = ({
92
82
selectedEnvironment,
93
83
handleEnvironmentSelection,
94
84
environments,
95
- invalidaEnvironment ,
85
+ invalidEnvironment ,
96
86
isVirtualEnvironmentOnSelector,
97
87
isVirtualEnvironment,
98
88
} : ChartEnvironmentSelectorType ) : JSX . Element => {
99
- const singleOption = ( props ) => {
100
- return < EnvFormatOptions { ...props } environmentfieldName = "label" />
101
- }
102
89
103
90
const renderVirtualEnvironmentInfoText = ( ) : JSX . Element => {
104
91
if ( isVirtualEnvironmentOnSelector && VirtualEnvSelectionInfoText ) {
105
92
return < VirtualEnvSelectionInfoText />
106
93
}
94
+
95
+ return null
107
96
}
108
97
109
98
const renderVirtualTippy = ( ) : JSX . Element => {
@@ -117,10 +106,6 @@ export const ChartEnvironmentSelector = ({
117
106
}
118
107
}
119
108
120
- const handleFormatHighlightedText = ( opt , { inputValue } ) => {
121
- return formatHighlightedText ( opt , inputValue , 'label' )
122
- }
123
-
124
109
return ! isDeployChartView ? (
125
110
< div className = "chart-values__environment-container mb-12" >
126
111
< h2
@@ -143,26 +128,17 @@ export const ChartEnvironmentSelector = ({
143
128
</ div >
144
129
) : (
145
130
< div className = "form__row form__row--w-100 fw-4" >
146
- < span className = "form__label required-field" data-testid = "environment-name-heading" >
147
- Deploy to environment
148
- </ span >
149
- < ReactSelect
150
- components = { {
151
- IndicatorSeparator : null ,
152
- DropdownIndicator,
153
- SingleValue : singleOption ,
154
- GroupHeading,
155
- } }
156
- classNamePrefix = "values-environment-select"
131
+ < SelectPicker
132
+ label = "Deploy to environment"
133
+ inputId = "values-environment-select"
157
134
placeholder = "Select Environment"
158
135
value = { selectedEnvironment }
159
- styles = { envGroupStyle }
160
136
onChange = { handleEnvironmentSelection }
161
137
options = { environments }
162
- formatOptionLabel = { handleFormatHighlightedText }
138
+ required
139
+ error = { invalidEnvironment ? REQUIRED_FIELD_MSG : null }
140
+ helperText = { renderVirtualEnvironmentInfoText ( ) }
163
141
/>
164
- { invalidaEnvironment && renderValidationErrorLabel ( ) }
165
- { renderVirtualEnvironmentInfoText ( ) }
166
142
</ div >
167
143
)
168
144
}
@@ -476,65 +452,50 @@ export const ChartProjectSelector = ({
476
452
invalidProject,
477
453
} : ChartProjectSelectorType ) : JSX . Element => {
478
454
return (
479
- < label className = "form__row form__row--w-100 fw-4" >
480
- < span className = "form__label required-field" data-testid = "project-name-heading" >
481
- Project
482
- </ span >
483
- < ReactSelect
484
- components = { {
485
- IndicatorSeparator : null ,
486
- DropdownIndicator,
487
- Option,
488
- } }
455
+ < div className = "form__row form__row--w-100" >
456
+ < SelectPicker
457
+ label = "Project"
458
+ inputId = "select-chart-project"
489
459
placeholder = "Select Project"
490
- classNamePrefix = "select-chart-project"
491
460
value = { selectedProject }
492
- styles = { getCommonSelectStyle ( ) }
493
461
onChange = { handleProjectSelection }
494
462
options = { projects }
463
+ required
464
+ error = { invalidProject ? REQUIRED_FIELD_MSG : null }
495
465
/>
496
- { invalidProject && renderValidationErrorLabel ( ) }
497
- </ label >
466
+ </ div >
498
467
)
499
468
}
500
469
501
470
export const ChartVersionSelector = ( {
502
471
selectedVersion,
503
- chartVersionObj,
504
472
selectedVersionUpdatePage,
505
473
handleVersionSelection,
506
474
chartVersionsData,
507
475
} : ChartVersionSelectorType ) => {
476
+ const selectOptions = chartVersionsData . map ( chartVersion => ( {
477
+ value : chartVersion . id ,
478
+ label : chartVersion . version ,
479
+ } ) )
480
+
481
+ const selectedOption = selectOptions . find (
482
+ ( option ) => option . value === selectedVersionUpdatePage ?. id || option . value === selectedVersion ,
483
+ )
484
+
508
485
return (
509
486
< div className = "w-100 mb-12" >
510
- < span className = "form__label fs-13 fw-4 lh-20 cn-7" data-testid = "chart-version-heading" >
511
- Chart Version
512
- </ span >
513
- < Select
514
- tabIndex = { 4 }
515
- rootClassName = "select-button--default chart-values-selector"
516
- onChange = { ( event ) => {
517
- handleVersionSelection ( event . target . value , {
518
- id : event . target . value ,
519
- version : event . target . innerText ,
487
+ < SelectPicker < number , false >
488
+ label = "Chart Version"
489
+ inputId = "chart-values-selector"
490
+ options = { selectOptions }
491
+ onChange = { ( option ) =>
492
+ handleVersionSelection ( option . value , {
493
+ id : option . value ,
494
+ version : option . label as string ,
520
495
} )
521
- } }
522
- value = { selectedVersionUpdatePage ?. id || selectedVersion }
523
- dataTestId = "select-chart-version"
524
- >
525
- < Select . Button dataTestIdDropdown = "chart-version-of-preset" >
526
- { selectedVersionUpdatePage ?. version || chartVersionObj ?. version }
527
- </ Select . Button >
528
- { chartVersionsData . map ( ( _chartVersion , index ) => (
529
- < Select . Option
530
- key = { _chartVersion . id }
531
- value = { _chartVersion . id }
532
- dataTestIdMenuList = { `chart-select-${ index } ` }
533
- >
534
- { _chartVersion . version }
535
- </ Select . Option >
536
- ) ) }
537
- </ Select >
496
+ }
497
+ value = { selectedOption }
498
+ />
538
499
</ div >
539
500
)
540
501
}
@@ -588,7 +549,7 @@ export const ChartValuesSelector = ({
588
549
589
550
return (
590
551
< button
591
- className = "dc__transparent fs-13 lh-20 flex left dc__gap-4 cb-5 px-8 py-6 "
552
+ className = "dc__transparent fs-13 lh-20 flex left dc__gap-6 cb-5 px-12 py-4 "
592
553
onClick = { redirectToChartValues }
593
554
data-testid = "add-preset-values-button-dropdown"
594
555
>
0 commit comments