MCPcopy
hub / github.com/basecamp/once / NewSettingsFormBackups

Function NewSettingsFormBackups

internal/ui/settings_form_backups.go:20–56  ·  view source on GitHub ↗
(app *docker.Application, lastResult *docker.OperationResult)

Source from the content-addressed store, hash-verified

18}
19
20func NewSettingsFormBackups(app *docker.Application, lastResult *docker.OperationResult) SettingsFormBackups {
21 pathField := NewTextField("/path/to/backups")
22 pathField.SetValue(app.Settings.Backup.Path)
23
24 autoBackupField := NewCheckboxField("Automatically create backups", app.Settings.Backup.AutoBackup)
25
26 m := SettingsFormBackups{
27 settingsFormBase: settingsFormBase{
28 title: "Backups",
29 form: NewForm("Done",
30 FormItem{Label: "Backup location", Field: pathField},
31 FormItem{Label: "Backups", Field: autoBackupField},
32 ),
33 },
34 }
35
36 m.statusLine = func() string {
37 return formatOperationStatus("backup", lastResult)
38 }
39
40 m.form.SetActionButton("Run backup now", func() tea.Msg {
41 return settingsRunActionMsg{action: func() (string, error) {
42 return "Backup complete", runBackup(app, pathField.Value())
43 }}
44 })
45 m.form.OnSubmit(func(f *Form) tea.Cmd {
46 s := app.Settings
47 s.Backup.Path = f.TextField(backupsPathField).Value()
48 s.Backup.AutoBackup = f.CheckboxField(backupsAutoBackupField).Checked()
49 return func() tea.Msg { return SettingsSectionSubmitMsg{Settings: s} }
50 })
51 m.form.OnCancel(func(f *Form) tea.Cmd {
52 return func() tea.Msg { return SettingsSectionCancelMsg{} }
53 })
54
55 return m
56}
57
58func (m SettingsFormBackups) Update(msg tea.Msg) (SettingsSection, tea.Cmd) {
59 var cmd tea.Cmd

Calls 14

SetValueMethod · 0.95
ValueMethod · 0.95
NewTextFieldFunction · 0.85
NewCheckboxFieldFunction · 0.85
NewFormFunction · 0.85
formatOperationStatusFunction · 0.85
runBackupFunction · 0.85
SetActionButtonMethod · 0.80
OnSubmitMethod · 0.80
TextFieldMethod · 0.80
CheckedMethod · 0.80
CheckboxFieldMethod · 0.80

Used in the wild real call sites across dependent graphs

searching dependent graphs…