tui

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package tui provides filter and debounce utilities for the TUI model.

Package tui defines message types for the TUI model.

Package tui implements the core TUI model and logic for the toolkit application. It provides the Model struct and related helpers for managing state, events, and rendering using Bubble Tea and Charmbracelet components.

Package tui contains reducer and event logic for the Model. This file contains methods for state transitions, event handling, and UI updates.

Package tui contains the Model struct and constructor for the toolkit TUI. This file defines the main state container and its initialization logic.

Package tui implements the update/reduce logic for the Model.

Package tui implements the view and rendering logic for the Model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebounceFilter

func DebounceFilter(m *Model) tea.Cmd

DebounceFilter triggers a debounced filter update for the model's text input.

func FilterTable

func FilterTable(m *Model, filter string)

FilterTable updates the model's filter and rows if the filter has changed.

func GetScopedItems

func GetScopedItems[T models.NamedFilterable](
	logger logging.Logger,
	g map[string][]T,
	scopeCategory domain.Category,
	ctx *domain.ToolkitContext,
	filter string,
) []table.Row

GetScopedItems is used for tenancy and other scoped overrides. Accepts a Logger interface for decoupling from zap.

func GetTableRow

func GetTableRow(logger logging.Logger, scope string, item any) table.Row

GetTableRow returns a table.Row for a given item. If the item implements RowMarshaler, it is used directly. Otherwise, falls back to legacy type switch for backward compatibility.

Types

type ConsolePropertyTenancyOverrideRow

type ConsolePropertyTenancyOverrideRow models.ConsolePropertyTenancyOverride

ConsolePropertyTenancyOverrideRow is a wrapper to implement RowMarshaler for models.ConsolePropertyTenancyOverride.

func (ConsolePropertyTenancyOverrideRow) Render

Render implements the Renderer interface for ConsolePropertyTenancyOverrideRow.

func (ConsolePropertyTenancyOverrideRow) ToRow

ToRow returns a table.Row for the ConsolePropertyTenancyOverrideRow, scoped by the given string.

type DataMsg

type DataMsg struct{ Data any }

DataMsg is a message containing generic data.

type DedicatedAIClusterRow

type DedicatedAIClusterRow models.DedicatedAICluster

DedicatedAIClusterRow is a wrapper to implement RowMarshaler for models.DedicatedAICluster.

func (DedicatedAIClusterRow) Render

func (d DedicatedAIClusterRow) Render(scope string) []string

Render implements the Renderer interface for DedicatedAIClusterRow.

func (DedicatedAIClusterRow) ToRow

func (d DedicatedAIClusterRow) ToRow(scope string) table.Row

ToRow returns a table.Row for the DedicatedAIClusterRow, scoped by the given string.

type EnvironmentRow

type EnvironmentRow models.Environment

EnvironmentRow is a wrapper to implement RowMarshaler for models.Environment.

func (EnvironmentRow) Render

func (e EnvironmentRow) Render(_ string) []string

Render implements the Renderer interface for EnvironmentRow.

func (EnvironmentRow) ToRow

func (e EnvironmentRow) ToRow(scope string) table.Row

ToRow returns a table.Row for the EnvironmentRow.

type ErrMsg

type ErrMsg struct{ Err error }

ErrMsg is a message containing an error.

type FilterMsg

type FilterMsg struct{ Text string }

FilterMsg is a message containing filter text.

type GpuNodeRow

type GpuNodeRow models.GpuNode

GpuNodeRow is a wrapper to implement RowMarshaler for models.GpuNode.

func (GpuNodeRow) Render

func (n GpuNodeRow) Render(_ string) []string

Render implements the Renderer interface for GpuNodeRow.

func (GpuNodeRow) ToRow

func (n GpuNodeRow) ToRow(scope string) table.Row

ToRow returns a table.Row for the GpuNodeRow.

type LimitTenancyOverrideRow

type LimitTenancyOverrideRow models.LimitTenancyOverride

LimitTenancyOverrideRow adapts models.LimitTenancyOverride for table rendering.

func (LimitTenancyOverrideRow) Render

func (l LimitTenancyOverrideRow) Render(scope string) []string

Render implements the Renderer interface for LimitTenancyOverrideRow.

func (LimitTenancyOverrideRow) ToRow

func (l LimitTenancyOverrideRow) ToRow(scope string) table.Row

ToRow returns a table.Row for the LimitTenancyOverrideRow, scoped by the given string.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model represents the main TUI model for the toolkit application. It manages state, events, and rendering for the Bubble Tea UI.

