Skip to content

Commit

Permalink
clean up k3s/k3d borders for last tui block
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebot committed Jan 11, 2024
1 parent b497b1b commit 1d61edc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
3 changes: 0 additions & 3 deletions smol_k8s_lab/tui/css/k3s.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ $navy: rgb(35,35,54);
.k3s-config-container {
align: center middle;
background: rgb(35,35,54) 50%;
border: round $cornflower;
border-title-color: $sky_blue;
border-subtitle-color: $lavender;
link-background-hover: $navy;
link-color-hover: $orange;
padding: 2;
Expand Down
29 changes: 29 additions & 0 deletions smol_k8s_lab/tui/distro_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,32 @@ def compose(self) -> ComposeResult:
# kubelet config section for kind only
kubelet_args = self.metadata['k3s_yaml'].get('kubelet-args', '')
yield KubeletConfig('k3s', kubelet_args)

def on_mount(self) -> None:
"""
screen and box border styling
"""
# update tabbed content box
tabbed_content = self.query_one(TabbedContent)

tabbed_content.border_title = (
"[i]Add extra[/] options for the [#C1FF87]k3s[/] install script"
)

subtitle = (
"[b][@click=screen.launch_new_option_modal()] ➕ k3s option[/][/]"
)

tabbed_content.border_subtitle = subtitle

for tab in self.query("Tab"):
tab.add_class('header-tab')

def action_show_tab(self, tab: str) -> None:
"""Switch to a new tab."""
self.get_child_by_type(TabbedContent).active = tab

@on(TabbedContent.TabActivated)
def speak_when_tab_selected(self, event: TabbedContent.TabActivated) -> None:
if self.app.speak_on_focus:
self.app.action_say(f"Selected tab is {event.tab.id}")
9 changes: 0 additions & 9 deletions smol_k8s_lab/tui/distro_widgets/k3s_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,6 @@ def on_mount(self) -> None:
"""
box border styling
"""
# k3s arg config styling
k3s_title = ("[i]Add[/] [i]extra[/] options for the [#C1FF87]k3s[/] "
"install script")
k3s_container = self.get_widget_by_id(f"{self.distro}-base-grid")
k3s_container.border_title = k3s_title
subtitle = ("[b][@click=screen.launch_new_option_modal()]"
"➕ k3s option[/][/]")
k3s_container.border_subtitle = subtitle

# if we've been passed k3s args already, generate rows
if self.k3s_args:
for arg, value in self.k3s_args.items():
Expand Down
4 changes: 2 additions & 2 deletions smol_k8s_lab/tui/distro_widgets/kubelet_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def on_button_pressed(self, event: Button.Pressed) -> None:

# this isn't beautiful, but should get the job done
if self.distro == "k3s":
k3s_args = app_yaml['k3s_yaml']
k3s_args = app_yaml['k3s_yaml']['kubelet-args']
pop_item = None

if input_key:
Expand Down Expand Up @@ -114,7 +114,7 @@ def update_base_yaml(self, event: Input.Changed | Input.Submitted) -> None:

# k3s uses a list
if self.distro == "k3s":
args = distro_cfg["k3s_yaml"]
args = distro_cfg["k3s_yaml"]['kubelet-args']
if isinstance(args, list):
args.append(f"{event.input.name}={event.input.value}")
else:
Expand Down

0 comments on commit 1d61edc

Please sign in to comment.