diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 592c006d..323e8f23 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,6 +6,8 @@ class ApplicationController < ActionController::Base include ActiveStorage::SetCurrent include Pagy::Method + helper WhitelabelHelper + check_authorization unless: :devise_controller? around_action :with_locale @@ -122,6 +124,8 @@ class ApplicationController < ActionController::Base end def maybe_redirect_com + # NOTE: upstream DocuSeal cloud redirect — no-op for self-hosted / white-label + return unless Docuseal.multitenant? return if request.domain != 'docuseal.co' redirect_to request.url.gsub('.co/', '.com/'), allow_other_host: true, status: :moved_permanently diff --git a/app/controllers/embed_scripts_controller.rb b/app/controllers/embed_scripts_controller.rb index a40ed79c..35fb5c5f 100644 --- a/app/controllers/embed_scripts_controller.rb +++ b/app/controllers/embed_scripts_controller.rb @@ -1,39 +1,43 @@ # frozen_string_literal: true class EmbedScriptsController < ActionController::Metal - DUMMY_SCRIPT = <<~JAVASCRIPT.freeze - const DummyBuilder = class extends HTMLElement { - connectedCallback() { - this.innerHTML = ` -
-

Upgrade to Pro

-

Unlock embedded components by upgrading to Pro

-
- - Learn More - -
-
- `; - } - }; + def show + headers['Content-Type'] = 'application/javascript' - const DummyForm = class extends DummyBuilder {}; + self.response_body = dummy_script - if (!window.customElements.get('docuseal-builder')) { - window.customElements.define('docuseal-builder', DummyBuilder); - } + self.status = 200 + end - if (!window.customElements.get('docuseal-form')) { - window.customElements.define('docuseal-form', DummyForm); - } - JAVASCRIPT + private - def show - headers['Content-Type'] = 'application/javascript' + def dummy_script + <<~JAVASCRIPT + const DummyBuilder = class extends HTMLElement { + connectedCallback() { + this.innerHTML = ` +
+

Upgrade to Pro

+

Unlock embedded components by upgrading to Pro

