dialogs

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package dialogs implements the TUI's modal mutation dialogs: the create/edit entry form (a charm.land/huh/v2 form embedded as a model, with a $EDITOR handoff), the delete confirm, the tag add/remove form, the restore form, and a plain error dialog. Every mutation dialog carries a staged-by-default / apply-immediately mode toggle (hidden when the service has no staging, so the write is always immediate), and routes through the provider-neutral data.Mutator seam — staged writes to internal/usecase/staging, immediate writes to the direct param/secret use cases. The app shell owns the dialog stack and dismissal; a dialog reports Busy() so the shell suppresses dismissal while an operation is in flight.

Index

Constants

This section is empty.

Variables

View Source
var NowFunc = time.Now

NowFunc is the clock the "recoverable until" date is computed from. It is an exported package variable so a golden can pin the date deterministically.

Functions

This section is empty.

Types

type ApplyInput

type ApplyInput struct {
	Ctx context.Context //nolint:containedctx // Run context threaded into the apply command; mirrors the browser
	// Targets are the services to apply (one for per-service, all for apply-all).
	Targets []data.StagingService
	// TargetLine is the resolved target identity string (account/region, project,
	// or vault/store) shown on the confirmation — parity with the CLI prompt.
	TargetLine string
	// Title is the dialog title (e.g. "Apply staged changes — Param" / "— all").
	Title string
	// EntryCount / TagCount are the staged totals across the targets.
	EntryCount int
	TagCount   int
	Styles     styles.Styles
}

ApplyInput configures an apply dialog.

type CanceledMsg

type CanceledMsg struct{}

CanceledMsg is emitted when a dialog is dismissed without an action (the Cancel button, or a huh form abort). The app pops the dialog.

type DeleteInput

type DeleteInput struct {
	Ctx       context.Context //nolint:containedctx // Run context threaded into the mutation command; mirrors the browser
	Mutator   data.Mutator
	Service   string
	Styles    styles.Styles
	Name      string
	Namespace string
}

DeleteInput configures a delete dialog.

type DismissReloader

type DismissReloader interface {
	DismissCmd() tea.Cmd
}

DismissReloader is an optional dialog capability. A dialog that has already mutated by the time it can be dismissed — the apply results view — returns a non-nil command from DismissCmd so that closing it with Back (Esc) runs the same pop+reload+voice as its confirm key, instead of the shell's bare pop (which would leave the staging page rendering just-applied items as still staged). Returning nil means "fall back to a bare dismiss".

type EntryFormInput

type EntryFormInput struct {
	Ctx     context.Context //nolint:containedctx // Run context threaded into the mutation command; mirrors the browser
	Mutator data.Mutator
	Service string
	Styles  styles.Styles
	// Edit switches the dialog to edit mode (name is fixed, not entered).
	Edit bool
	// Name/Namespace/Value/TypeLabel/Description seed the fields. For create,
	// Namespace seeds the App Configuration namespace default (the viewing one).
	Name      string
	Namespace string
	Value     string
	TypeLabel string
	// StagedOnly opens the dialog from a staged-only surface (the staging review
	// page): the mode toggle is hidden and the write is forced staged, so a staged
	// review can never launch an immediate write that bypasses the staging store.
	StagedOnly  bool
	Description string
	// DeleteStagedKeys lets a create dialog reject a name already staged for
	// deletion with an inline validation error (#692). Unset for an edit.
	DeleteStagedKeys map[data.StagedKey]struct{}
}

EntryFormInput configures a create/edit dialog.

type EscInterceptor

type EscInterceptor interface {
	InterceptEsc() bool
}

EscInterceptor is an optional dialog capability. A free-text form that guards against discarding unsaved input implements it so the shell forwards the Back (Esc) key into the dialog's Update — where a dirty form arms a discard confirmation (a second Esc then discards) — instead of bare-popping it. A clean form returns CanceledMsg on the first Esc, so the shell closes it exactly as before. The shell still suppresses Esc entirely while the dialog is Busy (a mutation in flight is never interrupted).

type Model

type Model interface {
	// Update handles a forwarded message and returns the (possibly replaced)
	// dialog plus any command.
	Update(tea.Msg) (Model, tea.Cmd)
	// View renders the dialog's inner content (the shell frames and centers it).
	View() string
	// Busy reports whether an operation is mid-flight, so the shell suppresses
	// dismissal and the dialog swallows further input (double-submit guard).
	Busy() bool
}

Model is a modal dialog embedded in the app shell's dialog stack. It mirrors the app's page contract but returns its own concrete interface (the app adapts it). While Busy() reports true the shell must not dismiss it (a mutation is in flight — GUI "Modal busy" parity).

func NewApply

func NewApply(in ApplyInput) Model

NewApply builds an apply dialog.

func NewDeleteConfirm

func NewDeleteConfirm(in DeleteInput) Model

NewDeleteConfirm builds a delete dialog.

func NewEntryForm

func NewEntryForm(in EntryFormInput) (Model, tea.Cmd)

NewEntryForm builds a create/edit dialog. It returns the dialog and its Init command (the embedded huh form's Init), which the app batches on open.

func NewError

func NewError(st styles.Styles, title, message string) Model

NewError builds an error dialog with a title and message.

func NewReset

func NewReset(in ResetInput) Model

NewReset builds a reset dialog. Focus starts on Cancel so an accidental enter (e.g. an "R enter" double-tap) does not wipe staged changes — parity with the delete/apply confirms, which also default to a non-destructive control.

func NewRestore

func NewRestore(in RestoreInput) (Model, tea.Cmd)

NewRestore builds a restore dialog.

func NewTagForm

func NewTagForm(in TagInput) (Model, tea.Cmd)

NewTagForm builds a tag add/remove dialog.

type MutationDoneMsg

type MutationDoneMsg struct {
	// Service is the affected service ("param"/"secret"), so the app reloads the
	// right browser page.
	Service string
	// Status is the one-line outcome to voice (staged/applied/skipped/unstaged).
	Status string
	// Staged reports whether the write was staged (vs applied immediately).
	Staged bool
}

MutationDoneMsg is emitted when a mutation succeeds. The app pops the dialog, reloads the affected service's browser (list/detail/staged badges), refreshes the staging tab count, and voices Status.

type ResetInput

type ResetInput struct {
	Ctx     context.Context //nolint:containedctx // Run context threaded into the reset command; mirrors the browser
	Targets []data.StagingService
	// Title is the dialog title (e.g. "Reset staged changes — Secret" / "— all").
	Title  string
	Styles styles.Styles
}

ResetInput configures a reset dialog.

type RestoreInput

type RestoreInput struct {
	Ctx     context.Context //nolint:containedctx // Run context threaded into the mutation command; mirrors the browser
	Mutator data.Mutator
	Service string
	Styles  styles.Styles
	// Name seeds the name input (the browser's selected entry, when any).
	Name string
}

RestoreInput configures a restore dialog.

type TagInput

type TagInput struct {
	Ctx       context.Context //nolint:containedctx // Run context threaded into the mutation command; mirrors the browser
	Mutator   data.Mutator
	Service   string
	Styles    styles.Styles
	Name      string
	Namespace string
	// Tags is the entry's current tag set, offered as the Remove action's choices
	// (#705). Empty when the caller has none to offer, in which case the Remove
	// action is not offered (#761).
	Tags []data.Tag
	// StagedOnly opens the dialog from a staged-only surface (the staging review
	// page): the mode toggle is hidden and the tag write is forced staged.
	StagedOnly bool
}

TagInput configures a tag dialog.

Jump to

Keyboard shortcuts

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