From 97b5cd306f44a23d5f8923b1cf750533c1ca3e10 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 1 Sep 2023 17:47:37 +0200 Subject: [PATCH] feat: add demo mode flag Related to https://kolaente.dev/vikunja/frontend/issues/2453 --- config.yml.sample | 3 +++ docs/content/doc/setup/config.md | 12 ++++++++++++ pkg/config/config.go | 2 ++ pkg/routes/api/v1/info.go | 2 ++ 4 files changed, 19 insertions(+) diff --git a/config.yml.sample b/config.yml.sample index fa1820bdf..252904277 100644 --- a/config.yml.sample +++ b/config.yml.sample @@ -59,6 +59,9 @@ service: # The maximum size clients will be able to request for user avatars. # If clients request a size bigger than this, it will be changed on the fly. maxavatarsize: 1024 + # If set to true, the frontend will show a big red warning not to use this instance for real data as it will be cleared out. + # You probably don't need to set this value, it was created specifically for usage on [try](https://try.vikunja.io). + demomode: false database: # Database type to use. Supported types are mysql, postgres and sqlite. diff --git a/docs/content/doc/setup/config.md b/docs/content/doc/setup/config.md index 8cc0d147c..e25f31126 100644 --- a/docs/content/doc/setup/config.md +++ b/docs/content/doc/setup/config.md @@ -333,6 +333,18 @@ Full path: `service.maxavatarsize` Environment path: `VIKUNJA_SERVICE_MAXAVATARSIZE` +### demomode + +If set to true, the frontend will show a big red warning not to use this instance for real data as it will be cleared out. +You probably don't need to set this value, it was created specifically for usage on [try](https://try.vikunja.io). + +Default: `false` + +Full path: `service.demomode` + +Environment path: `VIKUNJA_SERVICE_DEMOMODE` + + --- ## database diff --git a/pkg/config/config.go b/pkg/config/config.go index 1e0ca1d67..c8ad843ac 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -49,6 +49,7 @@ const ( ServiceRootpath Key = `service.rootpath` ServiceStaticpath Key = `service.staticpath` ServiceMaxItemsPerPage Key = `service.maxitemsperpage` + ServiceDemoMode Key = `service.demomode` // Deprecated: Use metrics.enabled ServiceEnableMetrics Key = `service.enablemetrics` ServiceMotd Key = `service.motd` @@ -300,6 +301,7 @@ func InitDefaultConfig() { ServiceEnableEmailReminders.setDefault(true) ServiceEnableUserDeletion.setDefault(true) ServiceMaxAvatarSize.setDefault(1024) + ServiceDemoMode.setDefault(false) // Auth AuthLocalEnabled.setDefault(true) diff --git a/pkg/routes/api/v1/info.go b/pkg/routes/api/v1/info.go index c0398d485..d2be79da8 100644 --- a/pkg/routes/api/v1/info.go +++ b/pkg/routes/api/v1/info.go @@ -49,6 +49,7 @@ type vikunjaInfos struct { EmailRemindersEnabled bool `json:"email_reminders_enabled"` UserDeletionEnabled bool `json:"user_deletion_enabled"` TaskCommentsEnabled bool `json:"task_comments_enabled"` + DemoModeEnabled bool `json:"demo_mode_enabled"` } type authInfo struct { @@ -92,6 +93,7 @@ func Info(c echo.Context) error { EmailRemindersEnabled: config.ServiceEnableEmailReminders.GetBool(), UserDeletionEnabled: config.ServiceEnableUserDeletion.GetBool(), TaskCommentsEnabled: config.ServiceEnableTaskComments.GetBool(), + DemoModeEnabled: config.ServiceDemoMode.GetBool(), AvailableMigrators: []string{ (&vikunja_file.FileMigrator{}).Name(), (&ticktick.Migrator{}).Name(),