mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
- Improve how settings are rendered in Chatwoot Super admin panel - Add google settings support - show setting for community edition ## Settings page - community edition <img width="1702" alt="Screenshot 2025-07-08 at 9 08 03 PM" src="https://github.com/user-attachments/assets/0434f56f-ea74-44a8-a7b0-8e26fab88093" /> ## Expanded settings <img width="1675" alt="Screenshot 2025-07-03 at 2 17 16 AM" src="https://github.com/user-attachments/assets/3aa1f888-c54a-4b58-896a-0d3e828fa176" /> --------- Co-authored-by: Sojan Jose <sojan@Sojans-MacBook-Pro.local> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
53 lines
2.3 KiB
Ruby
53 lines
2.3 KiB
Ruby
class SuperAdmin::AppConfigsController < SuperAdmin::ApplicationController
|
|
before_action :set_config
|
|
before_action :allowed_configs
|
|
def show
|
|
# ref: https://github.com/rubocop/rubocop/issues/7767
|
|
# rubocop:disable Style/HashTransformValues
|
|
@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
|
|
@installation_configs = ConfigLoader.new.general_configs.each_with_object({}) do |config_hash, result|
|
|
result[config_hash['name']] = config_hash.except('name')
|
|
end
|
|
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_settings_path, notice: "App Configs - #{@config.titleize} updated successfully"
|
|
end
|
|
|
|
private
|
|
|
|
def set_config
|
|
@config = params[:config] || 'general'
|
|
end
|
|
|
|
def allowed_configs
|
|
mapping = {
|
|
'facebook' => %w[FB_APP_ID FB_VERIFY_TOKEN FB_APP_SECRET IG_VERIFY_TOKEN FACEBOOK_API_VERSION ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT],
|
|
'shopify' => %w[SHOPIFY_CLIENT_ID SHOPIFY_CLIENT_SECRET],
|
|
'microsoft' => %w[AZURE_APP_ID AZURE_APP_SECRET],
|
|
'email' => ['MAILER_INBOUND_EMAIL_DOMAIN'],
|
|
'linear' => %w[LINEAR_CLIENT_ID LINEAR_CLIENT_SECRET],
|
|
'slack' => %w[SLACK_CLIENT_ID SLACK_CLIENT_SECRET],
|
|
'instagram' => %w[INSTAGRAM_APP_ID INSTAGRAM_APP_SECRET INSTAGRAM_VERIFY_TOKEN INSTAGRAM_API_VERSION ENABLE_INSTAGRAM_CHANNEL_HUMAN_AGENT],
|
|
'whatsapp_embedded' => %w[WHATSAPP_APP_ID WHATSAPP_APP_SECRET WHATSAPP_CONFIGURATION_ID WHATSAPP_API_VERSION],
|
|
'notion' => %w[NOTION_CLIENT_ID NOTION_CLIENT_SECRET],
|
|
'google' => %w[GOOGLE_OAUTH_CLIENT_ID GOOGLE_OAUTH_CLIENT_SECRET GOOGLE_OAUTH_REDIRECT_URI]
|
|
}
|
|
|
|
@allowed_configs = mapping.fetch(@config, %w[ENABLE_ACCOUNT_SIGNUP FIREBASE_PROJECT_ID FIREBASE_CREDENTIALS])
|
|
end
|
|
end
|
|
|
|
SuperAdmin::AppConfigsController.prepend_mod_with('SuperAdmin::AppConfigsController')
|