feat(settings): UI visibility prefs for console/api/test-mode; remove plans upsell

pull/639/head
Bob Develop 2 weeks ago
parent fd953d71fe
commit a44531c6a7

@ -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

@ -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,

@ -0,0 +1,33 @@
<div class="space-y-2">
<p class="text-4xl font-bold mb-4 mt-8"><%= t('ui_visibility') %></p>
<% [
[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' %>
<label class="flex items-center space-x-3 flex-grow"
<%= "title=\"#{t('locked_by_env')}\"".html_safe if locked %>>
<submit-form data-on="change" class="flex">
<input type="checkbox"
class="toggle toggle-sm"
<%= 'checked' if current %>
<%= 'disabled' if locked %>
onchange="this.form.submit()">
</submit-form>
<span class="text-base"><%= label %></span>
<% if locked %>
<span class="text-xs text-base-content/60">(<%= t('locked_by_env') %>)</span>
<% end %>
</label>
<% end %>
<% end %>
</div>

@ -22,6 +22,7 @@
<%= render 'form_policy_links_form' %>
</div>
<%= render 'form_customization_settings' %>
<%= render 'ui_visibility_form' %>
</div>
<div class="w-0 md:w-52"></div>
</div>

@ -39,7 +39,7 @@
<span class="mr-1"><%= t('profile') %></span>
<% end %>
</li>
<% if !Docuseal.demo? && can?(:manage, EncryptedConfig) %>
<% if !Docuseal.demo? && can?(:manage, EncryptedConfig) && current_account.ui_visible?(AccountConfig::SHOW_CONSOLE_LINK_KEY) %>
<li>
<%= 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 %>
</li>
<% 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| %>
<label class="flex items-center pl-6 pr-4 py-2 border-y border-base-300 -ml-2 -mr-2" for="testing_toggle">
<submit-form data-on="change" class="flex">

@ -50,7 +50,7 @@
</li>
<% end %>
<%= render 'shared/settings_nav_extra' %>
<% if Docuseal.demo? || !Docuseal.multitenant? %>
<% if (Docuseal.demo? || !Docuseal.multitenant?) && current_account.ui_visible?(AccountConfig::SHOW_API_LINK_KEY) %>
<% if can?(:read, AccessToken) %>
<li>
<%= link_to 'API', settings_api_index_path, class: 'text-base hover:bg-base-300' %>
@ -64,15 +64,7 @@
</li>
<% end %>
<% end %>
<% if !Docuseal.demo? && can?(:manage, EncryptedConfig) && (current_user != true_user || !current_account.linked_account_account) %>
<li>
<%= content_for(:pro_link) || link_to(Docuseal.multitenant? ? console_redirect_index_path(redir: "#{Docuseal::CONSOLE_URL}/plans") : "#{Docuseal::CLOUD_URL}/sign_up?#{{ redir: "#{Docuseal::CONSOLE_URL}/on_premises" }.to_query}", class: 'text-base hover:bg-base-300', data: { turbo: false }) do %>
<%= t('plans') %>
<span class="badge badge-warning"><%= t('pro') %></span>
<% end %>
</li>
<% end %>
<% if !Docuseal.demo? && can?(:manage, EncryptedConfig) && (current_user == true_user || current_account.testing?) %>
<% if !Docuseal.demo? && can?(:manage, EncryptedConfig) && (current_user == true_user || current_account.testing?) && current_account.ui_visible?(AccountConfig::SHOW_CONSOLE_LINK_KEY) %>
<li>
<%= link_to Docuseal.multitenant? ? console_redirect_index_path(redir: "#{Docuseal::CONSOLE_URL}#{'/test' if current_account.testing?}/api") : "#{Docuseal::CONSOLE_URL}/on_premises", class: 'text-base hover:bg-base-300', data: { turbo: false } do %>
<% if Docuseal.multitenant? %> API <% else %> <%= t('console') %> <% end %>
@ -96,7 +88,7 @@
</li>
<% end %>
<%= render 'shared/settings_nav_extra2' %>
<% 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' } do |f| %>
<li>
<label class="flex items-center text-base hover:bg-base-300 w-full justify-between" for="testing_toggle">

@ -1,4 +1,9 @@
en: &en
ui_visibility: UI Visibility
show_console_link: Show Console Link
show_api_link: Show API Link
show_test_mode: Show Test Mode
locked_by_env: Locked by environment variable
language_en: English
language_en-US: English (US)
language_en-GB: English (UK)

@ -0,0 +1,43 @@
import { test, expect } from '@playwright/test';
import { loginAsAdmin } from './helpers/auth';
// Phase 0.3 — UI visibility preferences.
// Toggle "Show Console Link" off and verify the console link disappears.
test.describe('UI visibility preferences', () => {
test('toggling Show Console Link hides and shows the link', async ({ page }) => {
await loginAsAdmin(page);
await page.goto('/settings/personalization');
const consoleToggle = page.locator('form input[type="hidden"][value="show_console_link"]').locator('..')
.locator('input[type="checkbox"]');
await expect(consoleToggle).toBeVisible();
const initiallyChecked = await consoleToggle.isChecked();
// Toggle off
if (initiallyChecked) {
await consoleToggle.click();
await page.waitForLoadState('networkidle');
}
await page.goto('/');
// Open user-menu dropdown
await page.locator('.dropdown label').first().click();
await expect(page.getByRole('link', { name: /console/i })).toHaveCount(0);
// Toggle back on
await page.goto('/settings/personalization');
const toggle2 = page.locator('form input[type="hidden"][value="show_console_link"]').locator('..')
.locator('input[type="checkbox"]');
if (!(await toggle2.isChecked())) {
await toggle2.click();
await page.waitForLoadState('networkidle');
}
await page.goto('/settings/profile');
// With Console link enabled and admin signed in, the Console link should appear
// in the settings sidebar when not in multitenant mode.
await expect(page.getByRole('link', { name: /console/i }).first()).toBeVisible();
});
});
Loading…
Cancel
Save