From 7b05c492153fea1c52fae473e5d8c83d939407f6 Mon Sep 17 00:00:00 2001 From: Yash Jipkate <34203227+YashJipkate@users.noreply.github.com> Date: Mon, 31 May 2021 01:06:10 +0530 Subject: [PATCH] Add devEnableShare config option (#1141) * add devEnableShare config option * Toggle in config.js --- conf/configuration.go | 2 ++ server/app/serve_index.go | 1 + server/app/serve_index_test.go | 10 ++++++++++ ui/src/config.js | 1 + 4 files changed, 14 insertions(+) diff --git a/conf/configuration.go b/conf/configuration.go index cd0bd8034..fb540f1c6 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -64,6 +64,7 @@ type configOptions struct { DevFastAccessCoverArt bool DevOldCacheLayout bool DevActivityPanel bool + DevEnableShare bool } type scannerOptions struct { @@ -211,6 +212,7 @@ func init() { viper.SetDefault("devoldcachelayout", false) viper.SetDefault("devFastAccessCoverArt", false) viper.SetDefault("devactivitypanel", true) + viper.SetDefault("devenableshare", false) } func InitConfig(cfgFile string) { diff --git a/server/app/serve_index.go b/server/app/serve_index.go index 02f54b4e4..8d35af207 100644 --- a/server/app/serve_index.go +++ b/server/app/serve_index.go @@ -49,6 +49,7 @@ func serveIndex(ds model.DataStore, fs fs.FS) http.HandlerFunc { "devActivityPanel": conf.Server.DevActivityPanel, "devFastAccessCoverArt": conf.Server.DevFastAccessCoverArt, "enableUserEditing": conf.Server.EnableUserEditing, + "devEnableShare": conf.Server.DevEnableShare, } j, err := json.Marshal(appConfig) if err != nil { diff --git a/server/app/serve_index_test.go b/server/app/serve_index_test.go index 04f4c80c9..ab6daa8dc 100644 --- a/server/app/serve_index_test.go +++ b/server/app/serve_index_test.go @@ -199,6 +199,16 @@ var _ = Describe("serveIndex", func() { config := extractAppConfig(w.Body.String()) Expect(config).To(HaveKeyWithValue("enableUserEditing", true)) }) + + It("sets the devEnableShare", func() { + r := httptest.NewRequest("GET", "/index.html", nil) + w := httptest.NewRecorder() + + serveIndex(ds, fs)(w, r) + + config := extractAppConfig(w.Body.String()) + Expect(config).To(HaveKeyWithValue("devEnableShare", false)) + }) }) var appConfigRegex = regexp.MustCompile(`(?m)window.__APP_CONFIG__="([^"]*)`) diff --git a/ui/src/config.js b/ui/src/config.js index ec7a3c8b2..5d8f9123c 100644 --- a/ui/src/config.js +++ b/ui/src/config.js @@ -18,6 +18,7 @@ const defaultConfig = { enableStarRating: true, defaultTheme: 'Dark', enableUserEditing: true, + devEnableShare: true, } let config