func NewModel

func NewModel(opts ...ModelOption) (*Model, error)

NewModel creates a new Model for the toolkit TUI, applying the given options.

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init implements the tea.Model interface and initializes the model.

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements the tea.Model interface and updates the Model state in response to a message.

func (*Model) View

func (m *Model) View() string

View renders the current state of the model as a string.

type ModelArtifactRow

type ModelArtifactRow models.ModelArtifact

ModelArtifactRow adapts models.ModelArtifact for table rendering.

func (ModelArtifactRow) Render

func (val ModelArtifactRow) Render(_ string) []string

Render implements the Renderer interface for ModelArtifactRow.

func (ModelArtifactRow) ToRow

func (val ModelArtifactRow) ToRow(scope string) table.Row

ToRow returns a table.Row for the ModelArtifactRow.

type ModelOption

type ModelOption func(*Model)

ModelOption defines a functional option for configuring Model.

func WithCategory

func WithCategory(category domain.Category) ModelOption

WithCategory sets the category field for the Model.

func WithContext

func WithContext(ctx context.Context) ModelOption

WithContext sets the context.Context for the Model.

func WithEnvironment

func WithEnvironment(env models.Environment) ModelOption

WithEnvironment sets the environment field.

func WithFilter

func WithFilter(filter string) ModelOption

WithFilter sets a starting filter before Init().

func WithKubeConfig

func WithKubeConfig(kubeConfig string) ModelOption

WithKubeConfig sets the kubeConfig field.

func WithLoader

func WithLoader(l loader.Loader) ModelOption

WithLoader sets the Loader implementation for the Model. The Loader interface must implement all loader interfaces (DatasetLoader, BaseModelLoader, GpuPoolLoader, GpuNodeLoader, DedicatedAIClusterLoader).

func WithLogger

func WithLogger(logger logging.Logger) ModelOption

WithLogger sets the logger for the Model.

func WithRepoPath

func WithRepoPath(repoPath string) ModelOption

WithRepoPath sets the repoPath field.

func WithTable

func WithTable(tbl *table.Model) ModelOption

WithTable sets the table.Model.

func WithVersion

func WithVersion(v string) ModelOption

WithVersion sets the version of the Model.

type PropertyTenancyOverrideRow

type PropertyTenancyOverrideRow models.PropertyTenancyOverride

PropertyTenancyOverrideRow is a wrapper to implement RowMarshaler for models.PropertyTenancyOverride.

func (PropertyTenancyOverrideRow) Render

func (p PropertyTenancyOverrideRow) Render(scope string) []string

Render implements the Renderer interface for PropertyTenancyOverrideRow.

func (PropertyTenancyOverrideRow) ToRow

func (p PropertyTenancyOverrideRow) ToRow(scope string) table.Row

ToRow returns a table.Row for the PropertyTenancyOverrideRow, scoped by the given string.

type Renderer

type Renderer interface {
	Render(scope string) []string
}

Renderer is a UI-agnostic interface for rendering a row as a slice of strings.

type ServiceTenancyRow

type ServiceTenancyRow models.ServiceTenancy

ServiceTenancyRow is a wrapper to implement RowMarshaler for models.ServiceTenancy.

func (ServiceTenancyRow) Render

func (s ServiceTenancyRow) Render(_ string) []string

Render implements the Renderer interface for ServiceTenancyRow.

func (ServiceTenancyRow) ToRow

func (s ServiceTenancyRow) ToRow(scope string) table.Row

ToRow returns a table.Row for the ServiceTenancyRow.

type SetFilterMsg

type SetFilterMsg struct{ Text string }

SetFilterMsg is a message to set the filter text in the model.

type TenantRow

type TenantRow models.Tenant

TenantRow is a wrapper to implement RowMarshaler for models.Tenant.

func (TenantRow) Render

func (t TenantRow) Render(_ string) []string

Render implements the Renderer interface for TenantRow.

func (TenantRow) ToRow

func (t TenantRow) ToRow(scope string) table.Row

ToRow returns a table.Row for the TenantRow.

Directories

Path Synopsis
Package common provides shared types and utilities for the TUI components.
Package common provides shared types and utilities for the TUI components.
Package keys provides key binding definitions and utilities for the TUI.
Package keys provides key binding definitions and utilities for the TUI.
Package view provides utilities for rendering and centering text in the TUI.
Package view provides utilities for rendering and centering text in the TUI.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL