16
16
17
17
import { useEffect , useState } from 'react'
18
18
import { components } from 'react-select'
19
- import { CIBuildType , ComponentSizeType , CustomInput , InfoIconTippy , SelectPicker } from '@devtron-labs/devtron-fe-common-lib'
19
+ import { CIBuildType , ComponentSizeType , CustomInput , InfoIconTippy , SelectPicker , stopPropagation } from '@devtron-labs/devtron-fe-common-lib'
20
+ import {
21
+ DropdownIndicator ,
22
+ getCommonSelectStyle ,
23
+ getCustomOptionSelectionStyle ,
24
+ Option ,
25
+ } from '../v2/common/ReactSelect.utils'
20
26
import { ReactComponent as GitLab } from '../../assets/icons/git/gitlab.svg'
21
27
import { ReactComponent as Git } from '../../assets/icons/git/git.svg'
22
28
import { ReactComponent as GitHub } from '../../assets/icons/git/github.svg'
@@ -41,6 +47,7 @@ import {
41
47
VERSION_DETECT_OPTION ,
42
48
} from './ciConfigConstant'
43
49
import { getSelectStartIcon } from './utils'
50
+ import CreatableSelect from 'react-select/creatable'
44
51
45
52
export const renderOptionIcon = ( option : string ) => {
46
53
if ( ! option ) {
@@ -70,6 +77,47 @@ const menuListComponent = (props): JSX.Element => {
70
77
)
71
78
}
72
79
80
+
81
+ export const repositoryOption = ( props ) : JSX . Element => {
82
+ props . selectProps . styles . option = getCustomOptionSelectionStyle ( )
83
+ return (
84
+ < components . Option { ...props } >
85
+ { props . data . url && renderOptionIcon ( props . data . url ) }
86
+ { props . label }
87
+ </ components . Option >
88
+ )
89
+ }
90
+
91
+ export const releaseTagOption = ( props ) : JSX . Element => {
92
+ props . selectProps . styles . option = getCustomOptionSelectionStyle ( )
93
+ return (
94
+ < components . Option { ...props } onClick = { stopPropagation } >
95
+ { props . value }
96
+ </ components . Option >
97
+ )
98
+ }
99
+
100
+ export const checkoutPathOption = ( props ) : JSX . Element => {
101
+ props . selectProps . styles . option = getCustomOptionSelectionStyle ( )
102
+ return < components . Option { ...props } > { props . value } </ components . Option >
103
+ }
104
+ export const repositoryControls = ( props ) : JSX . Element => {
105
+ let value = ''
106
+ if ( props . hasValue ) {
107
+ value = props . getValue ( ) [ 0 ] . url
108
+ }
109
+ const showGit = value && ! value . includes ( 'github' ) && ! value . includes ( 'gitlab' ) && ! value . includes ( 'bitbucket' )
110
+ return (
111
+ < components . Control { ...props } >
112
+ { value . includes ( 'github' ) && < GitHub className = "icon-dim-20 ml-10" /> }
113
+ { value . includes ( 'gitlab' ) && < GitLab className = "icon-dim-20 ml-10" /> }
114
+ { value . includes ( 'bitbucket' ) && < BitBucket className = "icon-dim-20 ml-10" /> }
115
+ { showGit && < Git className = "icon-dim-20 ml-10" /> }
116
+ { props . children }
117
+ </ components . Control >
118
+ )
119
+ }
120
+
73
121
const BuildContextLabel = ( ) => {
74
122
return (
75
123
< label htmlFor = "" className = "form__label flexbox-imp flex-align-center" >
@@ -454,14 +502,7 @@ export default function CIBuildpackBuildOptions({
454
502
setBuildEnvArgs ( _buildEnvArgs )
455
503
}
456
504
457
- const formatOptionLabel = ( option : VersionsOptionType ) => {
458
- return (
459
- < div className = "flex left column w-100 dc__ellipsis-right" >
460
- < span > { option . label } </ span >
461
- { option . infoText && < small className = "cn-6" > { option . infoText } </ small > }
462
- </ div >
463
- )
464
- }
505
+ const formatCreateLabel = ( inputValue : string ) => `Use '${ inputValue } '`
465
506
466
507
const projectPathVal = readOnly ? ciBuildConfig . buildPackConfig ?. projectPath : projectPath . value
467
508
@@ -617,17 +658,25 @@ export default function CIBuildpackBuildOptions({
617
658
< BuilderTippy />
618
659
</ label >
619
660
620
- < SelectPicker
621
- inputId = "build-pack-builder"
622
- isCreatableSingleSelect
661
+ < CreatableSelect
623
662
classNamePrefix = "build-pack-select-builder-dropdown"
624
663
placeholder = { CI_BUILDPACK_OPTION_TEXTS . BuilderTippyContent . selectBuilder }
664
+ className = "m-0"
665
+ tabIndex = { 3 }
625
666
isLoading = { ! builderLanguageSupportMap ?. [ buildersAndFrameworks . selectedLanguage ?. value ] }
626
667
options = {
627
668
builderLanguageSupportMap ?. [ buildersAndFrameworks . selectedLanguage ?. value ]
628
669
?. BuilderLanguageMetadata
629
670
}
630
671
value = { buildersAndFrameworks . selectedBuilder }
672
+ formatCreateLabel = { formatCreateLabel }
673
+ styles = { getCommonSelectStyle ( BUILDER_SELECT_STYLES ) }
674
+ components = { {
675
+ IndicatorSeparator : null ,
676
+ DropdownIndicator,
677
+ Option,
678
+ MenuList : menuListComponent ,
679
+ } }
631
680
onChange = { handleBuilderSelection }
632
681
/>
633
682
</ div >
0 commit comments