From e94b276f642f511108ba9e595288657e1ab3a5df Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 21 Mar 2024 23:00:46 +0530 Subject: [PATCH] feat: Add help URLs for features in features.yml (#9134) Co-authored-by: Pranav --- app/helpers/application_helper.rb | 7 +++++++ app/javascript/dashboard/featureFlags.js | 10 ++++++++++ app/javascript/dashboard/helper/featureHelper.js | 4 ++++ app/views/layouts/vueapp.html.erb | 1 + config/features.yml | 13 ++++++++++++- 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 app/javascript/dashboard/helper/featureHelper.js diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b52b2300e..76d0bacc8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2,4 +2,11 @@ module ApplicationHelper def available_locales_with_name LANGUAGES_CONFIG.map { |_key, val| val.slice(:name, :iso_639_1_code) } end + + def feature_help_urls + features = YAML.safe_load(Rails.root.join('config/features.yml').read).freeze + features.each_with_object({}) do |feature, hash| + hash[feature['name']] = feature['help_url'] if feature['help_url'] + end + end end diff --git a/app/javascript/dashboard/featureFlags.js b/app/javascript/dashboard/featureFlags.js index f2fd3e757..a0453b7d3 100644 --- a/app/javascript/dashboard/featureFlags.js +++ b/app/javascript/dashboard/featureFlags.js @@ -20,4 +20,14 @@ export const FEATURE_FLAGS = { INBOX_VIEW: 'inbox_view', SLA: 'sla', RESPONSE_BOT: 'response_bot', + CHANNEL_EMAIL: 'channel_email', + CHANNEL_FACEBOOK: 'channel_facebook', + CHANNEL_TWITTER: 'channel_twitter', + CHANNEL_WEBSITE: 'channel_website', + CUSTOM_REPLY_DOMAIN: 'custom_reply_domain', + CUSTOM_REPLY_EMAIL: 'custom_reply_email', + DISABLE_BRANDING: 'disable_branding', + EMAIL_CONTINUITY_ON_API_CHANNEL: 'email_continuity_on_api_channel', + INBOUND_EMAILS: 'inbound_emails', + IP_LOOKUP: 'ip_lookup', }; diff --git a/app/javascript/dashboard/helper/featureHelper.js b/app/javascript/dashboard/helper/featureHelper.js new file mode 100644 index 000000000..edbbf4472 --- /dev/null +++ b/app/javascript/dashboard/helper/featureHelper.js @@ -0,0 +1,4 @@ +export function getHelpUrlForFeature(featureName) { + const { helpUrls } = window.chatwootConfig; + return helpUrls[featureName]; +} diff --git a/app/views/layouts/vueapp.html.erb b/app/views/layouts/vueapp.html.erb index 2e49a7b96..a80f23cce 100644 --- a/app/views/layouts/vueapp.html.erb +++ b/app/views/layouts/vueapp.html.erb @@ -44,6 +44,7 @@ vapidPublicKey: new Uint8Array(<%= Base64.urlsafe_decode64(@global_config['VAPID_PUBLIC_KEY']).bytes %>), <% end %> enabledLanguages: <%= available_locales_with_name.to_json.html_safe %>, + helpUrls: <%= feature_help_urls.to_json.html_safe %>, selectedLocale: '<%= I18n.locale %>' } window.globalConfig = <%= raw @global_config.to_json %> diff --git a/config/features.yml b/config/features.yml index f0477c297..37439c31f 100644 --- a/config/features.yml +++ b/config/features.yml @@ -3,37 +3,45 @@ enabled: true - name: channel_email enabled: true + help_url: https://chwt.app/hc/email - name: channel_facebook enabled: true + help_url: https://chwt.app/hc/fb - name: channel_twitter enabled: true - name: ip_lookup enabled: false - name: disable_branding enabled: false - premium: true + premium: true - name: email_continuity_on_api_channel enabled: false - name: help_center enabled: true + help_url: https://chwt.app/hc/help-center - name: agent_bots enabled: false + help_url: https://chwt.app/hc/agent-bots - name: macros enabled: true - name: agent_management enabled: true - name: team_management enabled: true + help_url: https://chwt.app/hc/teams - name: inbox_management enabled: true - name: labels enabled: true + help_url: https://chwt.app/hc/labels - name: custom_attributes enabled: true + help_url: https://chwt.app/hc/custom-attributes - name: automations enabled: true - name: canned_responses enabled: true + help_url: https://chwt.app/hc/canned - name: integrations enabled: true - name: voice_recorder @@ -44,8 +52,10 @@ enabled: true - name: campaigns enabled: true + help_url: https://chwt.app/hc/campaigns - name: reports enabled: true + help_url: https://chwt.app/hc/reports - name: crm enabled: true - name: auto_resolve_conversations @@ -62,6 +72,7 @@ premium: true - name: message_reply_to enabled: false + help_url: https://chwt.app/hc/reply-to - name: insert_article_in_reply enabled: false - name: inbox_view