Skip to content

Commit

Permalink
refactor DistroConfigScreen.action_launch_new_option_modal, update sc…
Browse files Browse the repository at this point in the history
…reenshots everywhere
  • Loading branch information
jessebot committed Jan 12, 2024
1 parent 358aab9 commit c7d2f8a
Show file tree
Hide file tree
Showing 11 changed files with 1,440 additions and 1,438 deletions.
316 changes: 157 additions & 159 deletions docs/assets/images/screenshots/add_k3s_option_screen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
293 changes: 145 additions & 148 deletions docs/assets/images/screenshots/apps_screen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
292 changes: 147 additions & 145 deletions docs/assets/images/screenshots/distro_config_screen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
290 changes: 144 additions & 146 deletions docs/assets/images/screenshots/kind_config_screen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
286 changes: 142 additions & 144 deletions docs/assets/images/screenshots/kind_config_screen2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
319 changes: 159 additions & 160 deletions docs/assets/images/screenshots/modify_global_parameters_modal_screen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
317 changes: 158 additions & 159 deletions docs/assets/images/screenshots/new_app_modal_screen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
232 changes: 117 additions & 115 deletions docs/assets/images/screenshots/start_screen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
234 changes: 118 additions & 116 deletions docs/assets/images/screenshots/tui_config_screen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
228 changes: 115 additions & 113 deletions docs/assets/images/screenshots/tui_help_screen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 38 additions & 33 deletions smol_k8s_lab/tui/distro_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ def on_mount(self) -> None:

@on(Select.Changed)
def update_k8s_distro(self, event: Select.Changed) -> None:
"""
changed currently enabled kubernetes distro in the TUI
"""
distro = str(event.value)

# disable display on previous distro
Expand Down Expand Up @@ -190,50 +193,52 @@ def add_new_row(option: str):
Takes option (str) to add new row to the tui for the active tab of
current distro
"""
# if the distro is kind
if option and self.current_distro == 'kind':
# use tab for kind networking, which is the default tab
if self.query_one(TabbedContent).active == "kind-networking-tab":
kind_widget = self.query_one(KindNetworkingConfig)
# use tab for kubelet config
else:
kind_widget = self.get_widget_by_id(
f"kubelet-config-{self.current_distro}"
)
kind_widget.generate_row(option)

# if the distro is k3s OR k3d
elif option and self.current_distro.startswith('k3'):
# use tab for k3s yaml options, EXCEPT for kubelet config args
if self.query_one(TabbedContent).active == "k3s-yaml-tab":
k3s_widget = self.get_widget_by_id(f"{self.current_distro}-widget")
# use tab for k3s kubelet-args
else:
k3s_widget = self.get_widget_by_id(
f"kubelet-config-{self.current_distro}"
)
k3s_widget.generate_row(option)
distro = self.current_distro

if option:
# if the distro is kind
if distro == 'kind':
# use tab for kind networking, which is the default tab
tabbed_content = self.get_widget_by_id("kind-tabbed-content")
if tabbed_content.active == "kind-networking-tab":
widget = self.query_one(KindNetworkingConfig)

# if the distro is k3s OR k3d
elif distro.startswith('k3'):
tabbed_content = self.get_widget_by_id("k3s-tabbed-content")
# use tab for k3s yaml options, EXCEPT for kubelet config args
if tabbed_content.active == "k3s-yaml-tab":
widget = self.get_widget_by_id(f"{distro}-widget")

if "kubelet" in tabbed_content.active:
widget = self.get_widget_by_id(f"kubelet-config-{distro}")

widget.generate_row(option)

else:
return

if self.current_distro != 'kind':
if self.query_one(TabbedContent).active == "k3s-kubelet-tab":
if self.current_distro == 'kind':
kind_cfg = self.cfg['kind']
kind_tabbed_content = self.get_widget_by_id("kind-tabbed-content")
if kind_tabbed_content.active == "kind-networking-tab":
existing_keys = kind_cfg['networking_args'].keys()
trigger = "kind networking"
else:
existing_keys = kind_cfg['kubelet_extra_args'].keys()
trigger = "kind kubelet"

# if the current_distro is k3s or k3d
else:
k3s_tabbed_content = self.get_widget_by_id("k3s-tabbed-content")
if k3s_tabbed_content.active == "k3s-kubelet-tab":
existing_keys = self.cfg[self.current_distro]['k3s_yaml'].get(
"kubelet-arg", []
)
trigger = "k3s kubelet"
else:
existing_keys = self.cfg[self.current_distro]['k3s_yaml'].keys()
trigger = "k3s k3s_yaml"
else:
kind_cfg = self.cfg['kind']
if self.query_one(TabbedContent).active == "kind-networking-tab":
existing_keys = kind_cfg['networking_args'].keys()
trigger = "kind networking"
else:
existing_keys = kind_cfg['kubelet_extra_args'].keys()
trigger = "kind kubelet"

self.app.push_screen(NewOptionModal(trigger, existing_keys), add_new_row)

Expand Down

0 comments on commit c7d2f8a

Please sign in to comment.