1
- import React , { useEffect , useState } from 'react'
1
+ // Disabling for ReactSelect
2
+ /* eslint-disable jsx-a11y/label-has-associated-control */
3
+ import React , { FunctionComponent , useEffect , useState } from 'react'
2
4
import ReactSelect from 'react-select'
3
5
import { CustomInput , OptionType , TippyCustomized , TippyTheme } from '@devtron-labs/devtron-fe-common-lib'
4
6
import { checkoutPathOption , renderOptionIcon , repositoryControls , repositoryOption } from './CIBuildpackBuildOptions'
@@ -9,7 +11,7 @@ import { ReactComponent as QuestionFilled } from '../../assets/icons/ic-help.svg
9
11
import { ReactComponent as Question } from '../../assets/icons/ic-help-outline.svg'
10
12
import { RootBuildContext } from './ciConfigConstant'
11
13
12
- function getBuildContextAdditionalContent ( ) {
14
+ const getBuildContextAdditionalContent = ( ) => {
13
15
return (
14
16
< div className = "p-12 fs-13" >
15
17
To build all files from the root, use (.) as the build context, or set build context by referring a
@@ -22,7 +24,7 @@ function getBuildContextAdditionalContent() {
22
24
)
23
25
}
24
26
25
- function InfoCard ( ) {
27
+ const InfoCard : FunctionComponent = ( ) => {
26
28
return (
27
29
< div className = "flex row ml-0" >
28
30
< TippyCustomized
@@ -46,7 +48,7 @@ function InfoCard() {
46
48
)
47
49
}
48
50
49
- export default function BuildContext ( {
51
+ const BuildContext : FunctionComponent < BuildContextProps > = ( {
50
52
readOnly,
51
53
isDefaultBuildContext,
52
54
configOverrideView,
@@ -63,7 +65,7 @@ export default function BuildContext({
63
65
setCurrentCIBuildConfig,
64
66
currentBuildContextGitMaterial,
65
67
readOnlyBuildContextPath,
66
- } : BuildContextProps ) {
68
+ } ) => {
67
69
const [ isCollapsed , setIsCollapsed ] = useState < boolean > ( ! isDefaultBuildContext )
68
70
69
71
const useRootBuildContextFlag = currentCIBuildConfig ?. useRootBuildContext
@@ -75,14 +77,14 @@ export default function BuildContext({
75
77
const [ checkoutPathOptions , setCheckoutPathOptions ] = useState < OptionType [ ] > ( checkoutPathArray )
76
78
77
79
useEffect ( ( ) => {
78
- const checkoutPathArray = [ { label : RootBuildContext , value : RootBuildContext } ]
80
+ const _checkoutPathArray = [ { label : RootBuildContext , value : RootBuildContext } ]
79
81
if ( selectedBuildContextGitMaterial ?. checkoutPath !== RootBuildContext ) {
80
- checkoutPathArray . push ( {
82
+ _checkoutPathArray . push ( {
81
83
label : selectedBuildContextGitMaterial ?. checkoutPath ,
82
84
value : selectedBuildContextGitMaterial ?. checkoutPath ,
83
85
} )
84
86
}
85
- setCheckoutPathOptions ( checkoutPathArray )
87
+ setCheckoutPathOptions ( _checkoutPathArray )
86
88
} , [ selectedBuildContextGitMaterial ] )
87
89
88
90
const toggleCollapse = ( ) => {
@@ -91,13 +93,14 @@ export default function BuildContext({
91
93
92
94
const getSelectedBuildContextGitMaterial = ( ) => selectedBuildContextGitMaterial ?? currentMaterial
93
95
94
- const handleBuildContextPathChange = ( selectedBuildContextGitMaterial ) : void => {
95
- setSelectedBuildContextGitMaterial ( selectedBuildContextGitMaterial )
96
+ const handleBuildContextPathChange = ( _selectedBuildContextGitMaterial ) : void => {
97
+ setSelectedBuildContextGitMaterial ( _selectedBuildContextGitMaterial )
96
98
// Don't know how and why we are directly setting state.
97
- formState . repository . value = selectedBuildContextGitMaterial . name
99
+ // eslint-disable-next-line no-param-reassign
100
+ formState . repository . value = _selectedBuildContextGitMaterial . name
98
101
setCurrentCIBuildConfig ( {
99
102
...currentCIBuildConfig ,
100
- buildContextGitMaterialId : selectedBuildContextGitMaterial . id ,
103
+ buildContextGitMaterialId : _selectedBuildContextGitMaterial . id ,
101
104
} )
102
105
}
103
106
@@ -109,9 +112,9 @@ export default function BuildContext({
109
112
} )
110
113
}
111
114
112
- const getCheckoutPathValue = ( useRootBuildContextFlag : boolean ) : OptionType => {
115
+ const getCheckoutPathValue = ( _useRootBuildContextFlag : boolean ) : OptionType => {
113
116
const path = getSelectedBuildContextGitMaterial ( ) ?. checkoutPath
114
- const val = useRootBuildContextFlag ? RootBuildContext : path
117
+ const val = _useRootBuildContextFlag ? RootBuildContext : path
115
118
116
119
return { label : val , value : val }
117
120
}
@@ -125,7 +128,7 @@ export default function BuildContext({
125
128
return (
126
129
< div className = "form-row__docker" >
127
130
< div className = { `form__field ${ configOverrideView ? 'mb-0-imp' : '' } ` } >
128
- < label className = "form__label" > Repository containing build context</ label >
131
+ < span className = "form__label" > Repository containing build context</ span >
129
132
130
133
< div className = "flex left" >
131
134
{ currentBuildContextGitMaterial ?. url && renderOptionIcon ( currentBuildContextGitMaterial . url ) }
@@ -134,13 +137,11 @@ export default function BuildContext({
134
137
</ span >
135
138
</ div >
136
139
137
- { repositoryError && < label className = "form__error" > { repositoryError } </ label > }
140
+ { repositoryError && < span className = "form__error" > { repositoryError } </ span > }
138
141
</ div >
139
142
140
143
< div className = { `form__field ${ configOverrideView ? 'mb-0-imp' : '' } ` } >
141
- < label htmlFor = "" className = "form__label" >
142
- Build Context (Relative)
143
- </ label >
144
+ < span className = "form__label" > Build Context (Relative)</ span >
144
145
145
146
< span className = "fs-14 fw-4 lh-20 cn-9" > { readOnlyBuildContextPath } </ span >
146
147
</ div >
@@ -159,7 +160,7 @@ export default function BuildContext({
159
160
< Dropdown
160
161
className = "icon-dim-26 rotate"
161
162
data-testid = "set-build-context-button"
162
- style = { { [ '--rotateBy' as any ] : isCollapsed ? '360deg' : '270deg' } }
163
+ style = { { [ '--rotateBy' as string ] : isCollapsed ? '360deg' : '270deg' } }
163
164
/>
164
165
Set Build context
165
166
</ button >
@@ -175,7 +176,6 @@ export default function BuildContext({
175
176
< ReactSelect
176
177
className = "m-0"
177
178
classNamePrefix = "build-config__select-repository-containing-build-context"
178
- tabIndex = { 3 }
179
179
isMulti = { false }
180
180
isClearable = { false }
181
181
options = { sourceConfig . material }
@@ -210,7 +210,6 @@ export default function BuildContext({
210
210
< ReactSelect
211
211
className = "m-0 br-0"
212
212
classNamePrefix = "build-config__select-checkout-path-for-build-context"
213
- tabIndex = { 4 }
214
213
isMulti = { false }
215
214
isClearable = { false }
216
215
isSearchable = { false }
@@ -227,7 +226,6 @@ export default function BuildContext({
227
226
/>
228
227
229
228
< CustomInput
230
- tabIndex = { 4 }
231
229
type = "text"
232
230
rootClassName = "file-name"
233
231
data-testid = "build-context-path-text-box"
@@ -244,3 +242,5 @@ export default function BuildContext({
244
242
</ >
245
243
)
246
244
}
245
+
246
+ export default BuildContext
0 commit comments