Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Settings screen for custom branding (#8543)
- Ability to configure Chatwoot custom branding from UI when using paid plans Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
- Loading branch information
1 parent
075b029
commit 34675da
Showing
7 changed files
with
74 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,38 @@ | ||
class SuperAdmin::AppConfigsController < SuperAdmin::ApplicationController | ||
before_action :set_config | ||
before_action :allowed_configs | ||
def show | ||
@allowed_configs = %w[FB_APP_ID FB_VERIFY_TOKEN FB_APP_SECRET] | ||
# ref: https://github.com/rubocop/rubocop/issues/7767 | ||
# rubocop:disable Style/HashTransformValues | ||
@fb_config = InstallationConfig.where(name: @allowed_configs) | ||
.pluck(:name, :serialized_value) | ||
.map { |name, serialized_value| [name, serialized_value['value']] } | ||
.to_h | ||
@app_config = InstallationConfig.where(name: @allowed_configs) | ||
.pluck(:name, :serialized_value) | ||
.map { |name, serialized_value| [name, serialized_value['value']] } | ||
.to_h | ||
# rubocop:enable Style/HashTransformValues | ||
end | ||
|
||
def create | ||
params['app_config'].each do |key, value| | ||
next unless @allowed_configs.include?(key) | ||
|
||
i = InstallationConfig.where(name: key).first_or_create(value: value, locked: false) | ||
i.value = value | ||
i.save! | ||
end | ||
redirect_to super_admin_app_config_url | ||
# rubocop:disable Rails/I18nLocaleTexts | ||
redirect_to super_admin_settings_path, notice: 'App Configs updated successfully' | ||
# rubocop:enable Rails/I18nLocaleTexts | ||
end | ||
|
||
private | ||
|
||
def set_config | ||
@config = params[:config] | ||
end | ||
|
||
def allowed_configs | ||
@allowed_configs = %w[FB_APP_ID FB_VERIFY_TOKEN FB_APP_SECRET] | ||
end | ||
end | ||
|
||
SuperAdmin::AppConfigsController.prepend_mod_with('SuperAdmin::AppConfigsController') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
enterprise/app/controllers/enterprise/super_admin/app_configs_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Enterprise::SuperAdmin::AppConfigsController | ||
private | ||
|
||
def allowed_configs | ||
return super if ChatwootHub.pricing_plan == 'community' | ||
|
||
case @config | ||
when 'custom_branding' | ||
@allowed_configs = %w[ | ||
LOGO_THUMBNAIL | ||
LOGO | ||
BRAND_NAME | ||
INSTALLATION_NAME | ||
BRAND_URL | ||
WIDGET_BRAND_URL | ||
TERMS_URL | ||
PRIVACY_URL | ||
] | ||
else | ||
super | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters