chore: Add display manifest to whitelabel settings (#8708)
- Adds display manifest to white label settings - Improve the app config rendering with options for display name and description
This commit is contained in:
@@ -9,6 +9,9 @@ class SuperAdmin::AppConfigsController < SuperAdmin::ApplicationController
|
|||||||
.map { |name, serialized_value| [name, serialized_value['value']] }
|
.map { |name, serialized_value| [name, serialized_value['value']] }
|
||||||
.to_h
|
.to_h
|
||||||
# rubocop:enable Style/HashTransformValues
|
# rubocop:enable Style/HashTransformValues
|
||||||
|
@installation_configs = ConfigLoader.new.general_configs.each_with_object({}) do |config_hash, result|
|
||||||
|
result[config_hash['name']] = config_hash.except('name')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|||||||
@@ -8,13 +8,26 @@
|
|||||||
</header>
|
</header>
|
||||||
<section class="main-content__body">
|
<section class="main-content__body">
|
||||||
<%= form_with url: super_admin_app_config_url(config: @config) , method: :post do |form| %>
|
<%= form_with url: super_admin_app_config_url(config: @config) , method: :post do |form| %>
|
||||||
<% @allowed_configs.each do |c| %>
|
<% @allowed_configs.each do |key| %>
|
||||||
<div class="field-unit">
|
<div class="flex mb-8">
|
||||||
<div class="field-unit__label">
|
<div class="field-unit__label">
|
||||||
<%= form.label "app_config[#{c}]", c %>
|
<%= form.label "app_config[#{key}]", @installation_configs[key]&.dig('display_title') || key %>
|
||||||
</div>
|
</div>
|
||||||
<div class="field-unit__field">
|
<div class="field-unit__field -mt-2 ">
|
||||||
<%= form.text_field "app_config[#{c}]", value: @app_config[c] %>
|
<% if @installation_configs[key]&.dig('type') == 'boolean' %>
|
||||||
|
<%= form.select "app_config[#{key}]",
|
||||||
|
[["True", true], ["False", false]],
|
||||||
|
{ selected: ActiveModel::Type::Boolean.new.cast(@app_config[key]) },
|
||||||
|
class: "mt-2 border border-slate-100 p-1 rounded-md"
|
||||||
|
%>
|
||||||
|
<% else %>
|
||||||
|
<%= form.text_field "app_config[#{key}]", value: @app_config[key] %>
|
||||||
|
<% end %>
|
||||||
|
<%if @installation_configs[key]&.dig('description').present? %>
|
||||||
|
<p class="text-slate-400 text-xs italic pt-2">
|
||||||
|
<%= @installation_configs[key]&.dig('description') %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,23 +1,46 @@
|
|||||||
# if you dont specify locked attribute, the default value will be true
|
# if you don't specify locked attribute, the default value will be true
|
||||||
# which means the particular config will be locked
|
# which means the particular config will be locked
|
||||||
- name: INSTALLATION_NAME
|
- name: INSTALLATION_NAME
|
||||||
value: 'Chatwoot'
|
value: 'Chatwoot'
|
||||||
|
display_title: 'Installation Name'
|
||||||
|
description: 'The installation wide name that would be used in the dashboard, title etc.'
|
||||||
- name: LOGO_THUMBNAIL
|
- name: LOGO_THUMBNAIL
|
||||||
value: '/brand-assets/logo_thumbnail.svg'
|
value: '/brand-assets/logo_thumbnail.svg'
|
||||||
|
display_title: 'Logo Thumbnail'
|
||||||
|
description: 'The thumbnail that would be used for favicon (512px X 512px)'
|
||||||
- name: LOGO
|
- name: LOGO
|
||||||
value: '/brand-assets/logo.svg'
|
value: '/brand-assets/logo.svg'
|
||||||
|
display_title: 'Logo'
|
||||||
|
description: 'The logo that would be used on the dashboard, login page etc.'
|
||||||
|
- name: LOGO_DARK
|
||||||
|
value: '/brand-assets/logo_dark.svg'
|
||||||
|
display_title: 'Logo Dark Mode'
|
||||||
|
description: 'The logo that would be used on the dashboard, login page etc. for dark mode'
|
||||||
- name: BRAND_URL
|
- name: BRAND_URL
|
||||||
value: 'https://www.chatwoot.com'
|
value: 'https://www.chatwoot.com'
|
||||||
|
display_title: 'Brand URL'
|
||||||
|
description: 'The URL that would be used in emails under the section “Powered By”'
|
||||||
- name: WIDGET_BRAND_URL
|
- name: WIDGET_BRAND_URL
|
||||||
value: 'https://www.chatwoot.com'
|
value: 'https://www.chatwoot.com'
|
||||||
|
display_title: 'Widget Brand URL'
|
||||||
|
description: 'The URL that would be used in the widget under the section “Powered By”'
|
||||||
- name: BRAND_NAME
|
- name: BRAND_NAME
|
||||||
value: 'Chatwoot'
|
value: 'Chatwoot'
|
||||||
|
display_title: 'Brand Name'
|
||||||
|
description: 'The name that would be used in emails and the widget'
|
||||||
- name: TERMS_URL
|
- name: TERMS_URL
|
||||||
value: 'https://www.chatwoot.com/terms-of-service'
|
value: 'https://www.chatwoot.com/terms-of-service'
|
||||||
|
display_title: 'Terms URL'
|
||||||
|
description: 'The terms of service URL displayed in Signup Page'
|
||||||
- name: PRIVACY_URL
|
- name: PRIVACY_URL
|
||||||
value: 'https://www.chatwoot.com/privacy-policy'
|
value: 'https://www.chatwoot.com/privacy-policy'
|
||||||
|
display_title: 'Privacy URL'
|
||||||
|
description: 'The privacy policy URL displayed in the app'
|
||||||
- name: DISPLAY_MANIFEST
|
- name: DISPLAY_MANIFEST
|
||||||
value: true
|
value: true
|
||||||
|
display_title: 'Chatwoot Metadata'
|
||||||
|
description: 'Display default Chatwoot metadata like favicons and upgrade warnings'
|
||||||
|
type: boolean
|
||||||
- name: MAILER_INBOUND_EMAIL_DOMAIN
|
- name: MAILER_INBOUND_EMAIL_DOMAIN
|
||||||
value:
|
value:
|
||||||
locked: false
|
locked: false
|
||||||
@@ -72,8 +95,6 @@
|
|||||||
value: self-hosted
|
value: self-hosted
|
||||||
- name: CSML_EDITOR_HOST
|
- name: CSML_EDITOR_HOST
|
||||||
value:
|
value:
|
||||||
- name: LOGO_DARK
|
|
||||||
value: '/brand-assets/logo_dark.svg'
|
|
||||||
- name: INSTALLATION_PRICING_PLAN
|
- name: INSTALLATION_PRICING_PLAN
|
||||||
value: 'community'
|
value: 'community'
|
||||||
- name: INSTALLATION_PRICING_PLAN_QUANTITY
|
- name: INSTALLATION_PRICING_PLAN_QUANTITY
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ module Enterprise::SuperAdmin::AppConfigsController
|
|||||||
WIDGET_BRAND_URL
|
WIDGET_BRAND_URL
|
||||||
TERMS_URL
|
TERMS_URL
|
||||||
PRIVACY_URL
|
PRIVACY_URL
|
||||||
|
DISPLAY_MANIFEST
|
||||||
]
|
]
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
|
|||||||
@@ -26,12 +26,13 @@ class ConfigLoader
|
|||||||
reconcile_feature_config
|
reconcile_feature_config
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def general_configs
|
def general_configs
|
||||||
|
@config_path ||= Rails.root.join('config')
|
||||||
@general_configs ||= YAML.safe_load(File.read("#{@config_path}/installation_config.yml")).freeze
|
@general_configs ||= YAML.safe_load(File.read("#{@config_path}/installation_config.yml")).freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
def account_features
|
def account_features
|
||||||
@account_features ||= YAML.safe_load(File.read("#{@config_path}/features.yml")).freeze
|
@account_features ||= YAML.safe_load(File.read("#{@config_path}/features.yml")).freeze
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class GlobalConfig
|
|||||||
config[config_key] = load_from_cache(config_key)
|
config[config_key] = load_from_cache(config_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
typecast_config(config)
|
||||||
config.with_indifferent_access
|
config.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -28,6 +29,14 @@ class GlobalConfig
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def typecast_config(config)
|
||||||
|
general_configs = ConfigLoader.new.general_configs
|
||||||
|
config.each do |config_key, config_value|
|
||||||
|
config_type = general_configs.find { |c| c['name'] == config_key }&.dig('type')
|
||||||
|
config[config_key] = ActiveRecord::Type::Boolean.new.cast(config_value) if config_type == 'boolean'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def load_from_cache(config_key)
|
def load_from_cache(config_key)
|
||||||
cache_key = "#{VERSION}:#{KEY_PREFIX}:#{config_key}"
|
cache_key = "#{VERSION}:#{KEY_PREFIX}:#{config_key}"
|
||||||
cached_value = $alfred.with { |conn| conn.get(cache_key) }
|
cached_value = $alfred.with { |conn| conn.get(cache_key) }
|
||||||
|
|||||||
Reference in New Issue
Block a user