Add new fields to /api/config to remove /settings dependency in camapign UI.

This commit is contained in:
Kailash Nadh 2024-06-19 17:00:41 +05:30
parent f69aa300b4
commit 19527f97eb
2 changed files with 11 additions and 7 deletions

View file

@ -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

View file

@ -214,9 +214,8 @@
<b-switch data-cy="btn-archive" v-model="form.archive" :disabled="!canArchive" />
</div>
<div class="column is-12">
<a :href="`${settings['app.root_url']}/archive/${data.uuid}`" target="_blank"
rel="noopener noreferer" :class="{ 'has-text-grey-light': !form.archive }"
aria-label="$t('campaigns.archive')">
<a :href="`${serverConfig.root_url}/archive/${data.uuid}`" target="_blank" rel="noopener noreferer"
:class="{ 'has-text-grey-light': !form.archive }" aria-label="$t('campaigns.archive')">
<b-icon icon="link-variant" />
</a>
</div>
@ -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;