+
+ + Learn More + +
+
+ `; + } + }; - self.response_body = DUMMY_SCRIPT + const DummyForm = class extends DummyBuilder {}; - self.status = 200 + if (!window.customElements.get('docuseal-builder')) { + window.customElements.define('docuseal-builder', DummyBuilder); + } + + if (!window.customElements.get('docuseal-form')) { + window.customElements.define('docuseal-form', DummyForm); + } + JAVASCRIPT end end diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index 0c9e3632..190aefd5 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -2,7 +2,7 @@ class ErrorsController < ActionController::Base ENTERPRISE_FEATURE_MESSAGE = - 'This feature is available in Pro Edition: https://www.docuseal.com/pricing' + "This feature is available in Pro Edition: #{Whitelabel.website_url}/pricing" ENTERPRISE_PATHS = [ '/submissions/html', diff --git a/app/controllers/esign_settings_controller.rb b/app/controllers/esign_settings_controller.rb index 81c75fae..ba961372 100644 --- a/app/controllers/esign_settings_controller.rb +++ b/app/controllers/esign_settings_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class EsignSettingsController < ApplicationController - DEFAULT_CERT_NAME = 'DocuSeal Self-Host Autogenerated' + DEFAULT_CERT_NAME = Whitelabel.cert_name CertFormRecord = Struct.new(:name, :file, :password, keyword_init: true) do include ActiveModel::Validations diff --git a/app/controllers/personalization_settings_controller.rb b/app/controllers/personalization_settings_controller.rb index d9d33490..75ab6487 100644 --- a/app/controllers/personalization_settings_controller.rb +++ b/app/controllers/personalization_settings_controller.rb @@ -1,16 +1,6 @@ # frozen_string_literal: true class PersonalizationSettingsController < ApplicationController - ALLOWED_KEYS = [ - AccountConfig::FORM_COMPLETED_BUTTON_KEY, - AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY, - AccountConfig::SUBMITTER_INVITATION_REMINDER_EMAIL_KEY, - AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY, - AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY, - AccountConfig::FORM_COMPLETED_MESSAGE_KEY, - *(Docuseal.multitenant? ? [] : [AccountConfig::POLICY_LINKS_KEY]) - ].freeze - InvalidKey = Class.new(StandardError) before_action :load_and_authorize_account_config, only: :create @@ -45,11 +35,23 @@ class PersonalizationSettingsController < ApplicationController authorize!(:create, @account_config) - raise InvalidKey unless ALLOWED_KEYS.include?(@account_config.key) + raise InvalidKey unless allowed_keys.include?(@account_config.key) @account_config end + def allowed_keys + [ + AccountConfig::FORM_COMPLETED_BUTTON_KEY, + AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY, + AccountConfig::SUBMITTER_INVITATION_REMINDER_EMAIL_KEY, + AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY, + AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY, + AccountConfig::FORM_COMPLETED_MESSAGE_KEY, + *(Docuseal.multitenant? ? [] : [AccountConfig::POLICY_LINKS_KEY]) + ] + end + def account_config_params attrs = params.require(:account_config).permit(:key, :value, { value: {} }, { value: [] }) diff --git a/app/helpers/whitelabel_helper.rb b/app/helpers/whitelabel_helper.rb new file mode 100644 index 00000000..4adc50c5 --- /dev/null +++ b/app/helpers/whitelabel_helper.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +# ============================================================================= +# WhitelabelHelper — makes Whitelabel config available in all views +# ============================================================================= +# Include this in ApplicationController to use `wl` in all ERB templates. +# +# Usage in views: +# <%= wl.brand_name %> +# <%= wl.logo_path %> +# <%= wl.support_email %> +# ============================================================================= + +module WhitelabelHelper + def wl + Whitelabel + end +end diff --git a/app/javascript/submission_form/completed.vue b/app/javascript/submission_form/completed.vue index c87f9c4f..a69da76e 100644 --- a/app/javascript/submission_form/completed.vue +++ b/app/javascript/submission_form/completed.vue @@ -1,36 +1,18 @@ diff --git a/app/javascript/submission_form/signature_step.vue b/app/javascript/submission_form/signature_step.vue index 2651f8d5..7e1c73d6 100644 --- a/app/javascript/submission_form/signature_step.vue +++ b/app/javascript/submission_form/signature_step.vue @@ -288,7 +288,7 @@ class="text-base-content/60 text-xs text-center w-full mt-1 select-none" > {{ t('by_clicking_you_agree_to_the').replace('{button}', buttonText.charAt(0).toUpperCase() + buttonText.slice(1)) }} diff --git a/app/javascript/template_builder/conditions_modal.vue b/app/javascript/template_builder/conditions_modal.vue index d8219ff6..f1a5040c 100644 --- a/app/javascript/template_builder/conditions_modal.vue +++ b/app/javascript/template_builder/conditions_modal.vue @@ -23,7 +23,7 @@ class="bg-base-300 rounded-xl py-2 px-3 text-center" > {{ t('available_in_pro') }} diff --git a/app/javascript/template_builder/fields.vue b/app/javascript/template_builder/fields.vue index b1d1346d..55a1b9ed 100644 --- a/app/javascript/template_builder/fields.vue +++ b/app/javascript/template_builder/fields.vue @@ -5,21 +5,26 @@ class="roles-dropdown w-full rounded-lg roles-dropdown" :style="withStickySubmitters ? { backgroundColor } : {}" :submitters="submitters" - :menu-style="{ overflow: 'auto', display: 'flex', flexDirection: 'row', maxHeight: 'calc(100vh - 120px)', backgroundColor: ['', null, 'transparent'].includes(backgroundColor) ? 'white' : backgroundColor }" + :menu-style="{ + overflow: 'auto', + display: 'flex', + flexDirection: 'row', + maxHeight: 'calc(100vh - 120px)', + backgroundColor: ['', null, 'transparent'].includes(backgroundColor) ? 'white' : backgroundColor, + }" :editable="editable && !defaultSubmitters.length" @new-submitter="save" @remove="removeSubmitter" @name-change="save" - @update:model-value="$emit('change-submitter', submitters.find((s) => s.uuid === $event))" + @update:model-value=" + $emit( + 'change-submitter', + submitters.find((s) => s.uuid === $event), + ) + " /> -
+
-
+
-
+
- {{ t('field_not_found') }} + {{ t("field_not_found") }}
- - {{ t('clear') }} + + {{ t("clear") }}
-