@@ -345,6 +345,8 @@ def _create_widgets(self):
345
345
self ._create_advanced_options ()
346
346
# Save configuration section
347
347
self ._create_save_section ()
348
+ # Create section containers
349
+ self ._create_section_containers ()
348
350
# Action buttons
349
351
self .apply_btn = widgets .Button (
350
352
description = "Apply Configuration" ,
@@ -563,6 +565,25 @@ def _create_save_section(self):
563
565
)
564
566
self .save_btn .on_click (self ._on_save_config )
565
567
568
+ def _create_section_containers (self ):
569
+ """Create the main UI section containers."""
570
+ # Connection fields (dynamically shown/hidden)
571
+ self .connection_fields = widgets .VBox (
572
+ [
573
+ widgets .HTML ("<h5>Connection Settings</h5>" ),
574
+ self .host_field ,
575
+ widgets .HBox ([self .username_field , self .ssh_key_field ]),
576
+ self .port_field ,
577
+ ]
578
+ )
579
+ # Kubernetes fields
580
+ self .k8s_fields = widgets .VBox (
581
+ [
582
+ widgets .HTML ("<h5>Kubernetes Settings</h5>" ),
583
+ widgets .HBox ([self .k8s_namespace , self .k8s_image ]),
584
+ ]
585
+ )
586
+
566
587
def _validate_host (self , change ):
567
588
"""Validate host field input."""
568
589
value = change ["new" ]
@@ -573,36 +594,24 @@ def _validate_host(self, change):
573
594
self .host_field .layout .border = ""
574
595
575
596
def _on_cluster_type_change (self , change ):
576
- """Handle cluster type change to show/hide relevant fields ."""
597
+ """Handle cluster type change to show/hide relevant sections ."""
577
598
cluster_type = change ["new" ]
578
- # Update field visibility based on cluster type
599
+ # Update section visibility based on cluster type
579
600
if cluster_type == "local" :
580
- # Hide remote-specific fields
581
- self .host_field .layout .display = "none"
582
- self .username_field .layout .display = "none"
583
- self .ssh_key_field .layout .display = "none"
584
- self .port_field .layout .display = "none"
601
+ # Hide both remote-specific sections
602
+ self .connection_fields .layout .display = "none"
603
+ self .k8s_fields .layout .display = "none"
585
604
self .work_dir_field .layout .display = "none"
586
- self .k8s_namespace .layout .display = "none"
587
- self .k8s_image .layout .display = "none"
588
605
elif cluster_type == "kubernetes" :
589
- # Show Kubernetes-specific fields
590
- self .host_field .layout .display = ""
591
- self .username_field .layout .display = "none"
592
- self .ssh_key_field .layout .display = "none"
593
- self .port_field .layout .display = ""
606
+ # Show Kubernetes-specific fields, hide SSH connection fields
607
+ self .connection_fields .layout .display = "none"
608
+ self .k8s_fields .layout .display = ""
594
609
self .work_dir_field .layout .display = ""
595
- self .k8s_namespace .layout .display = ""
596
- self .k8s_image .layout .display = ""
597
610
else : # ssh, slurm, pbs, sge
598
- # Show SSH-based fields
599
- self .host_field .layout .display = ""
600
- self .username_field .layout .display = ""
601
- self .ssh_key_field .layout .display = ""
602
- self .port_field .layout .display = ""
611
+ # Show SSH-based connection fields, hide Kubernetes fields
612
+ self .connection_fields .layout .display = ""
613
+ self .k8s_fields .layout .display = "none"
603
614
self .work_dir_field .layout .display = ""
604
- self .k8s_namespace .layout .display = "none"
605
- self .k8s_image .layout .display = "none"
606
615
607
616
def _load_config_to_widgets (self , config_name : str ):
608
617
"""Load a configuration into the widgets."""
@@ -877,22 +886,6 @@ def display(self):
877
886
self .cluster_type ,
878
887
]
879
888
)
880
- # Connection fields (dynamically shown/hidden)
881
- connection_fields = widgets .VBox (
882
- [
883
- widgets .HTML ("<h5>Connection Settings</h5>" ),
884
- self .host_field ,
885
- widgets .HBox ([self .username_field , self .ssh_key_field ]),
886
- self .port_field ,
887
- ]
888
- )
889
- # Kubernetes fields
890
- k8s_fields = widgets .VBox (
891
- [
892
- widgets .HTML ("<h5>Kubernetes Settings</h5>" ),
893
- widgets .HBox ([self .k8s_namespace , self .k8s_image ]),
894
- ]
895
- )
896
889
# Resource fields
897
890
resource_fields = widgets .VBox (
898
891
[
@@ -921,8 +914,8 @@ def display(self):
921
914
config_section ,
922
915
widgets .HTML ("<hr>" ),
923
916
basic_fields ,
924
- connection_fields ,
925
- k8s_fields ,
917
+ self . connection_fields ,
918
+ self . k8s_fields ,
926
919
resource_fields ,
927
920
self .advanced_accordion ,
928
921
widgets .HTML ("<hr>" ),
0 commit comments