diff --git a/app/controllers/super_admin/accounts_controller.rb b/app/controllers/super_admin/accounts_controller.rb index 5bc487475..3f1e15cdc 100644 --- a/app/controllers/super_admin/accounts_controller.rb +++ b/app/controllers/super_admin/accounts_controller.rb @@ -36,6 +36,7 @@ class SuperAdmin::AccountsController < SuperAdmin::ApplicationController def resource_params permitted_params = super permitted_params[:limits] = permitted_params[:limits].to_h.compact + permitted_params[:selected_feature_flags] = params[:enabled_features].keys.map(&:to_sym) if params[:enabled_features].present? permitted_params end diff --git a/app/dashboards/account_dashboard.rb b/app/dashboards/account_dashboard.rb index 0dfe7bbcd..50cd3f8f6 100644 --- a/app/dashboards/account_dashboard.rb +++ b/app/dashboards/account_dashboard.rb @@ -8,7 +8,15 @@ class AccountDashboard < Administrate::BaseDashboard # which determines how the attribute is displayed # on pages throughout the dashboard. - enterprise_attribute_types = ChatwootApp.enterprise? ? { limits: Enterprise::AccountLimitsField } : {} + enterprise_attribute_types = if ChatwootApp.enterprise? + { + limits: Enterprise::AccountLimitsField, + all_features: Enterprise::AccountFeaturesField + } + else + {} + end + ATTRIBUTE_TYPES = { id: Field::Number, name: Field::String, @@ -37,7 +45,7 @@ class AccountDashboard < Administrate::BaseDashboard # SHOW_PAGE_ATTRIBUTES # an array of attributes that will be displayed on the model's show page. - enterprise_show_page_attributes = ChatwootApp.enterprise? ? %i[limits] : [] + enterprise_show_page_attributes = ChatwootApp.enterprise? ? %i[limits all_features] : [] SHOW_PAGE_ATTRIBUTES = (%i[ id name @@ -52,7 +60,7 @@ class AccountDashboard < Administrate::BaseDashboard # FORM_ATTRIBUTES # an array of attributes that will be displayed # on the model's form (`new` and `edit`) pages. - enterprise_form_attributes = ChatwootApp.enterprise? ? %i[limits] : [] + enterprise_form_attributes = ChatwootApp.enterprise? ? %i[limits all_features] : [] FORM_ATTRIBUTES = (%i[ name locale diff --git a/app/fields/enterprise/account_features_field.rb b/app/fields/enterprise/account_features_field.rb new file mode 100644 index 000000000..7a9de5a59 --- /dev/null +++ b/app/fields/enterprise/account_features_field.rb @@ -0,0 +1,7 @@ +require 'administrate/field/base' + +class Enterprise::AccountFeaturesField < Administrate::Field::Base + def to_s + data + end +end diff --git a/app/views/fields/account_features_field/_form.html.erb b/app/views/fields/account_features_field/_form.html.erb new file mode 100644 index 000000000..823a043a6 --- /dev/null +++ b/app/views/fields/account_features_field/_form.html.erb @@ -0,0 +1,8 @@ +