← back to jingle2008__toolkit

Function bodies 285 total

All specs Real LLM only Function bodies
tui.Model.handleLimitRegionalOverrideCategory method · go · L548-L553 (6 LOC)
internal/ui/tui/model_reducer.go
func (m *Model) handleLimitRegionalOverrideCategory(gen int) tea.Cmd {
	if m.dataset == nil || m.dataset.LimitRegionalOverrides == nil {
		return loadLimitRegionalOverridesCmd(m.loadCtx, m.loader, m.repoPath, m.environment, gen)
	}
	return nil
}
tui.Model.handleConsolePropertyRegionalOverrideCategory method · go · L555-L560 (6 LOC)
internal/ui/tui/model_reducer.go
func (m *Model) handleConsolePropertyRegionalOverrideCategory(gen int) tea.Cmd {
	if m.dataset == nil || m.dataset.ConsolePropertyRegionalOverrides == nil {
		return loadConsolePropertyRegionalOverridesCmd(m.loadCtx, m.loader, m.repoPath, m.environment, gen)
	}
	return nil
}
tui.Model.handlePropertyRegionalOverrideCategory method · go · L562-L567 (6 LOC)
internal/ui/tui/model_reducer.go
func (m *Model) handlePropertyRegionalOverrideCategory(gen int) tea.Cmd {
	if m.dataset == nil || m.dataset.PropertyRegionalOverrides == nil {
		return loadPropertyRegionalOverridesCmd(m.loadCtx, m.loader, m.repoPath, m.environment, gen)
	}
	return nil
}
tui.Model.handleBaseModelCategory method · go · L569-L574 (6 LOC)
internal/ui/tui/model_reducer.go
func (m *Model) handleBaseModelCategory(gen int) tea.Cmd {
	if m.dataset == nil || m.dataset.BaseModels == nil {
		return loadBaseModelsCmd(m.loadCtx, m.loader, m.kubeConfig, m.environment, gen)
	}
	return nil
}
tui.Model.handleGpuPoolCategory method · go · L576-L581 (6 LOC)
internal/ui/tui/model_reducer.go
func (m *Model) handleGpuPoolCategory(refresh bool, gen int) tea.Cmd {
	if m.dataset == nil || m.dataset.GpuPools == nil || refresh {
		return loadGpuPoolsCmd(m.loadCtx, m.loader, m.repoPath, m.environment, gen)
	}
	return nil
}
tui.Model.handleGpuNodeCategory method · go · L583-L588 (6 LOC)
internal/ui/tui/model_reducer.go
func (m *Model) handleGpuNodeCategory(refresh bool, gen int) tea.Cmd {
	if m.dataset == nil || m.dataset.GpuNodeMap == nil || refresh {
		return loadGpuNodesCmd(m.loadCtx, m.loader, m.kubeConfig, m.environment, gen)
	}
	return nil
}
tui.Model.handleDedicatedAIClusterCategory method · go · L590-L595 (6 LOC)
internal/ui/tui/model_reducer.go
func (m *Model) handleDedicatedAIClusterCategory(refresh bool, gen int) tea.Cmd {
	if m.dataset == nil || m.dataset.DedicatedAIClusterMap == nil || refresh {
		return loadDedicatedAIClustersCmd(m.loadCtx, m.loader, m.kubeConfig, m.environment, gen)
	}
	return nil
}
All rows above produced by Repobility · https://repobility.com
tui.Model.enterDetailView method · go · L598-L609 (12 LOC)
internal/ui/tui/model_reducer.go
func (m *Model) enterDetailView() tea.Cmd {
	row := m.table.SelectedRow()
	if len(row) == 0 {
		return nil
	}

	m.viewMode = common.DetailsView
	m.keys = keys.ResolveKeys(m.category, m.viewMode)
	m.choice = getItemKey(m.category, row)
	m.updateLayout(m.viewWidth, m.viewHeight)
	return m.updateContentAsync()
}
tui.Model.changeCategory method · go · L619-L630 (12 LOC)
internal/ui/tui/model_reducer.go
func (m *Model) changeCategory() tea.Cmd {
	text := m.textInput.Value()
	category, err := domain.ParseCategory(text)
	if err != nil {
		return nil
	}

	if m.category == category {
		return nil
	}
	return tea.Sequence(m.updateCategory(category)...)
}
tui.Model.enterContext method · go · L633-L659 (27 LOC)
internal/ui/tui/model_reducer.go
func (m *Model) enterContext() tea.Cmd {
	row := m.table.SelectedRow()
	if len(row) == 0 {
		return nil
	}

	target := row[0]
	switch {
	case m.category.IsScope():
		m.context = &domain.ToolkitContext{Category: m.category, Name: target}
		return tea.Sequence(m.updateCategory(m.category.ScopedCategories()[0])...)
	case m.category == domain.Environment:
		env := *collections.FindByName(m.dataset.Environments, target)
		if !m.environment.Equals(env) {
			m.environment = env
			m.dataset.ResetScopedData()
			return tea.Sequence(m.updateCategory(domain.Tenant)...)
		}
	case m.category == domain.Alias:
		if cat, _ := domain.ParseCategory(target); cat != m.category {
			return tea.Sequence(m.updateCategory(cat)...)
		}
	default:
		return m.enterDetailView()
	}
	return nil
}
tui.Model.beginTask method · go · L665-L678 (14 LOC)
internal/ui/tui/model_reducer.go
func (m *Model) beginTask() tea.Cmd {
	var cmd tea.Cmd
	if m.pendingTasks == 0 {
		m.lastViewMode = m.viewMode
		m.viewMode = common.LoadingView
		cmd = tea.Sequence(
			m.loadingSpinner.Tick, // start the spinner
			m.loadingTimer.Reset(),
			m.loadingTimer.Start(), // start the stopwatch
		)
	}
	m.pendingTasks++
	return cmd
}
tui.Model.endTask method · go · L684-L701 (18 LOC)
internal/ui/tui/model_reducer.go
func (m *Model) endTask(success bool) {
	if m.pendingTasks > 0 {
		m.pendingTasks--
	}
	if m.pendingTasks == 0 {
		elapsed := m.loadingTimer.Elapsed().String()
		m.logger.Infow("data load completed",
			"category", m.category,
			"success", success,
			"elapsed", elapsed,
		)
		if success {
			m.viewMode = m.lastViewMode
		} else {
			m.viewMode = common.ErrorView
		}
	}
}
tui.NewModel function · go · L113-L143 (31 LOC)
internal/ui/tui/model_state.go
func NewModel(opts ...ModelOption) (*Model, error) {
	m := &Model{
		inputMode:    common.NormalInput,
		editTarget:   common.NoneTarget,
		category:     domain.Tenant, // or a sensible default
		viewMode:     common.ListView,
		lastViewMode: common.ListView,
		sortColumn:   common.NameCol,
		sortAsc:      true,
		history:      []domain.Category{},
		historyIdx:   -1,
	}

	initStyles(m)
	applyOptions(m, opts)
	if err := validateModel(m); err != nil {
		return nil, err
	}
	setDefaults(m)

	// Seed initial category in history if not already present
	if len(m.history) == 0 {
		m.history = []domain.Category{m.category}
		m.historyIdx = 0
	}

	// Initialize keys based on initial category and mode
	m.keys = keys.ResolveKeys(m.category, m.viewMode)

	return m, nil
}
tui.setStyles function · go · L151-L166 (16 LOC)
internal/ui/tui/model_state.go
func setStyles(m *Model, s Styles) {
	m.baseStyle = s.Base
	m.statusNugget = s.StatusNugget
	m.statusBarStyle = s.StatusBar
	m.contextStyle = s.Context
	m.statsStyle = s.Stats
	m.statusText = s.StatusText
	m.infoKeyStyle = s.InfoKey
	m.infoValueStyle = s.InfoValue

	// Help view styles
	m.helpBorder = s.HelpBorder
	m.helpHeader = s.HelpHeader
	m.helpKey = s.HelpKey
	m.helpDesc = s.HelpDesc
}
tui.Model.newLoadContext method · go · L176-L189 (14 LOC)
internal/ui/tui/model_state.go
func (m *Model) newLoadContext() {
	if m.loadCancel != nil {
		// Cancel any in-flight load to prevent stale work
		m.loadCancel()
		if m.logger != nil {
			m.logger.Infow("canceled in-flight load")
		}
	}
	parent := m.parentCtx
	if parent == nil {
		parent = context.Background()
	}
	m.loadCtx, m.loadCancel = context.WithCancel(parent)
}
Open data scored by Repobility · https://repobility.com
tui.validateModel function · go · L192-L206 (15 LOC)
internal/ui/tui/model_state.go
func validateModel(m *Model) error {
	if m.repoPath == "" {
		return errors.New("toolkit: repoPath is required")
	}
	if m.environment.Region == "" || m.environment.Type == "" || m.environment.Realm == "" {
		return errors.New("toolkit: environment (Region, Type, Realm) is required")
	}
	if m.loader == nil {
		return errors.New("toolkit: loader is required (use WithLoader option)")
	}
	if m.logger == nil {
		return errors.New("toolkit: logger is required (use WithLogger option)")
	}
	return nil
}
tui.setDefaults function · go · L209-L275 (67 LOC)
internal/ui/tui/model_state.go
func setDefaults(m *Model) {
	if m.renderer == nil {
		m.renderer = view.ProductionRenderer{}
	}
	if m.table == nil {
		t := table.New(table.WithFocused(true))
		s := table.DefaultStyles()
		s.Header = s.Header.
			BorderStyle(lipgloss.NormalBorder()).
			BorderForeground(lipgloss.Color("240")).
			BorderBottom(true).
			Bold(true)
		s.Selected = s.Selected.
			Foreground(lipgloss.Color("229")).
			Background(lipgloss.Color("57")).
			Bold(false)
		t.SetStyles(s)
		m.table = &t
		m.styles = s
	}
	if m.textInput == nil {
		ti := textinput.New()
		ti.CharLimit = 256
		ti.Prompt = " 🐶> "
		m.textInput = &ti
	}
	if m.viewport == nil {
		vp := viewport.New(20, 20)
		vp.Style = lipgloss.NewStyle().
			BorderStyle(lipgloss.NormalBorder()).
			BorderForeground(lipgloss.Color("62"))
		m.viewport = &vp
	}
	if m.help == nil {
		keyStyle := lipgloss.NewStyle().
			Foreground(lipgloss.Color("33"))
		descStyle := lipgloss.NewStyle()
		hm := help.New()
		hm.ShowAll = true
		hm.Styles.FullKey = keySty
tui.Model.cancelInFlight method · go · L278-L285 (8 LOC)
internal/ui/tui/model_state.go
func (m *Model) cancelInFlight() {
	if m.loadCancel != nil {
		m.loadCancel()
		if m.logger != nil {
			m.logger.Infow("canceled in-flight tasks")
		}
	}
}
tui.Model.Update method · go · L15-L31 (17 LOC)
internal/ui/tui/model_update.go
func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
	switch msg := msg.(type) {
	case tea.WindowSizeMsg:
		return m.onResize(msg)
	case ErrMsg:
		m.handleErrMsg(msg)
		return m, nil
	case tableRowsComputedMsg:
		m.handleTableRowsComputedMsg(msg)
		return m, nil
	case detailContentRenderedMsg:
		m.handleDetailContentRenderedMsg(msg)
		return m, nil
	default:
		return m.delegateToActiveView(msg)
	}
}
tui.Model.onResize method · go · L33-L39 (7 LOC)
internal/ui/tui/model_update.go
func (m *Model) onResize(msg tea.WindowSizeMsg) (tea.Model, tea.Cmd) {
	m.updateLayout(msg.Width, msg.Height)
	if m.viewMode == common.DetailsView {
		return m, m.updateContentAsync()
	}
	return m, nil
}
tui.Model.delegateToActiveView method · go · L41-L57 (17 LOC)
internal/ui/tui/model_update.go
func (m *Model) delegateToActiveView(msg tea.Msg) (tea.Model, tea.Cmd) {
	switch m.viewMode {
	case common.HelpView:
		return m.updateHelpView(msg)
	case common.ListView:
		return m.updateListView(msg)
	case common.DetailsView:
		return m.updateDetailView(msg)
	case common.LoadingView:
		return m.updateLoadingView(msg)
	case common.ErrorView:
		return m.updateErrorView(msg)
	case common.ExportView:
		return m.updateExportView(msg)
	}
	return m, nil
}
tui.Model.infoView method · go · L22-L39 (18 LOC)
internal/ui/tui/model_view.go
func (m *Model) infoView() string {
	keys := []string{"Realm:", "Type:", "Region:", "Context:", "Version:"}
	values := []string{
		m.environment.Realm,
		m.environment.Type,
		m.environment.Region,
		m.environment.GetKubeContext(),
		m.version,
	}

	content := lipgloss.JoinHorizontal(lipgloss.Top,
		m.infoKeyStyle.Render(strings.Join(keys, "\n")),
		" ",
		m.infoValueStyle.Render(strings.Join(values, "\n")),
	)

	return content
}
tui.Model.contextString method · go · L41-L50 (10 LOC)
internal/ui/tui/model_view.go
func (m *Model) contextString() string {
	scope := "all"
	if m.viewMode == common.DetailsView {
		scope = getItemKeyString(m.choice)
	} else if m.context != nil && m.context.Category.IsScopeOf(m.category) {
		scope = m.context.Name
	}

	return fmt.Sprintf("%s (%s)", m.category.String(), scope)
}
Repobility · severity-and-effort ranking · https://repobility.com
tui.truncateString function · go · L52-L57 (6 LOC)
internal/ui/tui/model_view.go
func truncateString(s string, limit int) string {
	if runewidth.StringWidth(s) <= limit {
		return s
	}
	return runewidth.Truncate(s, limit-1, "…")
}
tui.Model.statusView method · go · L59-L94 (36 LOC)
internal/ui/tui/model_view.go
func (m *Model) statusView() string {
	w := lipgloss.Width

	maxCtx := m.viewWidth / 3
	ctx := truncateString(m.contextString(), maxCtx)
	contextCell := m.contextStyle.Render(ctx)

	statsText := strings.Builder{}
	if m.stats != nil {
		keys := make([]string, 0, len(m.stats))
		for k := range m.stats {
			keys = append(keys, k)
		}
		sort.Strings(keys)
		parts := make([]string, 0, len(keys))
		for _, k := range keys {
			parts = append(parts, fmt.Sprintf("%s: %d", k, m.stats[k]))
		}
		if len(parts) > 0 {
			statsText.WriteString(strings.Join(parts, " • "))
			statsText.WriteString(" ")
		}
	}
	statsText.WriteString(fmt.Sprintf("[%d/%d]", m.table.Cursor()+1, len(m.table.Rows())))
	statsCell := m.statsStyle.Render(statsText.String())

	m.textInput.Width = max(m.viewWidth-w(contextCell)-w(statsCell)-
		w(m.textInput.Prompt)-1, 0)
	inputCell := m.textInput.View()

	return lipgloss.JoinHorizontal(lipgloss.Top,
		contextCell,
		inputCell,
		statsCell,
	)
}
tui.Model.detailRenderWidth method · go · L96-L103 (8 LOC)
internal/ui/tui/model_view.go
func (m *Model) detailRenderWidth() int {
	border := m.viewport.Style.GetBorderStyle()
	width := m.viewWidth - (border.GetLeftSize() + border.GetRightSize())
	if width < 0 {
		return 0
	}
	return width
}
tui.Model.updateContentAsync method · go · L105-L124 (20 LOC)
internal/ui/tui/model_view.go
func (m *Model) updateContentAsync() tea.Cmd {
	if m.viewMode != common.DetailsView {
		return nil
	}

	m.detailNonce++
	nonce := m.detailNonce
	item := findItem(m.dataset, m.category, m.choice)
	width := m.detailRenderWidth()
	renderer := m.renderer

	return func() tea.Msg {
		content, err := jsonutil.PrettyJSON(item)
		if err != nil {
			content = err.Error()
		}
		str, err := renderer.RenderJSON(content, width)
		return detailContentRenderedMsg{Content: str, Err: err, Nonce: nonce}
	}
}
tui.Model.handleDetailContentRenderedMsg method · go · L126-L135 (10 LOC)
internal/ui/tui/model_view.go
func (m *Model) handleDetailContentRenderedMsg(msg detailContentRenderedMsg) {
	if msg.Nonce != m.detailNonce || m.viewMode != common.DetailsView {
		return
	}
	if msg.Err != nil {
		m.err = fmt.Errorf("error encountered rendering content: %w", msg.Err)
		return
	}
	m.viewport.SetContent(msg.Content)
}
tui.Model.View method · go · L138-L158 (21 LOC)
internal/ui/tui/model_view.go
func (m *Model) View() string {
	// exhaustive:common.ViewMode
	switch m.viewMode {
	case common.LoadingView:
		spin := m.loadingSpinner.View()
		sw := m.loadingTimer.View()
		return m.centered(fmt.Sprintf("%s Loading data: %s … %s", spin, m.category.String(), sw))
	case common.ErrorView:
		return m.centered(m.err.Error())
	case common.HelpView:
		return m.centered(m.fullHelpView())
	case common.ListView:
		return m.frame(m.baseStyle.Render(m.table.View()))
	case common.DetailsView:
		return m.frame(m.viewport.View())
	case common.ExportView:
		return m.centered(m.exportView())
	default:
		return ""
	}
}
tui.Model.frame method · go · L166-L172 (7 LOC)
internal/ui/tui/model_view.go
func (m *Model) frame(main string) string {
	helpView := m.help.View(m.keys)
	infoView := m.infoValueStyle.Render(m.infoView())
	header := lipgloss.JoinHorizontal(lipgloss.Top, infoView, helpView)
	status := m.statusView()
	return lipgloss.JoinVertical(lipgloss.Left, header, status, main)
}
tui.Model.fullHelpView method · go · L178-L213 (36 LOC)
internal/ui/tui/model_view.go
func (m *Model) fullHelpView() string {
	const keyCol = 12
	var b strings.Builder

	renderRow := func(k, d string) {
		fmt.Fprintf(&b, "  %s%s\n",
			m.helpKey.Render(fmt.Sprintf("%-*s", keyCol, k)),
			m.helpDesc.Render(d))
	}
	renderSection := func(title string, bind []key.Binding) {
		if len(bind) == 0 {
			return
		}
		fmt.Fprintln(&b, m.helpHeader.Render(title))
		for _, bb := range bind {
			h := bb.Help()
			if h.Key == "" && h.Desc == "" {
				continue
			}
			renderRow(h.Key, h.Desc)
		}
		b.WriteString("\n")
	}
	renderSection("Resource Actions", m.keys.Context)
	renderSection(fmt.Sprintf("%s View Actions", m.lastViewMode), m.keys.Mode)
	renderSection("General Actions", m.keys.Global)
	switch m.lastViewMode {
	case common.ListView:
		renderSection("Table Actions", m.getTableBinding())
	case common.DetailsView:
		renderSection("Viewport Actions", m.getViewportBinding())
	case common.LoadingView, common.HelpView, common.ErrorView, common.ExportView:
		// No additional sections f
Source: Repobility analyzer · https://repobility.com
tui.Model.getTableBinding method · go · L215-L226 (12 LOC)
internal/ui/tui/model_view.go
func (m *Model) getTableBinding() []key.Binding {
	return []key.Binding{
		m.table.KeyMap.LineUp,
		m.table.KeyMap.LineDown,
		m.table.KeyMap.HalfPageUp,
		m.table.KeyMap.HalfPageDown,
		m.table.KeyMap.PageUp,
		m.table.KeyMap.PageDown,
		m.table.KeyMap.GotoTop,
		m.table.KeyMap.GotoBottom,
	}
}
tui.Model.getViewportBinding method · go · L228-L237 (10 LOC)
internal/ui/tui/model_view.go
func (m *Model) getViewportBinding() []key.Binding {
	return []key.Binding{
		m.viewport.KeyMap.Up,
		m.viewport.KeyMap.Down,
		m.viewport.KeyMap.HalfPageUp,
		m.viewport.KeyMap.HalfPageDown,
		m.viewport.KeyMap.PageUp,
		m.viewport.KeyMap.PageDown,
	}
}
tui.aliasToRow function · go · L14-L19 (6 LOC)
internal/ui/tui/row_builders.go
func aliasToRow(c domain.Category) table.Row {
	return table.Row{
		c.String(),
		strings.Join(c.GetAliases(), ", "),
	}
}
tui.tenantToRow function · go · L22-L29 (8 LOC)
internal/ui/tui/row_builders.go
func tenantToRow(t models.Tenant) table.Row {
	return table.Row{
		t.Name,
		t.GetTenantID(),
		fmt.Sprint(t.IsInternal),
		t.Note,
	}
}
tui.limitDefinitionToRow function · go · L32-L40 (9 LOC)
internal/ui/tui/row_builders.go
func limitDefinitionToRow(val models.LimitDefinition) table.Row {
	return table.Row{
		val.Name,
		val.Description,
		val.Scope,
		val.DefaultMin,
		val.DefaultMax,
	}
}
tui.environmentToRow function · go · L52-L59 (8 LOC)
internal/ui/tui/row_builders.go
func environmentToRow(e models.Environment) table.Row {
	return table.Row{
		e.GetName(),
		e.Realm,
		e.Type,
		e.Region,
	}
}
tui.serviceTenancyToRow function · go · L62-L70 (9 LOC)
internal/ui/tui/row_builders.go
func serviceTenancyToRow(s models.ServiceTenancy) table.Row {
	return table.Row{
		s.Name,
		s.Realm,
		s.Environment,
		s.HomeRegion,
		strings.Join(s.Regions, ", "),
	}
}
tui.gpuPoolToRow function · go · L73-L85 (13 LOC)
internal/ui/tui/row_builders.go
func gpuPoolToRow(val models.GpuPool) table.Row {
	return table.Row{
		val.Name,
		val.Shape,
		val.AvailabilityDomain,
		fmt.Sprint(val.Size),
		fmt.Sprint(val.ActualSize),
		fmt.Sprint(val.GetGPUs()),
		fmt.Sprint(val.IsOkeManaged),
		val.CapacityType,
		val.Status,
	}
}
All rows above produced by Repobility · https://repobility.com
tui.limitTenancyOverrideToRow function · go · L88-L96 (9 LOC)
internal/ui/tui/row_builders.go
func limitTenancyOverrideToRow(val models.LimitTenancyOverride, tenant string) table.Row {
	return table.Row{
		val.Name,
		tenant,
		strings.Join(val.Regions, ", "),
		fmt.Sprint(val.Values[0].Min),
		fmt.Sprint(val.Values[0].Max),
	}
}
tui.limitRegionalOverrideToRow function · go · L109-L121 (13 LOC)
internal/ui/tui/row_builders.go
func limitRegionalOverrideToRow(val models.LimitRegionalOverride) table.Row {
	minStr, maxStr := "", ""
	if len(val.Values) > 0 {
		minStr = fmt.Sprint(val.Values[0].Min)
		maxStr = fmt.Sprint(val.Values[0].Max)
	}
	return table.Row{
		val.Name,
		strings.Join(val.Regions, ", "),
		minStr,
		maxStr,
	}
}
tui.baseModelToRow function · go · L133-L149 (17 LOC)
internal/ui/tui/row_builders.go
func baseModelToRow(val models.BaseModel) table.Row {
	shape := val.GetDefaultDacShape()
	var shapeDisplay string
	if shape != nil {
		shapeDisplay = fmt.Sprintf("%dx %s", shape.QuotaUnit, shape.Name)
	}
	return table.Row{
		val.Name,
		val.DisplayName,
		val.Version,
		shapeDisplay,
		val.ParameterSize,
		fmt.Sprint(val.MaxTokens),
		val.GetFlags(),
		val.Status,
	}
}
tui.modelArtifactToRow function · go · L152-L159 (8 LOC)
internal/ui/tui/row_builders.go
func modelArtifactToRow(val models.ModelArtifact, _ string) table.Row {
	return table.Row{
		val.Name,
		val.ModelName,
		val.GetGpuConfig(),
		val.TensorRTVersion,
	}
}
tui.gpuNodeToRow function · go · L162-L174 (13 LOC)
internal/ui/tui/row_builders.go
func gpuNodeToRow(val models.GpuNode, _ string) table.Row {
	return table.Row{
		val.Name,
		val.NodePool,
		val.InstanceType,
		fmt.Sprint(val.Allocatable),
		fmt.Sprint(val.Allocatable - val.Allocated),
		fmt.Sprint(val.IsHealthy()),
		fmt.Sprint(val.IsReady),
		val.Age,
		val.GetStatus(),
	}
}
tui.dedicatedAIClusterToRowInternal function · go · L181-L202 (22 LOC)
internal/ui/tui/row_builders.go
func dedicatedAIClusterToRowInternal(val models.DedicatedAICluster, tenant string, name *string) table.Row {
	unitShapeOrProfile := val.UnitShape
	if unitShapeOrProfile == "" {
		unitShapeOrProfile = val.Profile
	}

	if name == nil {
		name = &val.Name
	}

	return table.Row{
		*name,
		tenant,
		val.GetOwnerState(),
		val.GetUsage(),
		val.Type,
		unitShapeOrProfile,
		fmt.Sprint(val.Size),
		val.Age,
		val.Status,
	}
}
tui.DefaultStyles function · go · L25-L75 (51 LOC)
internal/ui/tui/styles.go
func DefaultStyles() Styles {
	base := lipgloss.NewStyle().
		BorderStyle(lipgloss.NormalBorder()).
		BorderForeground(lipgloss.Color("240"))

	statusNugget := lipgloss.NewStyle().
		Foreground(lipgloss.Color("#FFFDF5")).
		Padding(0, 1)

	statusBar := lipgloss.NewStyle().
		Foreground(lipgloss.AdaptiveColor{Light: "#343433", Dark: "#C1C6B2"}).
		Background(lipgloss.AdaptiveColor{Light: "#D9DCCF", Dark: "#353533"})

	context := lipgloss.NewStyle().
		Inherit(statusBar).
		Foreground(lipgloss.Color("#FFFDF5")).
		Background(lipgloss.Color("#FF5F87")).
		Padding(0, 1)

	stats := statusNugget.
		Background(lipgloss.Color("#A550DF")).
		Align(lipgloss.Right)

	statusText := lipgloss.NewStyle().Inherit(statusBar)
	infoKey := lipgloss.NewStyle().Foreground(lipgloss.Color("208"))
	infoValue := lipgloss.NewStyle().Width(30)

	helpBorder := lipgloss.NewStyle().
		Border(lipgloss.NormalBorder()).
		BorderForeground(lipgloss.Color("62")).
		Padding(1, 2)
	helpHeader := lipgloss.NewStyle().Inherit
tui.sortRows function · go · L15-L40 (26 LOC)
internal/ui/tui/table_sort.go
func sortRows(rows []table.Row, headers []header, sortColumn string, asc bool) {
	colIdx := slices.IndexFunc(headers, func(h header) bool {
		return strings.EqualFold(h.text, sortColumn)
	})
	if colIdx < 0 {
		return
	}

	intCols := map[string]struct{}{
		common.FreeCol:    {},
		common.ContextCol: {},
	}

	switch {
	case strings.EqualFold(sortColumn, common.AgeCol):
		sortByAge(rows, colIdx, asc)
	case strings.EqualFold(sortColumn, common.UsageCol):
		sortByPercent(rows, colIdx, asc)
	case strings.EqualFold(sortColumn, common.SizeCol):
		sortBySize(rows, colIdx, asc)
	case hasIntHeader(intCols, sortColumn):
		sortByInt(rows, colIdx, asc)
	default:
		sortByString(rows, colIdx, asc)
	}
}
Open data scored by Repobility · https://repobility.com
tui.sortByAge function · go · L42-L51 (10 LOC)
internal/ui/tui/table_sort.go
func sortByAge(rows []table.Row, colIdx int, asc bool) {
	slices.SortFunc(rows, func(a, b table.Row) int {
		av := k8stime.ParseAge(a[colIdx])
		bv := k8stime.ParseAge(b[colIdx])
		if asc {
			return int(av - bv)
		}
		return int(bv - av)
	})
}
tui.sortByInt function · go · L53-L62 (10 LOC)
internal/ui/tui/table_sort.go
func sortByInt(rows []table.Row, colIdx int, asc bool) {
	slices.SortFunc(rows, func(a, b table.Row) int {
		av, _ := strconv.ParseInt(a[colIdx], 10, 64)
		bv, _ := strconv.ParseInt(b[colIdx], 10, 64)
		if asc {
			return int(av - bv)
		}
		return int(bv - av)
	})
}
tui.sortByPercent function · go · L64-L73 (10 LOC)
internal/ui/tui/table_sort.go
func sortByPercent(rows []table.Row, colIdx int, asc bool) {
	slices.SortFunc(rows, func(a, b table.Row) int {
		av, _ := parsePercent(a[colIdx])
		bv, _ := parsePercent(b[colIdx])
		if asc {
			return int(av - bv)
		}
		return int(bv - av)
	})
}
‹ prevpage 4 / 6next ›