4
4
Button ,
5
5
Form , FormGroup ,
6
6
TextInput , NumberInput ,
7
- ActionGroup , Checkbox
7
+ Checkbox ,
8
+ Tab , Tabs , TabTitleText ,
9
+ TabContentBody
8
10
} from '@patternfly/react-core' ;
9
11
10
12
import "./Configuration.scss" ;
@@ -14,6 +16,7 @@ export default class Configuration extends React.Component {
14
16
constructor ( props ) {
15
17
super ( props ) ;
16
18
this . state = {
19
+ activeTabKey : 0 ,
17
20
preset : "unknown" ,
18
21
cpus : 0 ,
19
22
memory : 0 ,
@@ -28,16 +31,33 @@ export default class Configuration extends React.Component {
28
31
29
32
this . configurationSaveClicked = this . configurationSaveClicked . bind ( this ) ;
30
33
this . configurationResetClicked = this . configurationResetClicked . bind ( this ) ;
34
+ this . handleTabClick = this . handleTabClick . bind ( this ) ;
35
+
36
+ this . updateClampedValue = this . updateClampedValue . bind ( this ) ;
31
37
this . updateValue = this . updateValue . bind ( this ) ;
32
38
}
33
39
40
+ // Toggle currently active tab
41
+ handleTabClick ( event , tabIndex ) {
42
+ this . setState ( {
43
+ activeTabKey : tabIndex
44
+ } ) ;
45
+ } ;
46
+
34
47
updateValues ( values ) {
35
48
const self = this ; // make sure 'self' references to this
36
49
Object . entries ( values ) . forEach ( function ( value ) {
37
50
self . updateValue ( value [ 0 ] , value [ 1 ] ) ;
38
51
} ) ;
39
52
}
40
53
54
+ updateClampedValue ( key , min , value ) {
55
+ if ( value < min ) {
56
+ value = min ;
57
+ }
58
+ this . updateValue ( key , value ) ;
59
+ }
60
+
41
61
updateValue ( key , value ) {
42
62
if ( this . state [ "" + key ] !== undefined ) {
43
63
const newState = { [ "" + key ] : value } ;
@@ -54,115 +74,141 @@ export default class Configuration extends React.Component {
54
74
}
55
75
56
76
render ( ) {
77
+ const { activeTabKey, isBox } = this . state ;
78
+
79
+ const tabStyle = {
80
+ height : this . props . height ,
81
+ }
82
+
83
+ const proxyInputStyle = {
84
+ width : this . props . textInputWidth
85
+ }
86
+
57
87
return (
58
88
< div >
59
- < Form isHorizontal >
60
-
61
- < FormGroup fieldId = 'settings-cpu' label = "CPU" >
62
- < NumberInput id = 'settings-cpu'
63
- className = "cpus"
64
- inputName = "cpus"
65
- minusBtnAriaLabel = "minus"
66
- plusBtnAriaLabel = "plus"
67
- unit = ""
68
- min = "1"
69
- value = { this . state . cpus }
70
- widthChars = { 5 }
71
- onPlus = { event => this . updateValue ( 'cpus' , this . state . cpus + 1 ) }
72
- onMinus = { event => this . updateValue ( 'cpus' , this . state . cpus - 1 ) }
73
- onChange = { value => this . state [ 'cpus' ] }
74
- />
75
- </ FormGroup >
76
- < FormGroup fieldId = 'settings-memory' label = "Memory" >
77
- < NumberInput id = 'settings-memory'
78
- className = "memory"
79
- inputName = "memory"
80
- minusBtnAriaLabel = "minus"
81
- plusBtnAriaLabel = "plus"
82
- unit = "MiB"
83
- min = "8192"
84
- value = { this . state . memory }
85
- widthChars = { 5 }
86
- onPlus = { event => this . updateValue ( 'memory' , this . state . memory + 512 ) }
87
- onMinus = { event => this . updateValue ( 'memory' , this . state . memory - 512 ) }
88
- onChange = { value => this . state [ 'memory' ] }
89
- />
90
- </ FormGroup >
91
- < FormGroup fieldId = 'settings-disksize' label = "Disk size" >
92
- < NumberInput id = 'settings-disksize'
93
- className = "disk-size"
94
- inputName = "disk-size"
95
- minusBtnAriaLabel = "minus"
96
- plusBtnAriaLabel = "plus"
97
- unit = "GB"
98
- min = "20"
99
- value = { this . state [ "disk-size" ] }
100
- widthChars = { 5 }
101
- onPlus = { event => this . updateValue ( 'disk-size' , this . state [ "disk-size" ] + 1 ) }
102
- onMinus = { event => this . updateValue ( 'disk-size' , this . state [ "disk-size" ] - 1 ) }
103
- onChange = { value => this . state [ 'disk-size' ] }
104
- />
105
- </ FormGroup >
106
-
107
-
108
-
109
- < FormGroup fieldId = 'settings-preset' label = "Preset" >
110
- < PresetSelection id = "settings-preset" isCompact
111
- className = "preset"
112
- inputName = "preset"
113
- value = { this . state [ "preset" ] }
114
- onChange = { value => this . updateValue ( 'preset' , value ) } />
115
- </ FormGroup >
116
-
117
-
118
-
119
- < FormGroup fieldId = 'config-telemetry' label = "Telemetry" >
120
- < Checkbox id = 'config-consentTelemetry'
121
- className = "consentTelemetry"
122
- isChecked = { this . state [ "consent-telemetry" ] === "yes" ? true : false }
123
- onChange = { value => this . updateValue ( 'consent-telemetry' , value === true ? "yes" : "no" ) }
124
- label = "Report telemetry to Red Hat"
125
- description = "Consent to allow basic information about the system and cluster to be collected for development and debugging purposes" />
126
- </ FormGroup >
127
-
89
+ < Tabs activeKey = { activeTabKey } onSelect = { this . handleTabClick } isBox = { true } >
90
+
91
+ < Tab eventKey = { 0 } title = { < TabTitleText > Basic</ TabTitleText > } >
92
+ < TabContentBody style = { tabStyle } hasPadding >
93
+ < Form isHorizontal >
94
+ < FormGroup fieldId = 'settings-cpu' label = "CPU" >
95
+ < NumberInput id = 'settings-cpu'
96
+ className = "cpus"
97
+ inputName = "cpus"
98
+ minusBtnAriaLabel = "minus"
99
+ plusBtnAriaLabel = "plus"
100
+ unit = ""
101
+ min = "1"
102
+ value = { this . state . cpus }
103
+ widthChars = { 5 }
104
+ onPlus = { event => this . updateValue ( 'cpus' , this . state . cpus + 1 ) }
105
+ onMinus = { event => this . updateClampedValue ( 'cpus' , 1 , this . state . cpus - 1 ) }
106
+ onChange = { value => this . state [ 'cpus' ] }
107
+ />
108
+ </ FormGroup >
109
+ < FormGroup fieldId = 'settings-memory' label = "Memory" >
110
+ < NumberInput id = 'settings-memory'
111
+ className = "memory"
112
+ inputName = "memory"
113
+ minusBtnAriaLabel = "minus"
114
+ plusBtnAriaLabel = "plus"
115
+ unit = "MiB"
116
+ min = "8192"
117
+ value = { this . state . memory }
118
+ widthChars = { 5 }
119
+ onPlus = { event => this . updateValue ( 'memory' , this . state . memory + 512 ) }
120
+ onMinus = { event => this . updateClampedValue ( 'memory' , 2048 , this . state . memory - 512 ) }
121
+ onChange = { value => this . state [ 'memory' ] }
122
+ />
123
+ </ FormGroup >
124
+ < FormGroup fieldId = 'settings-disksize' label = "Disk size" >
125
+ < NumberInput id = 'settings-disksize'
126
+ className = "disk-size"
127
+ inputName = "disk-size"
128
+ minusBtnAriaLabel = "minus"
129
+ plusBtnAriaLabel = "plus"
130
+ unit = "GB"
131
+ min = "20"
132
+ value = { this . state [ "disk-size" ] }
133
+ widthChars = { 5 }
134
+ onPlus = { event => this . updateValue ( 'disk-size' , this . state [ "disk-size" ] + 1 ) }
135
+ onMinus = { event => this . updateClampedValue ( 'disk-size' , 10 , this . state [ "disk-size" ] - 1 ) }
136
+ onChange = { value => this . state [ 'disk-size' ] }
137
+ />
138
+ </ FormGroup >
139
+ < FormGroup fieldId = 'settings-preset' label = "Preset" >
140
+ < PresetSelection id = "settings-preset" isCompact
141
+ className = "preset"
142
+ inputName = "preset"
143
+ value = { this . state [ "preset" ] }
144
+ onChange = { value => this . updateValue ( 'preset' , value ) } />
145
+ </ FormGroup >
146
+ </ Form >
147
+ </ TabContentBody >
148
+ </ Tab >
149
+
150
+ < Tab eventKey = { 1 } title = { < TabTitleText > Other</ TabTitleText > } >
151
+ < TabContentBody style = { tabStyle } hasPadding >
152
+ < Form isHorizontal >
153
+ < FormGroup fieldId = 'config-telemetry' label = "Telemetry" >
154
+ < Checkbox id = 'config-consentTelemetry'
155
+ className = "consentTelemetry"
156
+ isChecked = { this . state [ "consent-telemetry" ] === "yes" ? true : false }
157
+ onChange = { value => this . updateValue ( 'consent-telemetry' , value === true ? "yes" : "no" ) }
158
+ label = "Report telemetry to Red Hat"
159
+ description = "Consent to allow basic information about the system and cluster to be collected for development and debugging purposes" />
160
+ </ FormGroup >
161
+ </ Form >
162
+ </ TabContentBody >
163
+ </ Tab >
128
164
129
-
130
- < FormGroup fieldId = 'config-proxy' label = "HTTP proxy" >
131
- < TextInput id = 'config-http-proxy'
132
- className = "proxy"
133
- value = { this . state [ "http-proxy" ] }
134
- onChange = { value => this . updateValue ( 'http-proxy' , value ) } />
135
- </ FormGroup >
136
- < FormGroup fieldId = 'config-proxy' label = "HTTPS proxy" >
137
- < TextInput id = 'config-https-proxy'
138
- className = "proxy"
139
- value = { this . state [ "https-proxy" ] }
140
- onChange = { value => this . updateValue ( 'https-proxy' , value ) } />
141
- </ FormGroup >
142
- < FormGroup fieldId = 'config-proxy' label = "No proxy" >
143
- < TextInput id = 'config-no-proxy'
144
- className = "proxy"
145
- value = { this . state [ "no-proxy" ] }
146
- onChange = { value => this . updateValue ( 'no-proxy' , value ) } />
147
- </ FormGroup >
148
- < FormGroup fieldId = 'config-proxy' label = "Proxy CA file" >
149
- < TextInput id = 'config-proxy-ca-file'
150
- className = "proxy"
151
- value = { this . state [ "proxy-ca-file" ] }
152
- onChange = { value => this . updateValue ( 'proxy-ca-file' , value ) } />
153
- </ FormGroup >
154
-
155
-
156
- < ActionGroup >
157
- < Button variant = "primary" onClick = { this . configurationSaveClicked } > Save</ Button >
158
- < Button variant = "link" onClick = { this . configurationResetClicked } > Reset</ Button >
159
- </ ActionGroup >
160
-
161
-
162
- < FormGroup fieldId = 'config-pullsecret' label = "Pullsecret" >
163
- < Button onClick = { this . props . onPullsecretChangeClicked } variant = "primary" > Change</ Button >
164
- </ FormGroup >
165
- </ Form >
165
+ < Tab eventKey = { 2 } title = { < TabTitleText > Proxy</ TabTitleText > } >
166
+ < TabContentBody style = { tabStyle } hasPadding >
167
+ < Form isHorizontal >
168
+ < FormGroup fieldId = 'config-proxy' label = "HTTP proxy" >
169
+ < TextInput style = { proxyInputStyle } id = 'config-http-proxy'
170
+ className = "proxy"
171
+ value = { this . state [ "http-proxy" ] }
172
+ onChange = { value => this . updateValue ( 'http-proxy' , value ) } />
173
+ </ FormGroup >
174
+ < FormGroup fieldId = 'config-proxy' label = "HTTPS proxy" >
175
+ < TextInput style = { proxyInputStyle } id = 'config-https-proxy'
176
+ className = "proxy"
177
+ value = { this . state [ "https-proxy" ] }
178
+ onChange = { value => this . updateValue ( 'https-proxy' , value ) } />
179
+ </ FormGroup >
180
+ < FormGroup fieldId = 'config-proxy' label = "No proxy" >
181
+ < TextInput style = { proxyInputStyle } id = 'config-no-proxy'
182
+ className = "proxy"
183
+ value = { this . state [ "no-proxy" ] }
184
+ onChange = { value => this . updateValue ( 'no-proxy' , value ) } />
185
+ </ FormGroup >
186
+ < FormGroup fieldId = 'config-proxy' label = "Proxy CA file" >
187
+ < TextInput style = { proxyInputStyle } id = 'config-proxy-ca-file'
188
+ className = "proxy"
189
+ value = { this . state [ "proxy-ca-file" ] }
190
+ onChange = { value => this . updateValue ( 'proxy-ca-file' , value ) } />
191
+ </ FormGroup >
192
+ </ Form >
193
+ </ TabContentBody >
194
+ </ Tab >
195
+
196
+ < Tab eventKey = { 3 } title = { < TabTitleText > OpenShift</ TabTitleText > } isDisabled = { this . state . preset !== "openshift" } >
197
+ < TabContentBody style = { tabStyle } hasPadding >
198
+ < Form isHorizontal >
199
+ < FormGroup fieldId = 'config-pullsecret' label = "Pullsecret" >
200
+ < Button onClick = { this . props . onPullsecretChangeClicked } variant = "primary" > Change</ Button >
201
+ </ FormGroup >
202
+ </ Form >
203
+ </ TabContentBody >
204
+ </ Tab >
205
+
206
+ </ Tabs >
207
+
208
+ < div style = { { textAlign :"right" } } >
209
+ < Button variant = "primary" onClick = { this . configurationSaveClicked } > Save</ Button >
210
+ < Button variant = "link" onClick = { this . configurationResetClicked } > Reset</ Button >
211
+ </ div >
166
212
</ div >
167
213
) ;
168
214
}
@@ -172,5 +218,12 @@ Configuration.propTypes = {
172
218
onValueChanged : PropTypes . func ,
173
219
onSaveClicked : PropTypes . func ,
174
220
onResetClicked : PropTypes . func ,
175
- onPullsecretChangeClicked : PropTypes . func
221
+ onPullsecretChangeClicked : PropTypes . func ,
222
+ height : PropTypes . string ,
223
+ textInputWidth : PropTypes . string
176
224
} ;
225
+
226
+ Configuration . defaultProps = {
227
+ height : "300px" ,
228
+ textInputWidth : "320px"
229
+ } ;
0 commit comments