diff --git a/app/helpers/super_admin/account_features_helper.rb b/app/helpers/super_admin/account_features_helper.rb index 759aec134..515c82000 100644 --- a/app/helpers/super_admin/account_features_helper.rb +++ b/app/helpers/super_admin/account_features_helper.rb @@ -6,4 +6,14 @@ module SuperAdmin::AccountFeaturesHelper def self.account_premium_features account_features.filter { |feature| feature['premium'] }.pluck('name') end + + # Accepts account.features as argument + def self.filtered_features(features) + deployment_env = GlobalConfig.get_value('DEPLOYMENT_ENV') + return features if deployment_env == 'cloud' + + # Filter out internal features for non-cloud environments + internal_features = account_features.select { |f| f['chatwoot_internal'] }.pluck('name') + features.except(*internal_features) + end end diff --git a/app/javascript/dashboard/components-next/sidebar/SidebarProfileMenu.vue b/app/javascript/dashboard/components-next/sidebar/SidebarProfileMenu.vue index ba6d84ad1..dcf44b2dc 100644 --- a/app/javascript/dashboard/components-next/sidebar/SidebarProfileMenu.vue +++ b/app/javascript/dashboard/components-next/sidebar/SidebarProfileMenu.vue @@ -5,6 +5,7 @@ import { useMapGetter } from 'dashboard/composables/store'; import { useI18n } from 'vue-i18n'; import Avatar from 'next/avatar/Avatar.vue'; import SidebarProfileMenuStatus from './SidebarProfileMenuStatus.vue'; +import { FEATURE_FLAGS } from 'dashboard/featureFlags'; import { DropdownContainer, @@ -21,14 +22,27 @@ defineOptions({ const { t } = useI18n(); -const globalConfig = useMapGetter('globalConfig/get'); const currentUser = useMapGetter('getCurrentUser'); const currentUserAvailability = useMapGetter('getCurrentUserAvailability'); +const accountId = useMapGetter('getCurrentAccountId'); +const globalConfig = useMapGetter('globalConfig/get'); +const isFeatureEnabledonAccount = useMapGetter( + 'accounts/isFeatureEnabledonAccount' +); + +const showChatSupport = computed(() => { + return ( + isFeatureEnabledonAccount.value( + accountId.value, + FEATURE_FLAGS.CONTACT_CHATWOOT_SUPPORT_TEAM + ) && globalConfig.value.chatwootInboxToken + ); +}); const menuItems = computed(() => { return [ { - show: !!globalConfig.value.chatwootInboxToken, + show: showChatSupport.value, label: t('SIDEBAR_ITEMS.CONTACT_SUPPORT'), icon: 'i-lucide-life-buoy', click: () => { diff --git a/app/javascript/dashboard/components/layout/sidebarComponents/OptionsMenu.vue b/app/javascript/dashboard/components/layout/sidebarComponents/OptionsMenu.vue index 73364f195..4c1367957 100644 --- a/app/javascript/dashboard/components/layout/sidebarComponents/OptionsMenu.vue +++ b/app/javascript/dashboard/components/layout/sidebarComponents/OptionsMenu.vue @@ -4,6 +4,7 @@ import Auth from '../../../api/auth'; import WootDropdownItem from 'shared/components/ui/dropdown/DropdownItem.vue'; import WootDropdownMenu from 'shared/components/ui/dropdown/DropdownMenu.vue'; import AvailabilityStatus from 'dashboard/components/layout/AvailabilityStatus.vue'; +import { FEATURE_FLAGS } from '../../../featureFlags'; export default { components: { @@ -28,6 +29,7 @@ export default { currentUser: 'getCurrentUser', globalConfig: 'globalConfig/get', accountId: 'getCurrentAccountId', + isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount', }), showChangeAccountOption() { if (this.globalConfig.createNewAccountFromDashboard) { @@ -37,6 +39,14 @@ export default { const { accounts = [] } = this.currentUser; return accounts.length > 1; }, + showChatSupport() { + return ( + this.isFeatureEnabledonAccount( + this.accountId, + FEATURE_FLAGS.CONTACT_CHATWOOT_SUPPORT_TEAM + ) && this.globalConfig.chatwootInboxToken + ); + }, }, methods: { handleProfileSettingClick(e, navigate) { @@ -82,7 +92,7 @@ export default { {{ $t('SIDEBAR_ITEMS.CHANGE_ACCOUNTS') }} - +
- <% field.data.each do |key,val| %> + <% SuperAdmin::AccountFeaturesHelper.filtered_features(field.data).each do |key, val| %>
- <% is_premium = SuperAdmin::AccountFeaturesHelper.account_premium_features.include? key %> - <% if is_premium %> - - - - <% end %> - <%= key %> - <% should_disable = is_premium && ChatwootHub.pricing_plan == 'community' %> - <%= check_box "enabled_features", "feature_#{key}", { checked: val, disabled: should_disable }, true, false %> + <% is_premium = SuperAdmin::AccountFeaturesHelper.account_premium_features.include? key %> + <% if is_premium %> + + + + <% end %> + <%= key %> + <% should_disable = is_premium && ChatwootHub.pricing_plan == 'community' %> + <%= check_box "enabled_features", "feature_#{key}", { checked: val, disabled: should_disable }, true, false %>
<% end %>
diff --git a/app/views/fields/account_features_field/_show.html.erb b/app/views/fields/account_features_field/_show.html.erb index c34665393..3bc6cf15e 100644 --- a/app/views/fields/account_features_field/_show.html.erb +++ b/app/views/fields/account_features_field/_show.html.erb @@ -1,5 +1,5 @@
- <% field.data.each do |key,val| %> + <% SuperAdmin::AccountFeaturesHelper.filtered_features(field.data).each do |key, val| %>
<% if SuperAdmin::AccountFeaturesHelper.account_premium_features.include? key %> diff --git a/config/features.yml b/config/features.yml index 8fdab0e3b..59a37a7cf 100644 --- a/config/features.yml +++ b/config/features.yml @@ -71,6 +71,7 @@ - name: response_bot enabled: false premium: true + chatwoot_internal: true - name: message_reply_to enabled: false help_url: https://chwt.app/hc/reply-to @@ -96,3 +97,6 @@ enabled: false - name: report_v4 enabled: false +- name: contact_chatwoot_support_team + enabled: true + chatwoot_internal: true