From 19527f97ebc7b87a74108c2ad64fa47153a4b0ac Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Wed, 19 Jun 2024 17:00:41 +0530 Subject: [PATCH] Add new fields to `/api/config` to remove `/settings` dependency in camapign UI. --- cmd/admin.go | 11 ++++++++--- frontend/src/views/Campaign.vue | 7 +++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/admin.go b/cmd/admin.go index 2171bc41..36dd2c52 100644 --- a/cmd/admin.go +++ b/cmd/admin.go @@ -12,6 +12,8 @@ import ( ) type serverConfig struct { + RootURL string `json:"root_url"` + FromEmail string `json:"from_email"` Messengers []string `json:"messengers"` Langs []i18nLang `json:"langs"` Lang string `json:"lang"` @@ -25,8 +27,13 @@ type serverConfig struct { func handleGetServerConfig(c echo.Context) error { var ( app = c.Get("app").(*App) - out = serverConfig{} ) + out := serverConfig{ + RootURL: app.constants.RootURL, + FromEmail: app.constants.FromEmail, + Lang: app.constants.Lang, + Permissions: app.constants.PermissionsRaw, + } // Language list. langList, err := getI18nLangList(app.constants.Lang, app) @@ -35,8 +42,6 @@ func handleGetServerConfig(c echo.Context) error { fmt.Sprintf("Error loading language list: %v", err)) } out.Langs = langList - out.Lang = app.constants.Lang - out.Permissions = app.constants.PermissionsRaw // Sort messenger names with `email` always as the first item. var names []string diff --git a/frontend/src/views/Campaign.vue b/frontend/src/views/Campaign.vue index a3db59f4..1898f6ce 100644 --- a/frontend/src/views/Campaign.vue +++ b/frontend/src/views/Campaign.vue @@ -214,9 +214,8 @@ @@ -649,7 +648,7 @@ export default Vue.extend({ window.onbeforeunload = () => this.isUnsaved() || null; // Fill default form fields. - this.form.fromEmail = this.settings['app.from_email']; + this.form.fromEmail = this.serverConfig.from_email; // New campaign. const { id } = this.$route.params;