You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docuseal/app/views/shared/_navbar.html.erb

209 lines
13 KiB

<%= render 'shared/navbar_warning' %>
<header class="w-full border-b border-base-300 bg-base-100/95 backdrop-blur-sm sticky top-0 z-10 transition-shadow duration-200">
<div class="max-w-7xl mx-auto px-4 md:px-6 py-3.5 md:py-4 flex items-center justify-between">
<div class="flex items-center space-x-8">
<a href="<%= root_path %>" class="text-2xl font-bold items-center flex space-x-2">
<%= render 'shared/title' %>
</a>
<% if signed_in? %>
<nav class="hidden md:flex items-center space-x-6">
<% is_templates = request.path == root_path || request.path.start_with?('/templates') || request.path.start_with?('/folders') %>
<% is_submissions = request.path.start_with?('/submissions') %>
<% is_settings = request.path.start_with?('/settings') %>
<%= link_to root_path, class: "font-medium text-base transition-colors duration-200 #{is_templates ? 'text-primary' : 'text-base-content hover:text-primary'}" do %>
<%= t('templates') %>
<% end %>
<%= link_to submissions_path, class: "font-medium text-base transition-colors duration-200 #{is_submissions ? 'text-primary' : 'text-base-content hover:text-primary'}" do %>
<%= t('submissions') %>
<% end %>
<div class="dropdown dropdown-hover">
<label tabindex="0" class="font-medium text-base transition-colors duration-200 <%= is_settings ? 'text-primary' : 'text-base-content hover:text-primary' %> cursor-pointer">
<%= t('settings') %>
<%= svg_icon('chevron_down', class: 'w-4 h-4 inline-block ml-1') %>
</label>
<ul tabindex="0" class="z-10 dropdown-content p-1.5 mt-2 shadow-soft-lg menu bg-base-100 rounded-lg min-w-[200px] border border-base-300 animate-fade-in-up">
<li><%= link_to t('profile'), settings_profile_index_path, class: 'text-base rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3' %></li>
<li><%= link_to t('account'), settings_account_path, class: 'text-base rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3' %></li>
<% unless Docuseal.multitenant? %>
<% if can?(:read, EncryptedConfig.new(key: EncryptedConfig::EMAIL_SMTP_KEY, account: current_account)) && ENV['SMTP_ADDRESS'].blank? && true_user == current_user %>
<li>
<%= link_to t('email'), settings_email_index_path, class: 'text-base rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3' %>
</li>
<% end %>
<% if can?(:read, EncryptedConfig.new(key: EncryptedConfig::FILES_STORAGE_KEY, account: current_account)) && true_user == current_user %>
<li>
<%= link_to t('storage'), settings_storage_index_path, class: 'text-base rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3' %>
</li>
<% end %>
<% if can?(:read, EncryptedConfig.new(key: 'submitter_invitation_sms', account: current_account)) && true_user == current_user %>
<li>
<%= link_to 'SMS', settings_sms_path, class: 'text-base rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3' %>
</li>
<% end %>
<% end %>
<% if can?(:read, AccountConfig) %>
<li>
<%= link_to t('notifications'), settings_notifications_path, class: 'text-base rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3' %>
</li>
<% end %>
<% if can?(:read, EncryptedConfig.new(key: EncryptedConfig::ESIGN_CERTS_KEY, account: current_account)) %>
<li>
<%= link_to t('e_signature'), settings_esign_path, class: 'text-base rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3' %>
</li>
<% end %>
<% if can?(:read, AccountConfig) %>
<li>
<%= link_to t('personalization'), settings_personalization_path, class: 'text-base rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3' %>
</li>
<% end %>
<% if can?(:read, User) %>
<li>
<%= link_to t('users'), settings_users_path, class: 'text-base rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3' %>
</li>
<% end %>
<% if Docuseal.demo? || !Docuseal.multitenant? %>
<% if can?(:read, AccessToken) %>
<li>
<%= link_to 'API', settings_api_index_path, class: 'text-base rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3' %>
</li>
<% end %>
<% end %>
<% if Docuseal.demo? || !Docuseal.multitenant? || (current_user != true_user && !current_account.testing?) %>
<% if can?(:read, WebhookUrl) %>
<li>
<%= link_to 'Webhooks', settings_webhooks_path, class: 'text-base rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3' %>
</li>
<% end %>
<% end %>
<%= render 'shared/settings_nav_extra' %>
<% 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 rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3', 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?) %>
<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 rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3', data: { turbo: false } do %>
<% if Docuseal.multitenant? %> API <% else %> <%= t('console') %> <% end %>
<% end %>
</li>
<% if Docuseal.multitenant? %>
<li>
<%= link_to console_redirect_index_path(redir: "#{Docuseal::CONSOLE_URL}#{'/test' if current_account.testing?}/embedding/form"), class: 'text-base rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3', data: { turbo: false } do %>
<%= t('embedding') %>
<% end %>
</li>
<% end %>
<% if (!Docuseal.multitenant? || can?(:manage, :saml_sso)) && can?(:read, EncryptedConfig.new(key: 'saml_configs', account: current_account)) && true_user == current_user %>
<li>
<%= link_to 'SSO', settings_sso_index_path, class: 'text-base rounded-md hover:bg-base-200 transition-colors duration-150 py-2.5 px-3' %>
</li>
<% end %>
<%= render 'shared/settings_nav_extra2' %>
<% end %>
</ul>
</div>
</nav>
<% end %>
<span class="hidden sm:inline">
<%= render 'shared/github' if request.path.starts_with?('/settings') %>
</span>
</div>
<% if signed_in? %>
<div class="space-x-4 flex items-center">
<% if Docuseal.demo? %>
<a href="https://docuseal.com/sign_up" class="btn btn-neutral btn-sm btn-outline inline-flex items-center justify-center" style="height: 37px">
<%= t('sign_up') %>
</a>
<span class="hidden sm:inline">
<%= render 'shared/github_button' %>
</span>
<% else %>
<div class="flex items-center justify-center space-x-4 mr-1">
<%= render 'shared/navbar_buttons' %>
</div>
<% end %>
<div class="dropdown dropdown-end">
<label tabindex="0" class="cursor-pointer bg-neutral text-neutral-content rounded-full p-2 w-9 h-9 justify-center items-center flex font-semibold text-sm transition-all duration-200 hover:opacity-90 active:scale-95">
<span class="text-sm align-text-top"><%= current_user.initials %></span>
</label>
<ul tabindex="0" class="z-10 dropdown-content p-1.5 mt-2 shadow-soft-lg menu text-base bg-base-100 rounded-lg min-w-[180px] text-right border border-base-300 animate-fade-in-up">
<li>
<%= link_to settings_profile_index_path, class: 'flex items-center' do %>
<%= svg_icon('adjustments', class: 'w-5 h-5 flex-shrink-0 stroke-2') %>
<span class="mr-1"><%= t('profile') %></span>
<% end %>
</li>
<% if !Docuseal.demo? && can?(:manage, EncryptedConfig) %>
<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') %>
<%= t('console') %>
<% end %>
</li>
<% end %>
<% if can?(:read, EncryptedConfig.new(key: EncryptedConfig::ESIGN_CERTS_KEY, account: current_account)) %>
<li>
<%= link_to settings_esign_path, class: 'flex items-center' do %>
<%= svg_icon('zoom_check', class: 'w-5 h-5 flex-shrink-0 stroke-2') %>
<span class="mr-1 whitespace-nowrap"><%= t('verify_pdf') %></span>
<% end %>
</li>
<% end %>
<% if Docuseal.multitenant? || current_user.role == 'superadmin' %>
<li>
<%= link_to Docuseal::CHATGPT_URL, target: 'blank', class: 'flex items-center' do %>
<%= svg_icon('sparkles', class: 'w-5 h-5 flex-shrink-0 stroke-2') %>
<span class="mr-1 whitespace-nowrap"><%= t('ask_ai') %></span>
<% end %>
</li>
<% end %>
<% if (can?(:manage, EncryptedConfig) && current_user == true_user) || (current_user != true_user && current_account.testing?) %>
<%= 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">
<%= f.check_box :testing_toggle, class: 'toggle', checked: current_account.testing?, style: 'height: 0.885rem; width: 1.35rem; --handleoffset: 0.395rem; margin-left: -2px; margin-right: 8px' %>
</submit-form>
<span class="whitespace-nowrap">
<%= t('test_mode') %>
</span>
</label>
<% end %>
<% end %>
<li>
<%= button_to destroy_user_session_path, method: :delete, data: { turbo: false }, class: 'flex items-center' do %>
<%= svg_icon('logout', class: 'w-5 h-5 flex-shrink-0 stroke-2 mr-2 inline') %>
<span class="mr-1 whitespace-nowrap"><%= t('sign_out') %></span>
<% end %>
</li>
</ul>
</div>
</div>
<% else %>
<div class="flex space-x-2">
<% if request.path != new_user_session_path && request.path != setup_index_path %>
<%= link_to new_user_session_path({ lang: params[:lang] }.compact_blank), class: 'font-medium text-lg' do %>
<span class="flex items-center justify-center space-x-1">
<%= svg_icon('login', class: 'w-6 h-6') %>
<span><%= t('sign_in') %></span>
</span>
<% end %>
<% end %>
<% if Docuseal.multitenant? && !request.path.in?([registration_path, new_registration_path]) %>
<%= link_to registration_path({ lang: params[:lang] }.compact_blank), class: 'btn btn-neutral btn-sm btn-outline' do %>
<span class="flex items-center justify-center space-x-1">
<span class="hidden sm:block capitalize"><%= t('create_free_account') %></span>
<span class="md:hidden"><%= t('sign_up') %></span>
</span>
<% end %>
<% end %>
</div>
<% end %>
</header>