From 617d75a4ede217c29c13e9223703259a4621d1ce Mon Sep 17 00:00:00 2001 From: Alex Turchyn Date: Tue, 8 Sep 2026 15:06:29 +0300 Subject: [PATCH] add native titles --- app/javascript/application.js | 4 +++ app/javascript/application.scss | 5 +++ app/javascript/elements/native_action.js | 31 +++++++++++++++++++ app/javascript/elements/native_header.js | 14 +++++++++ app/views/accounts/show.html.erb | 1 + app/views/api_settings/index.html.erb | 1 + app/views/email_smtp_settings/index.html.erb | 1 + app/views/esign_settings/show.html.erb | 1 + app/views/layouts/_head_tags.html.erb | 2 +- app/views/mcp_settings/index.html.erb | 1 + .../notifications_settings/index.html.erb | 1 + .../personalization_settings/show.html.erb | 1 + app/views/profile/index.html.erb | 1 + app/views/settings/index.html.erb | 1 + app/views/sms_settings/index.html.erb | 1 + app/views/sso_settings/index.html.erb | 1 + app/views/storage_settings/index.html.erb | 1 + app/views/submissions/show.html.erb | 1 + app/views/submissions_archived/index.html.erb | 5 ++- app/views/template_folders/show.html.erb | 5 ++- app/views/templates/edit.html.erb | 1 + app/views/templates/show.html.erb | 1 + app/views/templates_archived/index.html.erb | 5 ++- .../index.html.erb | 1 + app/views/templates_shared/index.html.erb | 5 ++- app/views/users/index.html.erb | 1 + app/views/webhook_settings/index.html.erb | 1 + app/views/webhook_settings/show.html.erb | 1 + 28 files changed, 82 insertions(+), 13 deletions(-) create mode 100644 app/javascript/elements/native_action.js create mode 100644 app/javascript/elements/native_header.js diff --git a/app/javascript/application.js b/app/javascript/application.js index a9c3d0391..b32063f80 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -9,6 +9,8 @@ import ToggleVisible from './elements/toggle_visible' import ToggleCookies from './elements/toggle_cookies' import DisableHidden from './elements/disable_hidden' import TurboModal from './elements/turbo_modal' +import NativeAction from './elements/native_action' +import NativeHeader from './elements/native_header' import FileDropzone from './elements/file_dropzone' import MenuActive from './elements/menu_active' import ClipboardCopy from './elements/clipboard_copy' @@ -106,6 +108,8 @@ const safeRegisterElement = (name, element, options = {}) => !window.customEleme safeRegisterElement('toggle-visible', ToggleVisible) safeRegisterElement('disable-hidden', DisableHidden) safeRegisterElement('turbo-modal', TurboModal) +safeRegisterElement('native-action', NativeAction) +safeRegisterElement('native-header', NativeHeader) safeRegisterElement('file-dropzone', FileDropzone) safeRegisterElement('menu-active', MenuActive) safeRegisterElement('clipboard-copy', ClipboardCopy) diff --git a/app/javascript/application.scss b/app/javascript/application.scss index 1050df66c..d444c5e2a 100644 --- a/app/javascript/application.scss +++ b/app/javascript/application.scss @@ -166,3 +166,8 @@ button[disabled] .enabled, button.btn-disabled .enabled { markdown-editor [contenteditable] p { margin-bottom: 18px; } + +native-action, +native-header { + display: contents; +} diff --git a/app/javascript/elements/native_action.js b/app/javascript/elements/native_action.js new file mode 100644 index 000000000..27119b812 --- /dev/null +++ b/app/javascript/elements/native_action.js @@ -0,0 +1,31 @@ +let counter = 0 + +export default class extends HTMLElement { + connectedCallback () { + const bridge = window.webkit?.messageHandlers?.native + + if (!bridge) return + + const target = this.querySelector('a, button, [role="button"]') + + if (!target) return + + this.nativeId ||= `native-action-${++counter}` + target.dataset.nativeId = this.nativeId + + bridge.postMessage({ + type: 'action', + op: 'add', + id: this.nativeId, + title: this.dataset.label || target.textContent.trim(), + icon: this.dataset.icon, + placement: this.dataset.placement || 'menu' + }) + } + + disconnectedCallback () { + if (this.nativeId) { + window.webkit?.messageHandlers?.native?.postMessage({ type: 'action', op: 'remove', id: this.nativeId }) + } + } +} diff --git a/app/javascript/elements/native_header.js b/app/javascript/elements/native_header.js new file mode 100644 index 000000000..cfdbb0771 --- /dev/null +++ b/app/javascript/elements/native_header.js @@ -0,0 +1,14 @@ +export default class extends HTMLElement { + connectedCallback () { + window.webkit?.messageHandlers?.native?.postMessage({ + type: 'header', + op: 'add', + title: this.dataset.label || this.querySelector('h1')?.textContent?.trim() || '', + search: 'search' in this.dataset + }) + } + + disconnectedCallback () { + window.webkit?.messageHandlers?.native?.postMessage({ type: 'header', op: 'remove' }) + } +} diff --git a/app/views/accounts/show.html.erb b/app/views/accounts/show.html.erb index 46787131e..aa77491d3 100644 --- a/app/views/accounts/show.html.erb +++ b/app/views/accounts/show.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, t('account')) if turbo_native_app? %>
<%= render 'shared/settings_nav' %>
diff --git a/app/views/api_settings/index.html.erb b/app/views/api_settings/index.html.erb index 710fe7f85..e009646b7 100644 --- a/app/views/api_settings/index.html.erb +++ b/app/views/api_settings/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, 'API') if turbo_native_app? %>
<%= render 'shared/settings_nav' %>
diff --git a/app/views/email_smtp_settings/index.html.erb b/app/views/email_smtp_settings/index.html.erb index cd750acf7..102ac75bd 100644 --- a/app/views/email_smtp_settings/index.html.erb +++ b/app/views/email_smtp_settings/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, t('email')) if turbo_native_app? %>
<%= render 'shared/settings_nav' %>
diff --git a/app/views/esign_settings/show.html.erb b/app/views/esign_settings/show.html.erb index 2692aa375..fa0eab259 100644 --- a/app/views/esign_settings/show.html.erb +++ b/app/views/esign_settings/show.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, t('e_signature')) if turbo_native_app? %>
<%= render 'shared/settings_nav' %>
diff --git a/app/views/layouts/_head_tags.html.erb b/app/views/layouts/_head_tags.html.erb index cedcab1b5..c9ed919c6 100644 --- a/app/views/layouts/_head_tags.html.erb +++ b/app/views/layouts/_head_tags.html.erb @@ -1,4 +1,4 @@ - <%= content_for(:html_title) || (turbo_native_app? ? '' : (signed_in? ? 'DocuSeal' : 'DocuSeal | Open Source Document Signing')) %> + <%= content_for(:native_title) || content_for(:html_title) || (signed_in? ? 'DocuSeal' : 'DocuSeal | Open Source Document Signing') %> <%= render 'shared/meta' %> diff --git a/app/views/mcp_settings/index.html.erb b/app/views/mcp_settings/index.html.erb index b0afcc3a7..9191a6e29 100644 --- a/app/views/mcp_settings/index.html.erb +++ b/app/views/mcp_settings/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, 'MCP') if turbo_native_app? %>
<%= render 'shared/settings_nav' %>
diff --git a/app/views/notifications_settings/index.html.erb b/app/views/notifications_settings/index.html.erb index 262178d57..a911c9494 100644 --- a/app/views/notifications_settings/index.html.erb +++ b/app/views/notifications_settings/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, t('notifications')) if turbo_native_app? %>
<%= render 'shared/settings_nav' %>
diff --git a/app/views/personalization_settings/show.html.erb b/app/views/personalization_settings/show.html.erb index 20ea3c788..82651ce01 100644 --- a/app/views/personalization_settings/show.html.erb +++ b/app/views/personalization_settings/show.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, t('personalization')) if turbo_native_app? %>
<%= render 'shared/settings_nav' %>
diff --git a/app/views/profile/index.html.erb b/app/views/profile/index.html.erb index 6444c53f9..e3b393bc5 100644 --- a/app/views/profile/index.html.erb +++ b/app/views/profile/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, t('profile')) if turbo_native_app? %>
<%= render 'shared/settings_nav' %>
diff --git a/app/views/settings/index.html.erb b/app/views/settings/index.html.erb index 1232a47cb..9e1187fcb 100644 --- a/app/views/settings/index.html.erb +++ b/app/views/settings/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, t('settings')) if turbo_native_app? %> <% unless turbo_native_app? %>
diff --git a/app/views/sms_settings/index.html.erb b/app/views/sms_settings/index.html.erb index 2c2d2e902..b865f4e16 100644 --- a/app/views/sms_settings/index.html.erb +++ b/app/views/sms_settings/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, 'SMS') if turbo_native_app? %>
<%= render 'shared/settings_nav' %>
diff --git a/app/views/sso_settings/index.html.erb b/app/views/sso_settings/index.html.erb index 9ac6bdf24..fb13a57fd 100644 --- a/app/views/sso_settings/index.html.erb +++ b/app/views/sso_settings/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, 'SSO') if turbo_native_app? %>
<%= render 'shared/settings_nav' %>
diff --git a/app/views/storage_settings/index.html.erb b/app/views/storage_settings/index.html.erb index e4a5bd958..b459f1f7f 100644 --- a/app/views/storage_settings/index.html.erb +++ b/app/views/storage_settings/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, t('storage')) if turbo_native_app? %>
<%= render 'shared/settings_nav' %>
diff --git a/app/views/submissions/show.html.erb b/app/views/submissions/show.html.erb index 6a863cc29..5ab68571a 100644 --- a/app/views/submissions/show.html.erb +++ b/app/views/submissions/show.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, @submission.name || @submission.template&.name) if turbo_native_app? %> <% if local_assigns[:is_preview] %> <%= render 'submissions/preview_tags' %> <% end %> diff --git a/app/views/submissions_archived/index.html.erb b/app/views/submissions_archived/index.html.erb index 0118a3cb3..4b478f56a 100644 --- a/app/views/submissions_archived/index.html.erb +++ b/app/views/submissions_archived/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, t('archived')) if turbo_native_app? %> <% filter_params = params.permit(Submissions::Filter::ALLOWED_PARAMS).compact_blank %> <% unless turbo_native_app? %>
@@ -8,9 +9,7 @@
<% end %>
- <% if turbo_native_app? %> - <% content_for(:html_title, t('archived')) %> - <% else %> + <% unless turbo_native_app? %>

