From a44531c6a76d902357839dfb7ebffe3a515c1ec3 Mon Sep 17 00:00:00 2001 From: Bob Develop Date: Tue, 21 Apr 2026 13:28:29 -0400 Subject: [PATCH] feat(settings): UI visibility prefs for console/api/test-mode; remove plans upsell --- .../personalization_settings_controller.rb | 3 ++ app/models/account_config.rb | 3 ++ .../_ui_visibility_form.html.erb | 33 ++++++++++++++ .../personalization_settings/show.html.erb | 1 + app/views/shared/_navbar.html.erb | 4 +- app/views/shared/_settings_nav.html.erb | 14 ++---- config/locales/i18n.yml | 5 +++ playwright/tests/v0.3.0-ui-visibility.spec.ts | 43 +++++++++++++++++++ 8 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 app/views/personalization_settings/_ui_visibility_form.html.erb create mode 100644 playwright/tests/v0.3.0-ui-visibility.spec.ts diff --git a/app/controllers/personalization_settings_controller.rb b/app/controllers/personalization_settings_controller.rb index d9d33490..1d399bba 100644 --- a/app/controllers/personalization_settings_controller.rb +++ b/app/controllers/personalization_settings_controller.rb @@ -8,6 +8,9 @@ class PersonalizationSettingsController < ApplicationController AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY, AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY, AccountConfig::FORM_COMPLETED_MESSAGE_KEY, + AccountConfig::SHOW_CONSOLE_LINK_KEY, + AccountConfig::SHOW_API_LINK_KEY, + AccountConfig::SHOW_TEST_MODE_KEY, *(Docuseal.multitenant? ? [] : [AccountConfig::POLICY_LINKS_KEY]) ].freeze diff --git a/app/models/account_config.rb b/app/models/account_config.rb index 631e5385..fd8220a6 100644 --- a/app/models/account_config.rb +++ b/app/models/account_config.rb @@ -59,6 +59,9 @@ class AccountConfig < ApplicationRecord TEMPLATE_CUSTOM_FIELDS_KEY = 'template_custom_fields' POLICY_LINKS_KEY = 'policy_links' ENABLE_MCP_KEY = 'enable_mcp' + SHOW_CONSOLE_LINK_KEY = 'show_console_link' + SHOW_API_LINK_KEY = 'show_api_link' + SHOW_TEST_MODE_KEY = 'show_test_mode' EMAIL_VARIABLES = { SUBMITTER_INVITATION_EMAIL_KEY => %w[template.name submitter.link account.name].freeze, diff --git a/app/views/personalization_settings/_ui_visibility_form.html.erb b/app/views/personalization_settings/_ui_visibility_form.html.erb new file mode 100644 index 00000000..59f40660 --- /dev/null +++ b/app/views/personalization_settings/_ui_visibility_form.html.erb @@ -0,0 +1,33 @@ +
+

<%= t('ui_visibility') %>

+ <% [ + [AccountConfig::SHOW_CONSOLE_LINK_KEY, t('show_console_link')], + [AccountConfig::SHOW_API_LINK_KEY, t('show_api_link')], + [AccountConfig::SHOW_TEST_MODE_KEY, t('show_test_mode')] + ].each do |key, label| %> + <% env_var_name = "DOCUSEAL_CONFIG_#{key.upcase}" %> + <% locked = ENV.fetch(env_var_name, nil).present? %> + <% current = current_account.ui_visible?(key, default: true) %> + <%= form_for(AccountConfig.new, + url: settings_personalization_index_path, + method: :post, + html: { class: 'flex items-center justify-between py-1' }) do |f| %> + <%= f.hidden_field :key, value: key %> + <%= f.hidden_field :value, value: current ? 'false' : 'true' %> + + <% end %> + <% end %> +
diff --git a/app/views/personalization_settings/show.html.erb b/app/views/personalization_settings/show.html.erb index 438da311..4e6e22c4 100644 --- a/app/views/personalization_settings/show.html.erb +++ b/app/views/personalization_settings/show.html.erb @@ -22,6 +22,7 @@ <%= render 'form_policy_links_form' %> <%= render 'form_customization_settings' %> + <%= render 'ui_visibility_form' %>
diff --git a/app/views/shared/_navbar.html.erb b/app/views/shared/_navbar.html.erb index 7c85676a..a9ccee1e 100644 --- a/app/views/shared/_navbar.html.erb +++ b/app/views/shared/_navbar.html.erb @@ -39,7 +39,7 @@ <%= t('profile') %> <% end %> - <% if !Docuseal.demo? && can?(:manage, EncryptedConfig) %> + <% if !Docuseal.demo? && can?(:manage, EncryptedConfig) && current_account.ui_visible?(AccountConfig::SHOW_CONSOLE_LINK_KEY) %>
  • <%= link_to Docuseal.multitenant? ? console_redirect_index_path : Docuseal::CONSOLE_URL, data: { prefetch: false }, class: 'flex items-center' do %> <%= svg_icon('terminal', class: 'w-5 h-5 flex-shrink-0 stroke-2') %> @@ -63,7 +63,7 @@ <% end %>
  • <% end %> - <% if (can?(:manage, EncryptedConfig) && current_user == true_user) || (current_user != true_user && current_account.testing?) %> + <% if ((can?(:manage, EncryptedConfig) && current_user == true_user) || (current_user != true_user && current_account.testing?)) && current_account.ui_visible?(AccountConfig::SHOW_TEST_MODE_KEY) %> <%= form_for '', url: testing_account_path, method: current_account.testing? ? :delete : :get, html: { class: 'w-full py-1' } do |f| %>