diff --git a/app/javascript/application.js b/app/javascript/application.js index 339b558b..33eb93de 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -81,6 +81,7 @@ window.customElements.define('template-builder', class extends HTMLElement { template: reactive(JSON.parse(this.dataset.template)), backgroundColor: '#faf7f5', withPhone: this.dataset.withPhone === 'true', + withLogo: this.dataset.withLogo !== 'false', acceptFileTypes: this.dataset.acceptFileTypes, isDirectUpload: this.dataset.isDirectUpload === 'true' }) diff --git a/app/jobs/send_form_completed_webhook_request_job.rb b/app/jobs/send_form_completed_webhook_request_job.rb index aebac6e3..4fe65ff6 100644 --- a/app/jobs/send_form_completed_webhook_request_job.rb +++ b/app/jobs/send_form_completed_webhook_request_job.rb @@ -4,7 +4,7 @@ class SendFormCompletedWebhookRequestJob < ApplicationJob USER_AGENT = 'DocuSeal.co Webhook' def perform(submitter) - config = submitter.submission.account.encrypted_configs.find_by(key: EncryptedConfig::WEBHOOK_URL_KEY) + config = Accounts.load_webhook_configs(submitter.submission.account) return if config.blank? || config.value.blank? @@ -15,7 +15,7 @@ class SendFormCompletedWebhookRequestJob < ApplicationJob Faraday.post(config.value, { event_type: 'form.completed', - timestamp: Time.current.iso8601, + timestamp: Time.current, data: Submitters::SerializeForWebhook.call(submitter) }.to_json, 'Content-Type' => 'application/json', diff --git a/app/jobs/send_form_started_webhook_request_job.rb b/app/jobs/send_form_started_webhook_request_job.rb index 251e5b35..b14e273f 100644 --- a/app/jobs/send_form_started_webhook_request_job.rb +++ b/app/jobs/send_form_started_webhook_request_job.rb @@ -4,7 +4,7 @@ class SendFormStartedWebhookRequestJob < ApplicationJob USER_AGENT = 'DocuSeal.co Webhook' def perform(submitter) - config = submitter.submission.account.encrypted_configs.find_by(key: EncryptedConfig::WEBHOOK_URL_KEY) + config = Accounts.load_webhook_configs(submitter.submission.account) return if config.blank? || config.value.blank? @@ -13,7 +13,7 @@ class SendFormStartedWebhookRequestJob < ApplicationJob Faraday.post(config.value, { event_type: 'form.started', - timestamp: Time.current.iso8601, + timestamp: Time.current, data: Submitters::SerializeForWebhook.call(submitter) }.to_json, 'Content-Type' => 'application/json', diff --git a/app/jobs/send_form_viewed_webhook_request_job.rb b/app/jobs/send_form_viewed_webhook_request_job.rb index d28f240b..65b5c496 100644 --- a/app/jobs/send_form_viewed_webhook_request_job.rb +++ b/app/jobs/send_form_viewed_webhook_request_job.rb @@ -4,7 +4,7 @@ class SendFormViewedWebhookRequestJob < ApplicationJob USER_AGENT = 'DocuSeal.co Webhook' def perform(submitter) - config = submitter.submission.account.encrypted_configs.find_by(key: EncryptedConfig::WEBHOOK_URL_KEY) + config = Accounts.load_webhook_configs(submitter.submission.account) return if config.blank? || config.value.blank? @@ -13,7 +13,7 @@ class SendFormViewedWebhookRequestJob < ApplicationJob Faraday.post(config.value, { event_type: 'form.viewed', - timestamp: Time.current.iso8601, + timestamp: Time.current, data: Submitters::SerializeForWebhook.call(submitter) }.to_json, 'Content-Type' => 'application/json', diff --git a/app/views/accounts/show.html.erb b/app/views/accounts/show.html.erb index 96282853..5734e240 100644 --- a/app/views/accounts/show.html.erb +++ b/app/views/accounts/show.html.erb @@ -21,8 +21,9 @@ <% end %> - <% unless Docuseal.multitenant? %> - <%= f.fields_for @encrypted_config || EncryptedConfig.find_or_initialize_by(account: current_account, key: EncryptedConfig::APP_URL_KEY) do |ff| %> + <% encrypted_config = @encrypted_config || EncryptedConfig.find_or_initialize_by(account: current_account, key: EncryptedConfig::APP_URL_KEY) %> + <% if !Docuseal.multitenant? && can?(:manage, encrypted_config) %> + <%= f.fields_for encrypted_config do |ff| %>
<%= ff.label :value, 'App URL', class: 'label' %> <%= ff.text_field :value, autocomplete: 'off', class: 'base-input' %> diff --git a/app/views/layouts/_head_tags.html.erb b/app/views/layouts/_head_tags.html.erb new file mode 100644 index 00000000..6f991ab9 --- /dev/null +++ b/app/views/layouts/_head_tags.html.erb @@ -0,0 +1,4 @@ + + DocuSeal | Open Source Document Filling and Signing + +<%= render 'shared/meta' %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 939ddde5..f3d134cd 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,10 +1,7 @@ - - DocuSeal | Open Source Document Filling and Signing - - <%= render 'shared/meta' %> + <%= render 'layouts/head_tags' %> <%= csrf_meta_tags %> <%= csp_meta_tag %> diff --git a/app/views/layouts/form.html.erb b/app/views/layouts/form.html.erb index e2aa89b0..fa632377 100644 --- a/app/views/layouts/form.html.erb +++ b/app/views/layouts/form.html.erb @@ -1,10 +1,7 @@ - - DocuSeal | Open Source Document Filling and Signing - - <%= render 'shared/meta' %> + <%= render 'layouts/head_tags' %> <%= csrf_meta_tags %> <%= csp_meta_tag %> diff --git a/app/views/layouts/plain.html.erb b/app/views/layouts/plain.html.erb index 53a2167d..937518ca 100644 --- a/app/views/layouts/plain.html.erb +++ b/app/views/layouts/plain.html.erb @@ -1,10 +1,7 @@ - - DocuSeal | Open Source Document Filling and Signing - - <%= render 'shared/meta' %> + <%= render 'layouts/head_tags' %> <%= csrf_meta_tags %> <%= csp_meta_tag %> diff --git a/app/views/pages/landing.html.erb b/app/views/pages/landing.html.erb index 246b3d71..97ccf250 100644 --- a/app/views/pages/landing.html.erb +++ b/app/views/pages/landing.html.erb @@ -22,7 +22,7 @@

Easy to Start

- Run on your own host using Docker container, or deploy on your favorite managed PaaS with a single click. + Run on your own host using Docker container, or deploy on your favorite managed PaaS with a single click.

@@ -70,4 +70,4 @@ -<%= render 'shared/attribution' %> +<%= render 'shared/attribution', with_counter: true %> diff --git a/app/views/shared/_attribution.html.erb b/app/views/shared/_attribution.html.erb index 275eb686..4679b14f 100644 --- a/app/views/shared/_attribution.html.erb +++ b/app/views/shared/_attribution.html.erb @@ -1 +1 @@ -<%= render 'shared/powered_by' %> +<%= render 'shared/powered_by', with_counter: local_assigns[:with_counter] %> diff --git a/app/views/shared/_github.html.erb b/app/views/shared/_github.html.erb new file mode 100644 index 00000000..853ab6bf --- /dev/null +++ b/app/views/shared/_github.html.erb @@ -0,0 +1,3 @@ + + GitHub Repo stars + diff --git a/app/views/shared/_navbar.html.erb b/app/views/shared/_navbar.html.erb index 37dacf53..889c9bbc 100644 --- a/app/views/shared/_navbar.html.erb +++ b/app/views/shared/_navbar.html.erb @@ -1,14 +1,9 @@
- <%= render 'shared/logo' %> - DocuSeal + <%= render 'shared/title' %> - <% unless Docuseal.demo? %> - - GitHub Repo stars - - <% end %> + <%= render 'shared/github' %>
<% if signed_in? %>
@@ -16,11 +11,13 @@ <%= render 'shared/github_button' %> <% else %>
- <%= link_to Docuseal.multitenant? ? console_redirect_index_path : Docuseal::CONSOLE_URL, class: 'hidden md:inline-flex items-center font-medium text-lg', data: { prefetch: false } do %> - Console - New + <% if can?(:manage, EncryptedConfig) && !can?(:manage, :tenants) %> + <%= link_to Docuseal.multitenant? ? console_redirect_index_path : Docuseal::CONSOLE_URL, class: 'hidden md:inline-flex items-center font-medium text-lg', data: { prefetch: false } do %> + Console + New + <% end %> + <% end %> - <%= link_to 'Settings', settings_profile_index_path, class: 'hidden md:inline-flex font-medium text-lg' %>
<% end %> @@ -35,7 +32,7 @@ Profile <% end %> - <% unless Docuseal.demo? %> + <% if !Docuseal.demo? && can?(:manage, EncryptedConfig) %>
  • <%= 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 stroke-2') %> @@ -43,12 +40,14 @@ <% end %>
  • <% end %> -
  • - <%= link_to settings_esign_path, class: 'flex items-center' do %> - <%= svg_icon('zoom_check', class: 'w-5 h-5 stroke-2') %> - Verify PDF - <% end %> -
  • + <% if can?(:read, EncryptedConfig.new(key: EncryptedConfig::ESIGN_CERTS_KEY, account: current_account)) %> +
  • + <%= link_to settings_esign_path, class: 'flex items-center' do %> + <%= svg_icon('zoom_check', class: 'w-5 h-5 stroke-2') %> + Verify PDF + <% end %> +
  • + <% end %>
  • <%= button_to destroy_user_session_path, method: :delete, data: { turbo: false }, class: 'flex items-center' do %> <%= svg_icon('logout', class: 'w-5 h-5 stroke-2 mr-2 inline') %> diff --git a/app/views/shared/_powered_by.html.erb b/app/views/shared/_powered_by.html.erb index 58fbee58..47ec3f40 100644 --- a/app/views/shared/_powered_by.html.erb +++ b/app/views/shared/_powered_by.html.erb @@ -1,4 +1,13 @@
    - Powered by + <% if local_assigns[:with_counter] %> + <% count = Submitter.where.not(completed_at: nil).distinct.count(:submission_id) %> + <% if count > 1 %> + <%= count %> documents signed with + <% else %> + Powered by + <% end %> + <% else %> + Powered by + <% end %> <%= Docuseal::PRODUCT_NAME %> - open source documents software
    diff --git a/app/views/shared/_settings_nav.html.erb b/app/views/shared/_settings_nav.html.erb index b0fa41d8..2bafbb6f 100644 --- a/app/views/shared/_settings_nav.html.erb +++ b/app/views/shared/_settings_nav.html.erb @@ -58,7 +58,7 @@ <%= link_to 'Personalization', settings_personalization_path, class: 'text-base hover:bg-base-300' %>
  • <% end %> - <% unless Docuseal.demo? %> + <% if !Docuseal.demo? && can?(:manage, EncryptedConfig) %>
  • <%= link_to Docuseal.multitenant? ? console_redirect_index_path : Docuseal::CONSOLE_URL, class: 'text-base hover:bg-base-300', data: { prefetch: false } do %> Console @@ -68,29 +68,31 @@ <% end %> - <% end %> diff --git a/lib/accounts.rb b/lib/accounts.rb index 8fe0df0b..504fb005 100644 --- a/lib/accounts.rb +++ b/lib/accounts.rb @@ -43,12 +43,19 @@ module Accounts new_template end + def load_webhook_configs(account) + account = Account.order(:id).first unless Docuseal.multitenant? + + account.encrypted_configs.find_by(key: EncryptedConfig::WEBHOOK_URL_KEY) + end + def load_signing_pkcs(account) cert_data = if Docuseal.multitenant? - Docuseal::CERTS + EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value || Docuseal::CERTS else - EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY).value + EncryptedConfig.find_by(account: Account.order(:id).first, + key: EncryptedConfig::ESIGN_CERTS_KEY).value end if (default_cert = cert_data['custom']&.find { |e| e['status'] == 'default' })