<%= t('submissions') %> <%= t('archived') %>

diff --git a/app/views/template_folders/show.html.erb b/app/views/template_folders/show.html.erb index a06e0585f..cb89a887b 100644 --- a/app/views/template_folders/show.html.erb +++ b/app/views/template_folders/show.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, @template_folder.name) if turbo_native_app? %> <% unless turbo_native_app? %>
<%= link_to @template_folder.parent_folder ? folder_path(@template_folder.parent_folder) : root_path, class: 'flex items-center' do %> @@ -13,9 +14,7 @@ <% end %> - <% if turbo_native_app? %> - <% content_for(:html_title, @template_folder.name) %> - <% else %> + <% unless turbo_native_app? %>
<%= render 'templates/dashboard_dropzone', style: 'height: 137px' %> <% unless @template_folder.parent_folder %> diff --git a/app/views/templates/edit.html.erb b/app/views/templates/edit.html.erb index 8377815f7..fb82aeb1e 100644 --- a/app/views/templates/edit.html.erb +++ b/app/views/templates/edit.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, @template.name) if turbo_native_app? %> <% if !turbo_native_app? && (current_user.created_at > 2.weeks.ago || params[:tour] == 'true') %> <% user_config = current_user.user_configs.find_or_initialize_by(key: UserConfig::SHOW_APP_TOUR) %> <% @show_tour_start_form = user_config.new_record? && !params.key?(:tour) %> diff --git a/app/views/templates/show.html.erb b/app/views/templates/show.html.erb index 30bbcc724..28c857542 100644 --- a/app/views/templates/show.html.erb +++ b/app/views/templates/show.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, @template.name) if turbo_native_app? %> <%= render 'title', template: @template %> <% filter_params = params.permit(Submissions::Filter::ALLOWED_PARAMS).compact_blank %> <% is_show_tabs = @pagy.pages > 1 || params[:q].present? || params[:status].present? || filter_params.present? %> diff --git a/app/views/templates_archived/index.html.erb b/app/views/templates_archived/index.html.erb index b387d224f..d7ad963f1 100644 --- a/app/views/templates_archived/index.html.erb +++ b/app/views/templates_archived/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, t('archived')) if turbo_native_app? %> <% unless turbo_native_app? %>
<%= link_to root_path, class: 'flex items-center mb-1 md:mb-0' do %> @@ -6,9 +7,7 @@ <% end %>
<% end %> -<% if turbo_native_app? %> - <% content_for(:html_title, t('archived')) %> -<% else %> +<% unless turbo_native_app? %>

