1717import { useEffect , useState } from 'react'
1818import { GroupBase } from 'react-select'
1919import { useParams } from 'react-router-dom'
20- import ReactSelect from 'react-select'
2120import {
2221 Progressing ,
2322 DeleteDialog ,
@@ -34,16 +33,8 @@ import {
3433 getSelectPickerOptionByValue ,
3534} from '@devtron-labs/devtron-fe-common-lib'
3635import Tippy from '@tippyjs/react'
37- import {
38- DropdownIndicator ,
39- EnvFormatOptions ,
40- formatHighlightedText ,
41- getCommonSelectStyle ,
42- GroupHeading ,
43- Option ,
44- } from '../../common/ReactSelect.utils'
4536import { ReactComponent as Error } from '../../../../assets/icons/ic-warning.svg'
46- import { importComponentFromFELibrary , Select } from '../../../common'
37+ import { importComponentFromFELibrary } from '../../../common'
4738import { ReactComponent as Close } from '../../assets/icons/ic-close.svg'
4839import { ReactComponent as EditIcon } from '../../../../assets/icons/ic-pencil.svg'
4940import { AUTO_GENERATE_GITOPS_REPO , GITOPS_REPO_REQUIRED , GITOPS_REPO_REQUIRED_FOR_ENV } from './constant'
@@ -76,7 +67,6 @@ import {
7667import { DeploymentAppTypeNameMapping , REQUIRED_FIELD_MSG } from '../../../../config/constantMessaging'
7768import { ReactComponent as ArgoCD } from '../../../../assets/icons/argo-cd-app.svg'
7869import { ReactComponent as Helm } from '../../../../assets/icons/helm-app.svg'
79- import { envGroupStyle } from './ChartValuesView.utils'
8070import { DELETE_ACTION , repoType } from '../../../../config'
8171import UserGitRepo from '../../../gitOps/UserGitRepo'
8272import { getChartValuesFiltered } from '@Components/charts/charts.helper'
@@ -92,18 +82,17 @@ export const ChartEnvironmentSelector = ({
9282 selectedEnvironment,
9383 handleEnvironmentSelection,
9484 environments,
95- invalidaEnvironment ,
85+ invalidEnvironment ,
9686 isVirtualEnvironmentOnSelector,
9787 isVirtualEnvironment,
9888} : ChartEnvironmentSelectorType ) : JSX . Element => {
99- const singleOption = ( props ) => {
100- return < EnvFormatOptions { ...props } environmentfieldName = "label" />
101- }
10289
10390 const renderVirtualEnvironmentInfoText = ( ) : JSX . Element => {
10491 if ( isVirtualEnvironmentOnSelector && VirtualEnvSelectionInfoText ) {
10592 return < VirtualEnvSelectionInfoText />
10693 }
94+
95+ return null
10796 }
10897
10998 const renderVirtualTippy = ( ) : JSX . Element => {
@@ -117,10 +106,6 @@ export const ChartEnvironmentSelector = ({
117106 }
118107 }
119108
120- const handleFormatHighlightedText = ( opt , { inputValue } ) => {
121- return formatHighlightedText ( opt , inputValue , 'label' )
122- }
123-
124109 return ! isDeployChartView ? (
125110 < div className = "chart-values__environment-container mb-12" >
126111 < h2
@@ -143,26 +128,17 @@ export const ChartEnvironmentSelector = ({
143128 </ div >
144129 ) : (
145130 < 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"
157134 placeholder = "Select Environment"
158135 value = { selectedEnvironment }
159- styles = { envGroupStyle }
160136 onChange = { handleEnvironmentSelection }
161137 options = { environments }
162- formatOptionLabel = { handleFormatHighlightedText }
138+ required
139+ error = { invalidEnvironment ? REQUIRED_FIELD_MSG : null }
140+ helperText = { renderVirtualEnvironmentInfoText ( ) }
163141 />
164- { invalidaEnvironment && renderValidationErrorLabel ( ) }
165- { renderVirtualEnvironmentInfoText ( ) }
166142 </ div >
167143 )
168144}
@@ -476,65 +452,50 @@ export const ChartProjectSelector = ({
476452 invalidProject,
477453} : ChartProjectSelectorType ) : JSX . Element => {
478454 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"
489459 placeholder = "Select Project"
490- classNamePrefix = "select-chart-project"
491460 value = { selectedProject }
492- styles = { getCommonSelectStyle ( ) }
493461 onChange = { handleProjectSelection }
494462 options = { projects }
463+ required
464+ error = { invalidProject ? REQUIRED_FIELD_MSG : null }
495465 />
496- { invalidProject && renderValidationErrorLabel ( ) }
497- </ label >
466+ </ div >
498467 )
499468}
500469
501470export const ChartVersionSelector = ( {
502471 selectedVersion,
503- chartVersionObj,
504472 selectedVersionUpdatePage,
505473 handleVersionSelection,
506474 chartVersionsData,
507475} : 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+
508485 return (
509486 < 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 ,
520495 } )
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+ />
538499 </ div >
539500 )
540501}
@@ -588,7 +549,7 @@ export const ChartValuesSelector = ({
588549
589550 return (
590551 < 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 "
592553 onClick = { redirectToChartValues }
593554 data-testid = "add-preset-values-button-dropdown"
594555 >
0 commit comments