Skip to content

Commit 6f0c12e

Browse files
authored
support fields with numbers in dynamic bc (#3507)
support fields that start with numbers in dynamic bc.
1 parent a0c708d commit 6f0c12e

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

apps/dashboard/app/javascript/dynamic_forms.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ function snakeCaseWords(str) {
100100
snakeCase += c.toLowerCase();
101101
} else if(c == c.toUpperCase() && isNaN(c)) {
102102
const nextIsUpper = (index + 1 !== str.length) ? str[index + 1] === str[index + 1].toUpperCase() : true;
103-
if (str[index-1] === '_' || nextIsUpper) {
103+
const nextIsNum = !isNaN(str[index + 1]);
104+
if ((str[index-1] === '_' || nextIsUpper) && !nextIsNum) {
104105
snakeCase += c.toLowerCase();
105106
} else {
106107
snakeCase += `_${c.toLowerCase()}`;

apps/dashboard/test/fixtures/sys_with_gateway_apps/bc_jupyter/form.yml

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ attributes:
3838
data-max-bc-num-slots-for-cluster-oakley: 8,
3939
data-min-gpus: 0,
4040
data-max-gpus: 0,
41+
data-hide-gpus-num-v100: true,
4142
]
4243
- [
4344
"broken",
@@ -46,6 +47,7 @@ attributes:
4647
data-maximum-bc-not-found-for-cluster-mistype: 30,
4748
data-min-gpus: 0,
4849
data-max-gpus: 0,
50+
data-hide-gpus-num-v100: true,
4951
]
5052
- [
5153
"gpu",
@@ -76,6 +78,7 @@ attributes:
7678

7779
data-min-gpus: 0,
7880
data-max-gpus: 0,
81+
data-hide-gpus-num-v100: true,
7982
]
8083
- [
8184
"advanced",
@@ -85,6 +88,7 @@ attributes:
8588

8689
data-min-gpus: 0,
8790
data-max-gpus: 0,
91+
data-hide-gpus-num-v100: true,
8892
]
8993
# this node type is the same for both clusters, so there's no 'for-cluster-...' clause
9094
- [
@@ -99,6 +103,7 @@ attributes:
99103

100104
data-min-gpus: 0,
101105
data-max-gpus: 0,
106+
data-hide-gpus-num-v100: true,
102107
]
103108
- [
104109
"other-40ish-option",
@@ -108,6 +113,7 @@ attributes:
108113

109114
data-min-gpus: 0,
110115
data-max-gpus: 0,
116+
data-hide-gpus-num-v100: true,
111117
]
112118
python_version:
113119
# let's set the account used by the python version for some reason
@@ -214,3 +220,4 @@ form:
214220
- auto_modules_intel
215221
- auto_modules_netcdf-serial
216222
- checkbox_test
223+
- gpus_num_v100

apps/dashboard/test/models/batch_connect/session_test.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,8 @@ def completed?
599599
'auto_modules_app_jupyter' => '',
600600
'auto_modules_intel' => '',
601601
'auto_modules_netcdf_serial' => '',
602-
'checkbox_test' => ''
602+
'checkbox_test' => '',
603+
'gpus_num_v100' => ''
603604
}
604605

605606
assert session.save(app: bc_jupyter_app, context: ctx), session.errors.each(&:to_s).to_s

apps/dashboard/test/system/batch_connect_test.rb

+12
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,18 @@ def make_bc_app(dir, form)
674674
assert_equal 'display: none;', find_option_style('classroom_size', 'large')
675675
end
676676

677+
test 'can hide fields with numbers and characters' do
678+
visit new_batch_connect_session_context_url('sys/bc_jupyter')
679+
680+
# defaults - gpus_num_v100 is hidden on page load.
681+
assert_equal('any', find_value('node_type'))
682+
refute(find("##{bc_ele_id('gpus_num_v100')}", visible: false).visible?)
683+
684+
# select gpu and now it's shown.
685+
select('gpu', from: bc_ele_id('node_type'))
686+
assert(find("##{bc_ele_id('gpus_num_v100')}").visible?)
687+
end
688+
677689
test 'options can check and uncheck' do
678690
visit new_batch_connect_session_context_url('sys/bc_jupyter')
679691

0 commit comments

Comments
 (0)