From: Tom Hughes Date: Thu, 21 Mar 2024 17:25:41 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/4612' X-Git-Tag: live~1181 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/b2acd6e49c9533f9b49bf6f377835508a0a6d53d?hp=9c0d74fe690b76b1d307c3764532f4f89c7192dd Merge remote-tracking branch 'upstream/pull/4612' --- diff --git a/Gemfile b/Gemfile index 0b7e25ec9..13daf8267 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source "https://rubygems.org" # Require rails gem "rails", "~> 7.1.0" +gem "turbo-rails" # Require json for multi_json gem "json" diff --git a/Gemfile.lock b/Gemfile.lock index 958f4579b..77cf3dc19 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -563,6 +563,10 @@ GEM thor (1.3.1) tilt (2.3.0) timeout (0.4.1) + turbo-rails (2.0.4) + actionpack (>= 6.0.0) + activejob (>= 6.0.0) + railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) @@ -680,6 +684,7 @@ DEPENDENCIES sprockets-exporters_pack strong_migrations terser + turbo-rails unicode-display_width validates_email_format_of (>= 1.5.1) vendorer diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 0bfff869e..c71c0652d 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -69,6 +69,10 @@ window.updateLinks = function (loc, zoom, layers, object) { }; $(document).ready(function () { + // NB: Turns Turbo Drive off by default. Turbo Drive must be opt-in on a per-link and per-form basis + // See https://turbo.hotwired.dev/reference/drive#turbo.session.drive + Turbo.session.drive = false; + var headerWidth = 0, compactWidth = 0; @@ -108,6 +112,7 @@ $(document).ready(function () { updateHeader(); $(window).resize(updateHeader); + $(document).on("turbo:render", updateHeader); }, 0); $("#menu-icon").on("click", function (e) { diff --git a/app/assets/javascripts/messages.js b/app/assets/javascripts/messages.js index cc86da05e..eef06457b 100644 --- a/app/assets/javascripts/messages.js +++ b/app/assets/javascripts/messages.js @@ -1,36 +1,16 @@ $(document).ready(function () { - $(".inbox-mark-unread").on("ajax:success", function (event, data) { - updateHtml(data); - updateReadState(this, false); + $(".messages-table .destroy-message").on("turbo:submit-end", function (event) { + if (event.detail.success) { + event.target.dataset.isDestroyed = true; + } }); - $(".inbox-mark-read").on("ajax:success", function (event, data) { - updateHtml(data); - updateReadState(this, true); + $(".messages-table .message-summary").on("turbo:before-morph-element", function (event) { + if ($(event.target).find("[data-is-destroyed]").length > 0) { + event.preventDefault(); // NB: prevent Turbo from morhping/removing this element + $(event.target).fadeOut(800, "linear", function () { + $(this).remove(); + }); + } }); - - $(".inbox-destroy").on("ajax:success", function (event, data) { - updateHtml(data); - - $(this).closest("tr").fadeOut(800, "linear", function () { - $(this).remove(); - }); - }); - - function updateHtml(data) { - $("#inboxanchor").remove(); - $(".user-button").before(data.inboxanchor); - - $("#inbox-count").replaceWith(data.inbox_count); - $("#outbox-count").replaceWith(data.outbox_count); - $("#muted-count").replaceWith(data.muted_count); - } - - function updateReadState(target, isRead) { - $(target).closest("tr") - .toggleClass("inbox-row", isRead) - .toggleClass("inbox-row-unread", !isRead) - .find(".inbox-mark-unread").prop("hidden", !isRead).end() - .find(".inbox-mark-read").prop("hidden", isRead); - } }); diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 2ca86fc02..d231fddde 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -60,12 +60,12 @@ class MessagesController < ApplicationController @message = Message.where(:recipient => current_user).or(Message.where(:sender => current_user.id)).find(params[:id]) @message.from_user_visible = false if @message.sender == current_user @message.to_user_visible = false if @message.recipient == current_user - if @message.save && !request.xhr? + if @message.save flash[:notice] = t ".destroyed" referer = safe_referer(params[:referer]) if params[:referer] - redirect_to referer || { :action => :inbox } + redirect_to referer || { :action => :inbox }, :status => :see_other end rescue ActiveRecord::RecordNotFound @title = t "messages.no_such_message.title" @@ -125,9 +125,9 @@ class MessagesController < ApplicationController notice = t ".as_read" end @message.message_read = message_read - if @message.save && !request.xhr? + if @message.save flash[:notice] = notice - redirect_to :action => :inbox + redirect_back_or_to inbox_messages_path, :status => :see_other end rescue ActiveRecord::RecordNotFound @title = t "messages.no_such_message.title" diff --git a/app/views/changesets/history.html.erb b/app/views/changesets/history.html.erb index a9970e652..a536677b0 100644 --- a/app/views/changesets/history.html.erb +++ b/app/views/changesets/history.html.erb @@ -6,7 +6,7 @@ <% set_title(changeset_index_title(params, current_user)) @heading = if params[:display_name] - t("changesets.index.title_user_link_html", :user_link => link_to(params[:display_name], user_path(:display_name => params[:display_name]))) + t("changesets.index.title_user_link_html", :user_link => link_to(params[:display_name], user_path(params[:display_name]))) else @title end %> diff --git a/app/views/diary_entries/_diary_comment.html.erb b/app/views/diary_entries/_diary_comment.html.erb index 04e011574..5ade361aa 100644 --- a/app/views/diary_entries/_diary_comment.html.erb +++ b/app/views/diary_entries/_diary_comment.html.erb @@ -3,7 +3,7 @@ <%= user_thumbnail diary_comment.user %>
-

<%= t(".comment_from_html", :link_user => (link_to diary_comment.user.display_name, user_path(diary_comment.user)), :comment_created_at => link_to(l(diary_comment.created_at, :format => :friendly), :anchor => "comment#{diary_comment.id}")) %> +

<%= t(".comment_from_html", :link_user => (link_to diary_comment.user.display_name, diary_comment.user), :comment_created_at => link_to(l(diary_comment.created_at, :format => :friendly), :anchor => "comment#{diary_comment.id}")) %> <% if current_user and diary_comment.user.id != current_user.id %> | <%= report_link(t(".report"), diary_comment) %> <% end %> @@ -13,9 +13,9 @@ <% if can? :hidecomment, DiaryEntry %> <% if diary_comment.visible? %> - <%= link_to t(".hide_link"), hide_diary_comment_path(:display_name => diary_comment.diary_entry.user.display_name, :id => diary_comment.diary_entry.id, :comment => diary_comment.id), :method => :post, :data => { :confirm => t(".confirm") } %> + <%= link_to t(".hide_link"), hide_diary_comment_path(diary_comment.diary_entry.user, diary_comment.diary_entry, diary_comment), :method => :post, :data => { :confirm => t(".confirm") } %> <% else %> - <%= link_to t(".unhide_link"), unhide_diary_comment_path(:display_name => diary_comment.diary_entry.user.display_name, :id => diary_comment.diary_entry.id, :comment => diary_comment.id), :method => :post, :data => { :confirm => t(".confirm") } %> + <%= link_to t(".unhide_link"), unhide_diary_comment_path(diary_comment.diary_entry.user, diary_comment.diary_entry, diary_comment), :method => :post, :data => { :confirm => t(".confirm") } %> <% end %> <% end %> diff --git a/app/views/diary_entries/_diary_entry.html.erb b/app/views/diary_entries/_diary_entry.html.erb index 8bd4dc57f..a25ef10db 100644 --- a/app/views/diary_entries/_diary_entry.html.erb +++ b/app/views/diary_entries/_diary_entry.html.erb @@ -24,7 +24,7 @@ <% end %> <% if current_user && current_user == diary_entry.user %> -

  • <%= link_to t(".edit_link"), :action => "edit", :display_name => diary_entry.user.display_name, :id => diary_entry.id %>
  • +
  • <%= link_to t(".edit_link"), edit_diary_entry_path(diary_entry.user, diary_entry) %>
  • <% end %> <% if current_user and diary_entry.user != current_user %> @@ -36,9 +36,9 @@ <% if can? :hide, DiaryEntry %>
  • <% if diary_entry.visible %> - <%= link_to t(".hide_link"), hide_diary_entry_path(:display_name => diary_entry.user.display_name, :id => diary_entry.id), :method => :post, :data => { :confirm => t(".confirm") } %> + <%= link_to t(".hide_link"), hide_diary_entry_path(diary_entry.user, diary_entry), :method => :post, :data => { :confirm => t(".confirm") } %> <% else %> - <%= link_to t(".unhide_link"), unhide_diary_entry_path(:display_name => diary_entry.user.display_name, :id => diary_entry.id), :method => :post, :data => { :confirm => t(".confirm") } %> + <%= link_to t(".unhide_link"), unhide_diary_entry_path(diary_entry.user, diary_entry), :method => :post, :data => { :confirm => t(".confirm") } %> <% end %>
  • <% end %> diff --git a/app/views/diary_entries/_diary_entry_heading.html.erb b/app/views/diary_entries/_diary_entry_heading.html.erb index ef924ffdd..30f7bc03b 100644 --- a/app/views/diary_entries/_diary_entry_heading.html.erb +++ b/app/views/diary_entries/_diary_entry_heading.html.erb @@ -13,7 +13,7 @@ <% end %> - <%= t("diary_entries.diary_entry.posted_by_html", :link_user => (link_to diary_entry.user.display_name, user_path(diary_entry.user)), :created => l(diary_entry.created_at, :format => :blog), :language_link => (link_to diary_entry.language.name, :controller => "diary_entries", :action => "index", :display_name => nil, :language => diary_entry.language_code)) %> + <%= t("diary_entries.diary_entry.posted_by_html", :link_user => (link_to diary_entry.user.display_name, diary_entry.user), :created => l(diary_entry.created_at, :format => :blog), :language_link => (link_to diary_entry.language.name, :controller => "diary_entries", :action => "index", :display_name => nil, :language => diary_entry.language_code)) %> <% if (l(diary_entry.updated_at, :format => :blog) != l(diary_entry.created_at, :format => :blog)) %> <%= t("diary_entries.diary_entry.updated_at_html", :updated => l(diary_entry.updated_at, :format => :blog)) %> <% end %> diff --git a/app/views/diary_entries/_location.html.erb b/app/views/diary_entries/_location.html.erb index d5860f11d..ae48e86b9 100644 --- a/app/views/diary_entries/_location.html.erb +++ b/app/views/diary_entries/_location.html.erb @@ -1,7 +1,9 @@ <%= t ".location" %> - "index", :anchor => "map=14/#{location.latitude}/#{location.longitude}" %>"> - number_with_precision(location.latitude, :precision => 4), :longitude => number_with_precision(location.longitude, :precision => 4) %>"> -<%= describe_location location.latitude, location.longitude, 14, location.language_code %> - - +<%= link_to root_path(:anchor => "map=14/#{location.latitude}/#{location.longitude}") do + tag.abbr :class => "geo", + :title => t(".coordinates", :latitude => number_with_precision(location.latitude, :precision => 4), + :longitude => number_with_precision(location.longitude, :precision => 4)) do + describe_location location.latitude, location.longitude, 14, location.language_code + end + end %> diff --git a/app/views/diary_entries/comments.html.erb b/app/views/diary_entries/comments.html.erb index 61ceccdc0..aa0fceb95 100644 --- a/app/views/diary_entries/comments.html.erb +++ b/app/views/diary_entries/comments.html.erb @@ -1,6 +1,6 @@ <% content_for :heading do %>

    <%= t ".heading", :user => @user.display_name %>

    -

    <%= t ".subheading_html", :user => link_to(@user.display_name, user_path(@user)) %>

    +

    <%= t ".subheading_html", :user => link_to(@user.display_name, @user) %>

    <% end %> <% if @comments.empty? %> diff --git a/app/views/diary_entries/show.html.erb b/app/views/diary_entries/show.html.erb index 63ab89b8f..0aea2d442 100644 --- a/app/views/diary_entries/show.html.erb +++ b/app/views/diary_entries/show.html.erb @@ -19,9 +19,9 @@ <% if current_user %>
    <% if @entry.subscribers.exists?(current_user.id) %> - <%= link_to t("javascripts.changesets.show.unsubscribe"), diary_entry_unsubscribe_path(:display_name => @entry.user.display_name, :id => @entry.id), :method => :post, :class => "btn btn-sm btn-primary" %> + <%= link_to t("javascripts.changesets.show.unsubscribe"), diary_entry_unsubscribe_path(@entry.user, @entry), :method => :post, :class => "btn btn-sm btn-primary" %> <% else %> - <%= link_to t("javascripts.changesets.show.subscribe"), diary_entry_subscribe_path(:display_name => @entry.user.display_name, :id => @entry.id), :method => :post, :class => "btn btn-sm btn-primary" %> + <%= link_to t("javascripts.changesets.show.subscribe"), diary_entry_subscribe_path(@entry.user, @entry.id), :method => :post, :class => "btn btn-sm btn-primary" %> <% end %>
    <% end %> diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb index 34046bcab..724ca5526 100644 --- a/app/views/layouts/_head.html.erb +++ b/app/views/layouts/_head.html.erb @@ -2,6 +2,7 @@ <%= javascript_include_tag "es6" unless browser.es6? %> + <%= javascript_include_tag "turbo", :type => "module" %> <%= javascript_include_tag "application" %> <%= javascript_include_tag "i18n/#{I18n.locale}" %> <%= stylesheet_link_tag "screen-#{dir}", :media => "screen" %> diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index e9ded0f75..97be3f7b8 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -96,7 +96,7 @@ <%= t("users.show.my messages") %> <%= number_with_delimiter(current_user.new_messages.size) %> <% end %> - <%= link_to t("users.show.my profile"), user_path(current_user), :class => "dropdown-item" %> + <%= link_to t("users.show.my profile"), current_user, :class => "dropdown-item" %> <%= link_to t("users.show.my settings"), edit_account_path, :class => "dropdown-item" %> <%= link_to t("users.show.my_preferences"), preferences_path, :class => "dropdown-item" %> diff --git a/app/views/layouts/_meta.html.erb b/app/views/layouts/_meta.html.erb index 3517673ac..2352ad0b6 100644 --- a/app/views/layouts/_meta.html.erb +++ b/app/views/layouts/_meta.html.erb @@ -13,6 +13,8 @@ <%= tag.meta :name => "msapplication-TileColor", :content => "#00a300" %> <%= tag.meta :name => "msapplication-TileImage", :content => image_path("mstile-144x144.png") %> <%= tag.meta :name => "theme-color", :content => "#ffffff" %> +<%= turbo_refresh_method_tag :morph %> +<%= turbo_refresh_scroll_tag :preserve %> <%= canonical_tag %> <% if Settings.key?(:publisher_url) -%> <%= tag.link :rel => "publisher", :href => Settings.publisher_url %> diff --git a/app/views/messages/_inbox_count.html.erb b/app/views/messages/_inbox_count.html.erb deleted file mode 100644 index 86bb2c474..000000000 --- a/app/views/messages/_inbox_count.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -

    -<%= t "messages.inbox.messages", - :new_messages => t("messages.inbox.new_messages", - :count => current_user.new_messages.size), - :old_messages => t("messages.inbox.old_messages", - :count => current_user.messages.size - current_user.new_messages.size) %> -

    diff --git a/app/views/messages/_message_summary.html.erb b/app/views/messages/_message_summary.html.erb index cb85a62ba..81ef48402 100644 --- a/app/views/messages/_message_summary.html.erb +++ b/app/views/messages/_message_summary.html.erb @@ -1,13 +1,13 @@ -"> - <%= link_to message.sender.display_name, message.sender %> - <%= link_to message.title, message %> +"> + <%= link_to message.sender.display_name, user_path(message.sender) %> + <%= link_to message.title, message_path(message) %> <%= l message.sent_on, :format => :friendly %> - <%= button_to t(".unread_button"), message_mark_path(message, :mark => "unread"), :remote => true, :class => "btn btn-sm btn-primary", :form => { :class => "inbox-mark-unread", :hidden => !message.message_read? } %> - <%= button_to t(".read_button"), message_mark_path(message, :mark => "read"), :remote => true, :class => "btn btn-sm btn-primary", :form => { :class => "inbox-mark-read", :hidden => message.message_read? } %> - <%= button_to t(".destroy_button"), message_path(message, :referer => request.fullpath), :method => :delete, :remote => true, :class => "btn btn-sm btn-danger", :form_class => "inbox-destroy" %> + <%= button_to t(".unread_button"), message_mark_path(message, :mark => "unread"), :class => "btn btn-sm btn-primary", :form => { :data => { :turbo => true }, :class => "inbox-mark-unread", :hidden => !message.message_read? } %> + <%= button_to t(".read_button"), message_mark_path(message, :mark => "read"), :class => "btn btn-sm btn-primary", :form => { :data => { :turbo => true }, :class => "inbox-mark-read", :hidden => message.message_read? } %> + <%= button_to t(".destroy_button"), message_path(message, :referer => request.fullpath), :method => :delete, :class => "btn btn-sm btn-danger", :form => { :data => { :turbo => true }, :class => "destroy-message" } %> <% if message.muted? %> - <%= button_to t(".unmute_button"), message_unmute_path(message), :method => :patch, :class => "btn btn-sm btn-secondary" %> + <%= button_to t(".unmute_button"), message_unmute_path(message), :method => :patch, :class => "btn btn-sm btn-secondary", :form => { :data => { :turbo => true } } %> <% end %> diff --git a/app/views/messages/_messages_table.html.erb b/app/views/messages/_messages_table.html.erb index ce222dfab..f11fe3f62 100644 --- a/app/views/messages/_messages_table.html.erb +++ b/app/views/messages/_messages_table.html.erb @@ -1,4 +1,4 @@ - +
    <% columns.each do |column| %> diff --git a/app/views/messages/_muted_count.html.erb b/app/views/messages/_muted_count.html.erb deleted file mode 100644 index 207973d58..000000000 --- a/app/views/messages/_muted_count.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -

    -<%= t "messages.muted.messages", :count => current_user.muted_messages.size %> -

    diff --git a/app/views/messages/_outbox_count.html.erb b/app/views/messages/_outbox_count.html.erb deleted file mode 100644 index 5b27f1d6e..000000000 --- a/app/views/messages/_outbox_count.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -

    -<%= t "messages.outbox.messages", :count => current_user.sent_messages.size %> -

    diff --git a/app/views/messages/_sent_message_summary.html.erb b/app/views/messages/_sent_message_summary.html.erb index a9f011f5e..683d8d6ad 100644 --- a/app/views/messages/_sent_message_summary.html.erb +++ b/app/views/messages/_sent_message_summary.html.erb @@ -1,8 +1,8 @@ - - - + + + diff --git a/app/views/messages/destroy.json.jbuilder b/app/views/messages/destroy.json.jbuilder deleted file mode 100644 index 65bfd6a6b..000000000 --- a/app/views/messages/destroy.json.jbuilder +++ /dev/null @@ -1,4 +0,0 @@ -json.inboxanchor render(:partial => "layouts/inbox") -json.inbox_count render(:partial => "inbox_count") -json.outbox_count render(:partial => "outbox_count") -json.muted_count render(:partial => "muted_count") diff --git a/app/views/messages/inbox.html.erb b/app/views/messages/inbox.html.erb index 611b0b1c9..835d70a74 100644 --- a/app/views/messages/inbox.html.erb +++ b/app/views/messages/inbox.html.erb @@ -4,7 +4,7 @@ <%= render :partial => "heading", :locals => { :active_link_path => inbox_messages_path } %> -<%= render :partial => "inbox_count" %> +

    <%= t "messages.inbox.messages", :new_messages => t(".new_messages", :count => current_user.new_messages.size), :old_messages => t(".old_messages", :count => current_user.messages.size - current_user.new_messages.size) %>

    <% if current_user.messages.size > 0 %> <%= render :partial => "messages_table", :locals => { :columns => %w[from subject date], :messages => current_user.messages, :inner_partial => "message_summary" } %> diff --git a/app/views/messages/mark.json.jbuilder b/app/views/messages/mark.json.jbuilder deleted file mode 100644 index 65bfd6a6b..000000000 --- a/app/views/messages/mark.json.jbuilder +++ /dev/null @@ -1,4 +0,0 @@ -json.inboxanchor render(:partial => "layouts/inbox") -json.inbox_count render(:partial => "inbox_count") -json.outbox_count render(:partial => "outbox_count") -json.muted_count render(:partial => "muted_count") diff --git a/app/views/messages/muted.html.erb b/app/views/messages/muted.html.erb index 8e97abc7f..40c74e915 100644 --- a/app/views/messages/muted.html.erb +++ b/app/views/messages/muted.html.erb @@ -4,6 +4,6 @@ <%= render :partial => "heading", :locals => { :active_link_path => muted_messages_path } %> -<%= render :partial => "muted_count" %> +

    <%= t ".messages", :count => current_user.muted_messages.size %>

    <%= render :partial => "messages_table", :locals => { :columns => %w[from subject date], :messages => current_user.muted_messages, :inner_partial => "message_summary" } %> diff --git a/app/views/messages/outbox.html.erb b/app/views/messages/outbox.html.erb index 096427e8d..5cb357f6f 100644 --- a/app/views/messages/outbox.html.erb +++ b/app/views/messages/outbox.html.erb @@ -4,7 +4,7 @@ <%= render :partial => "heading", :locals => { :active_link_path => outbox_messages_path } %> -<%= render :partial => "outbox_count" %> +

    <%= t ".messages", :count => current_user.sent_messages.size %>

    <% if current_user.sent_messages.size > 0 %> <%= render :partial => "messages_table", :locals => { :columns => %w[to subject date], :messages => current_user.sent_messages, :inner_partial => "sent_message_summary" } %> diff --git a/app/views/notes/index.html.erb b/app/views/notes/index.html.erb index ef6251634..d93978480 100644 --- a/app/views/notes/index.html.erb +++ b/app/views/notes/index.html.erb @@ -1,7 +1,7 @@ <% content_for :heading do %>

    <%= t ".heading", :user => @user.display_name %>

    <%= t ".subheading_html", - :user => link_to(@user.display_name, user_path(@user)), + :user => link_to(@user.display_name, @user), :submitted => tag.span(t(".subheading_submitted"), :class => "px-2 py-1 bg-primary bg-opacity-25"), :commented => tag.span(t(".subheading_commented"), :class => "px-2 py-1 bg-white") %>

    <% end %> diff --git a/app/views/oauth/authorize.html.erb b/app/views/oauth/authorize.html.erb index 8576ea3ab..b8fe11f75 100644 --- a/app/views/oauth/authorize.html.erb +++ b/app/views/oauth/authorize.html.erb @@ -2,7 +2,7 @@

    <%= t ".title" %>

    <% end %> -

    <%= t(".request_access_html", :app_name => link_to(@token.client_application.name, @token.client_application.url), :user => link_to(current_user.display_name, user_path(current_user))) %>

    +

    <%= t(".request_access_html", :app_name => link_to(@token.client_application.name, @token.client_application.url), :user => link_to(current_user.display_name, current_user)) %>

    <%= bootstrap_form_tag do |f| %> <%= f.hidden_field :oauth_token, :value => @token.token %> diff --git a/app/views/profiles/edit.html.erb b/app/views/profiles/edit.html.erb index b207e72e2..47282d5a2 100644 --- a/app/views/profiles/edit.html.erb +++ b/app/views/profiles/edit.html.erb @@ -60,5 +60,5 @@ <%= f.primary t(".save") %> - <%= link_to t(".cancel"), user_path(current_user), :class => "btn btn-link" %> + <%= link_to t(".cancel"), current_user, :class => "btn btn-link" %> <% end %> diff --git a/app/views/redactions/show.html.erb b/app/views/redactions/show.html.erb index 22d17cd5d..5b9749a51 100644 --- a/app/views/redactions/show.html.erb +++ b/app/views/redactions/show.html.erb @@ -5,7 +5,7 @@

    <%= t ".user" %> - <%= link_to(@redaction.user.display_name, user_path(@redaction.user)) %> + <%= link_to @redaction.user.display_name, @redaction.user %>

    <%= t ".description" %> diff --git a/app/views/user_mutes/index.html.erb b/app/views/user_mutes/index.html.erb index cf9e7ed6b..8779a4bba 100644 --- a/app/views/user_mutes/index.html.erb +++ b/app/views/user_mutes/index.html.erb @@ -25,7 +25,7 @@
    <%= link_to message.recipient.display_name, message.recipient %><%= link_to message.title, message %>
    <%= link_to message.recipient.display_name, user_path(message.recipient) %><%= link_to message.title, message_path(message) %> <%= l message.sent_on, :format => :friendly %> - <%= button_to t(".destroy_button"), message_path(message, :referer => request.fullpath), :method => :delete, :remote => true, :class => "btn btn-sm btn-danger", :form_class => "inbox-destroy" %> + <%= button_to t(".destroy_button"), message_path(message, :referer => request.fullpath), :method => :delete, :class => "btn btn-sm btn-danger", :form => { :data => { :turbo => true }, :class => "destroy-message" } %>
    <%= user_thumbnail_tiny user %> - <%= link_to user.display_name, user_path(user) %> + <%= link_to user.display_name, user %> <%= link_to t(".table.tbody.unmute"), user_mute_path(user), :method => :delete, :class => "btn btn-sm btn-primary" %> diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb index e419aed1d..ef50ccaf2 100644 --- a/app/views/users/_user.html.erb +++ b/app/views/users/_user.html.erb @@ -6,12 +6,12 @@

    <% if user.creation_ip %> <%= t "users.index.summary_html", - :name => link_to(user.display_name, user_path(user)), + :name => link_to(user.display_name, user), :ip_address => link_to(user.creation_ip, :ip => user.creation_ip), :date => l(user.created_at, :format => :friendly) %> <% else %> <%= t "users.index.summary_no_ip_html", - :name => link_to(user.display_name, user_path(user)), + :name => link_to(user.display_name, user), :date => l(user.created_at, :format => :friendly) %> <% end %>

    diff --git a/config/eslint.json b/config/eslint.json index 3b878d48a..397615d1a 100644 --- a/config/eslint.json +++ b/config/eslint.json @@ -13,7 +13,8 @@ "OSM": "writable", "Matomo": "readonly", "Qs": "readonly", - "updateLinks": "readonly" + "updateLinks": "readonly", + "Turbo": "readonly" }, "rules": { "accessor-pairs": "error", diff --git a/test/controllers/changesets_controller_test.rb b/test/controllers/changesets_controller_test.rb index 32a4e4f70..1fd9de2e8 100644 --- a/test/controllers/changesets_controller_test.rb +++ b/test/controllers/changesets_controller_test.rb @@ -133,7 +133,9 @@ class ChangesetsControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "history" assert_template :layout => "map" - assert_select "h2", :text => "Changesets by #{user.display_name}", :count => 1 + assert_select "h2", :text => "Changesets by #{user.display_name}", :count => 1 do + assert_select "a[href=?]", user_path(user) + end assert_select "link[rel='alternate'][type='application/atom+xml']", :count => 1 do assert_select "[href=?]", "http://www.example.com/user/#{ERB::Util.url_encode(user.display_name)}/history/feed" end diff --git a/test/controllers/diary_entries_controller_test.rb b/test/controllers/diary_entries_controller_test.rb index 84d650e23..94b706975 100644 --- a/test/controllers/diary_entries_controller_test.rb +++ b/test/controllers/diary_entries_controller_test.rb @@ -886,8 +886,9 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest get diary_comments_path(:display_name => other_user.display_name) assert_response :success assert_template :comments - assert_select "table.table-striped" do - assert_select "tr", :count => 2 # header and one comment + assert_dom "a[href='#{user_path(other_user)}']", :text => other_user.display_name + assert_select "table.table-striped tbody" do + assert_select "tr", :count => 1 end # Test a suspended user diff --git a/test/controllers/messages_controller_test.rb b/test/controllers/messages_controller_test.rb index df7146ad6..40581993f 100644 --- a/test/controllers/messages_controller_test.rb +++ b/test/controllers/messages_controller_test.rb @@ -408,15 +408,13 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest assert_not Message.find(unread_message.id).message_read # Check that the marking a message read via XHR works - post message_mark_path(:message_id => unread_message, :mark => "read"), :xhr => true - assert_response :success - assert_template "mark" + post message_mark_path(:message_id => unread_message, :mark => "read") + assert_response :see_other assert Message.find(unread_message.id).message_read # Check that the marking a message unread via XHR works - post message_mark_path(:message_id => unread_message, :mark => "unread"), :xhr => true - assert_response :success - assert_template "mark" + post message_mark_path(:message_id => unread_message, :mark => "unread") + assert_response :see_other assert_not Message.find(unread_message.id).message_read # Asking to mark a message with no ID should fail diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb index 8f764a3f2..99886c80f 100644 --- a/test/controllers/notes_controller_test.rb +++ b/test/controllers/notes_controller_test.rb @@ -42,10 +42,12 @@ class NotesControllerTest < ActionDispatch::IntegrationTest get user_notes_path(first_user) assert_response :success + assert_select ".content-heading a[href='#{user_path first_user}']", :text => first_user.display_name assert_select "table.note_list tbody tr", :count => 1 get user_notes_path(second_user) assert_response :success + assert_select ".content-heading a[href='#{user_path second_user}']", :text => second_user.display_name assert_select "table.note_list tbody tr", :count => 1 get user_notes_path("non-existent") diff --git a/test/controllers/redactions_controller_test.rb b/test/controllers/redactions_controller_test.rb index 002e483fe..5ca72fe47 100644 --- a/test/controllers/redactions_controller_test.rb +++ b/test/controllers/redactions_controller_test.rb @@ -45,6 +45,15 @@ class RedactionsControllerTest < ActionDispatch::IntegrationTest end end + def test_show + redaction = create(:redaction, :title => "tested-redaction") + + get redaction_path(redaction) + assert_response :success + assert_dom "h1", :text => /tested-redaction/ + assert_dom "a[href='#{user_path redaction.user}']", :text => redaction.user.display_name + end + def test_new get new_redaction_path assert_redirected_to login_path(:referer => new_redaction_path) diff --git a/test/controllers/user_mutes_controller_test.rb b/test/controllers/user_mutes_controller_test.rb index cc22faaaa..2e98dc819 100644 --- a/test/controllers/user_mutes_controller_test.rb +++ b/test/controllers/user_mutes_controller_test.rb @@ -18,11 +18,13 @@ class UserMutesControllerTest < ActionDispatch::IntegrationTest def test_index user = create(:user) - user.mutes.create(:subject => create(:user)) + muted_user = create(:user) + user.mutes.create(:subject => muted_user) session_for(user) get user_mutes_path assert_match "You have muted 1 User", @response.body + assert_dom "tr a[href='#{user_path muted_user}']", :text => muted_user.display_name end def test_create diff --git a/test/system/messages_test.rb b/test/system/messages_test.rb index dea0d2208..b78568314 100644 --- a/test/system/messages_test.rb +++ b/test/system/messages_test.rb @@ -36,6 +36,7 @@ class MessagesTest < ApplicationSystemTestCase assert_text "1 muted message" click_on "Delete" - assert_text "0 muted messages" + refute_text "1 muted message" + assert_text "You have 0 new messages and 0 old messages" end end