Skip to content

Commit

Permalink
Refactor retention days help text and form validation
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardolat committed Aug 5, 2024
1 parent 3d18ec6 commit 59bef0c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
18 changes: 13 additions & 5 deletions internal/view/web/dashboard/backups/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,19 @@ func destinationDirectoryHelp() []gomponents.Node {

func retentionDaysHelp() []gomponents.Node {
return []gomponents.Node{
component.PText(`
Retention days specifies the number of days to keep backup files before
they are automatically deleted. This ensures that old backups are removed
to save storage space. The retention period is evaluated by execution.
`),
html.Div(
html.Class("space-y-2"),

component.PText(`
Retention days specifies the number of days to keep backup files before
they are automatically deleted. This ensures that old backups are removed
to save storage space. The retention period is evaluated by execution.
`),

component.PText(`
If you set the retention days to 0, the backups will never be deleted.
`),
),
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/view/web/dashboard/backups/create_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (h *handlers) createBackupHandler(c echo.Context) error {
TimeZone string `form:"time_zone" validate:"required"`
IsActive string `form:"is_active" validate:"required,oneof=true false"`
DestDir string `form:"dest_dir" validate:"required"`
RetentionDays int16 `form:"retention_days" validate:"required"`
RetentionDays int16 `form:"retention_days"`
OptDataOnly string `form:"opt_data_only" validate:"required,oneof=true false"`
OptSchemaOnly string `form:"opt_schema_only" validate:"required,oneof=true false"`
OptClean string `form:"opt_clean" validate:"required,oneof=true false"`
Expand Down
2 changes: 1 addition & 1 deletion internal/view/web/dashboard/backups/edit_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (h *handlers) editBackupHandler(c echo.Context) error {
TimeZone string `form:"time_zone" validate:"required"`
IsActive string `form:"is_active" validate:"required,oneof=true false"`
DestDir string `form:"dest_dir" validate:"required"`
RetentionDays int16 `form:"retention_days" validate:"required"`
RetentionDays int16 `form:"retention_days"`
OptDataOnly string `form:"opt_data_only" validate:"required,oneof=true false"`
OptSchemaOnly string `form:"opt_schema_only" validate:"required,oneof=true false"`
OptClean string `form:"opt_clean" validate:"required,oneof=true false"`
Expand Down
11 changes: 10 additions & 1 deletion internal/view/web/dashboard/backups/list_backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,16 @@ func listBackups(
component.SpanText(backup.TimeZone),
),
),
html.Td(component.SpanText(fmt.Sprintf("%d days", backup.RetentionDays))),
html.Td(
gomponents.If(
backup.RetentionDays == 0,
lucide.Infinity(),
),
gomponents.If(
backup.RetentionDays > 0,
component.SpanText(fmt.Sprintf("%d days", backup.RetentionDays)),
),
),
html.Td(yesNoSpan(backup.OptDataOnly)),
html.Td(yesNoSpan(backup.OptSchemaOnly)),
html.Td(yesNoSpan(backup.OptClean)),
Expand Down

0 comments on commit 59bef0c

Please sign in to comment.