(app *docker.Application, lastResult *docker.OperationResult)
| 18 | } |
| 19 | |
| 20 | func 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 | |
| 58 | func (m SettingsFormBackups) Update(msg tea.Msg) (SettingsSection, tea.Cmd) { |
| 59 | var cmd tea.Cmd |
searching dependent graphs…