<%= t('document_templates_html') %> <%= t('archived') %>

diff --git a/app/views/templates_archived_submissions/index.html.erb b/app/views/templates_archived_submissions/index.html.erb index 0752b72f8..77529a6b5 100644 --- a/app/views/templates_archived_submissions/index.html.erb +++ b/app/views/templates_archived_submissions/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, @template.name) if turbo_native_app? %> <% filter_params = params.permit(Submissions::Filter::ALLOWED_PARAMS).compact_blank %> <% with_filters = @pagy.pages > 1 || params[:q].present? || filter_params.present? %> <%= render 'templates/title', template: @template %> diff --git a/app/views/templates_shared/index.html.erb b/app/views/templates_shared/index.html.erb index af2a9bd5d..aa8048e4d 100644 --- a/app/views/templates_shared/index.html.erb +++ b/app/views/templates_shared/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, t('shared').capitalize) if turbo_native_app? %> <% unless turbo_native_app? %>
<%= link_to(@is_archived ? templates_shared_index_path : root_path, class: 'flex items-center mb-1 md:mb-0') do %> @@ -6,9 +7,7 @@ <% end %>
<% end %> -<% if turbo_native_app? %> - <% content_for(:html_title, t('shared').capitalize) %> -<% else %> +<% unless turbo_native_app? %>

<%= svg_icon('folder', class: 'w-9 h-9 flex-shrink-0') %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index a51db4860..6ac21ad40 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, t('users')) if turbo_native_app? %>
<%= render 'shared/settings_nav' %>
diff --git a/app/views/webhook_settings/index.html.erb b/app/views/webhook_settings/index.html.erb index 7448e57fd..c18914bac 100644 --- a/app/views/webhook_settings/index.html.erb +++ b/app/views/webhook_settings/index.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, t('webhooks')) if turbo_native_app? %>
<%= render 'shared/settings_nav' %>
diff --git a/app/views/webhook_settings/show.html.erb b/app/views/webhook_settings/show.html.erb index 47911b855..ed6d5f48d 100644 --- a/app/views/webhook_settings/show.html.erb +++ b/app/views/webhook_settings/show.html.erb @@ -1,3 +1,4 @@ +<% content_for(:native_title, 'Webhook') if turbo_native_app? %>
<%= render 'shared/settings_nav' %>