view

package
v1.13.0-rc8 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameHelp     = "help"
	NameStacks   = "stacks"
	NameServices = "services"
	NameTasks    = "tasks"
	NameNodes    = "nodes"
	NameConfigs  = "configs"
	NameSecrets  = "secrets"
	NameContexts = "contexts"
	NameInspect  = "inspect"
	NameLogs     = "logs"
	NameLoading  = "loading"
	NameNetworks = "networks"
	NameVolumes  = "volumes"
)

View name constants for type-safe navigation

View Source
const BELandingURL = "https://swarmcli.io/be"

BELandingURL is the public Business Edition landing page (trial info, feature overview). Exported so the BE module references the same string instead of re-hardcoding it.

Variables

View Source
var BEUnavailableFormat = "%s is a Business Edition feature.\nFor more information, visit: " + BELandingURL

BEUnavailableFormat is the format string used by BEUnavailableErr. Contains one %s verb for the feature name. Override in init() to customise.

View Source
var BEUnavailableFormatFn func(featureName string) string

BEUnavailableFormatFn, if set, returns the error message for a feature. Takes precedence over BEUnavailableFormat. Override in init() to customise.

View Source
var FeatureLockedCmdFn func(featureName string) tea.Cmd

FeatureLockedCmdFn, if set by an extension, returns a tea.Cmd to run when a license-gated feature is requested without entitlement. When set it takes precedence over the caller's local error dialog, letting the extension show a richer prompt (e.g. an inline license dialog) instead of the flat BEUnavailableErr text. Override in init().

View Source
var ServicesHealthHint func() string

ServicesHealthHint, when set by the BE module, returns a one-line services- view footer note (e.g. why container health is unavailable on the current context), or "" when there is nothing to say. It lets BE surface a context- specific note without CE having to know about managed contexts. Set in init(); read on the render goroutine.

Functions

func BEHelpDesc

func BEHelpDesc(actionName, desc string) string

BEHelpDesc returns desc if the action is registered, or desc+" (BE)" if not.

func BEUnavailableErr

func BEUnavailableErr(featureName string) error

BEUnavailableErr returns an error indicating a feature requires Business Edition.

func DecodeRef

func DecodeRef(s string) []string

DecodeRef unpacks an argument produced by EncodeRef.

func EncodeRef

func EncodeRef(parts ...string) string

EncodeRef packs fields into one Action argument string. It is the shared contract for actions that need more than a bare resource name — e.g. volume actions need the swarm node ID plus the volume name, because a volume name is only unique per node. Decode with DecodeRef.

func FeatureLockedCmd

func FeatureLockedCmd(featureName string) tea.Cmd

FeatureLockedCmd returns the extension's rich locked-feature command for featureName, or nil when no extension is registered — in which case callers fall back to surfacing BEUnavailableErr in their own error UI.

func HasAction

func HasAction(name string) bool

HasAction reports whether an action is registered and its guard passes.

func IsTopLevel

func IsTopLevel(name string) bool

IsTopLevel reports whether a view name is a top-level (root) view.

func RegisterAction

func RegisterAction(name string, fn Action)

RegisterAction registers a named action. Must only be called from init() functions.

func RegisterGatedAction

func RegisterGatedAction(name string, guard func() bool, fn Action)

RegisterGatedAction registers an action with a runtime guard. GetAction and HasAction return false when the guard returns false. Must only be called from init() functions.

func RegisterTopLevel

func RegisterTopLevel(name string)

RegisterTopLevel marks a view name as top-level. Called from init() by extension modules to register additional root views.

func RegisterView

func RegisterView(name string, f Factory)

RegisterView registers a view factory under the given name. Must only be called from init() functions.

func UnregisterActionForTest

func UnregisterActionForTest(name string)

UnregisterActionForTest removes a registered action. Test-only; not safe for concurrent use.

Types

type Action

type Action func(name string) tea.Cmd

Action is a feature action that can be triggered by key presses. The string parameter is the resource name (e.g. secret name). Registered during init() by extension packages, read-only after startup.

func GetAction

func GetAction(name string) (Action, bool)

GetAction returns the action for the given name, if registered and its guard passes.

type AppErrorMsg

type AppErrorMsg struct {
	Error        string
	FallbackView string
}

AppErrorMsg signals that a view (or the app layer) encountered a loading error. The app shows a modal error dialog. On dismiss it navigates to FallbackView (if non-empty) or calls goBack().

type AppInfoMsg

type AppInfoMsg struct {
	Message      string
	FallbackView string
}

AppInfoMsg signals that a view (or the app layer) wants to show an informational notice — the AppErrorMsg counterpart for non-error content. The app shows the same modal styled as a neutral "Info" notice (not an error). On dismiss it navigates to FallbackView (if non-empty) or calls goBack(). Generic extension point: senders decide what warrants a notice.

type Factory

type Factory func(deps docker.Deps, width, height int, payload any) (View, tea.Cmd)

Factory creates a View instance with its initial command. The deps parameter provides Docker operation interfaces for testability.

func GetFactory

func GetFactory(name string) (Factory, bool)

GetFactory returns the factory for the given view name.

type Filterable

type Filterable interface {
	ApplySearchQuery(query string)
	ClearSearchQuery()
}

Filterable is an opt-in interface for views that support app-level "/" search filtering. Checked via type assertion in app/update.go.

type GoBackMsg

type GoBackMsg struct{}

GoBackMsg requests the app to pop the current view and return to the previous one.

type NavigateToMsg struct {
	ViewName string
	Payload  any // Can be service ID, stack ID, etc.
	// Replace indicates whether the target view should replace the current
	// view (i.e., not be pushed onto the navigation stack). When false,
	// the view manager should push the new view onto the history stack.
	Replace bool
}

type OpenUnlockDialogMsg

type OpenUnlockDialogMsg struct{}

OpenUnlockDialogMsg requests the app to open the swarm unlock-key dialog.

type OpenUpdateDialogMsg

type OpenUpdateDialogMsg struct {
	Version string
}

OpenUpdateDialogMsg requests the app to force-show the "update available" notice on demand (the dev-only :dev-update command), bypassing the per-version dismissal. Version overrides the displayed latest version when set; otherwise the app falls back to the last checked version or a stub.

type View

type View interface {
	Update(msg tea.Msg) tea.Cmd
	View() string
	Init() tea.Cmd
	Name() string
	ShortHelpItems() []helpbar.HelpEntry

	OnEnter() tea.Cmd // Called when view becomes active
	OnExit() tea.Cmd  // Called when view is removed/replaced

	HasErrors() bool // Returns true if the view has any errors to display

	// Frame components — views return unframed content,
	// app wraps with ui.RenderViewFrame.
	FrameTitle() string   // text for frame title bar
	FrameHeader() string  // rendered header line(s), "" if none
	FrameFooter() string  // rendered footer line(s), "" if none
	FrameContent() string // unframed content (may include dialog overlays)
}

Jump to

Keyboard shortcuts

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