Project

General

Profile

Feature #39529 » feature-39529.patch

Mizuki ISHIKAWA, 2023-11-08 09:45

View differences:

app/helpers/application_helper.rb
75 75
    end
76 76

  
77 77
    css_classes += " #{options[:class]}" if css_classes && options[:class].present?
78
    url ? link_to(name, url, :class => css_classes) : name
78
    url ? link_to(name, url, :class => css_classes, :data => options[:data]) : name
79 79
  end
80 80

  
81 81
  # Displays a link to edit group page if current user is admin
......
1275 1275
          elsif sep == "@"
1276 1276
            name = remove_double_quotes(identifier)
1277 1277
            u = User.visible.find_by("LOWER(login) = :s AND type = 'User'", :s => name.downcase)
1278
            link = link_to_user(u, :only_path => only_path, :class => 'user-mention', :mention => true) if u
1278
            if u && obj && !obj.visible?(u)
1279
              data = {warning_tooltip: l(:error_not_mentioned)}
1280
            end
1281
            link = link_to_user(u, :only_path => only_path, :class => 'user-mention', :mention => true, :data => data) if u
1279 1282
          end
1280 1283
        end
1281 1284
        (leading + (link || "#{project_prefix}#{prefix}#{repo_prefix}#{sep}#{identifier}#{comment_suffix}"))
config/locales/en.yml
244 244
  error_invalid_size_parameter: "Invalid size parameter"
245 245
  error_attachment_not_found: "Attachment %{name} not found"
246 246
  error_invalid_authenticity_token: "Invalid form authenticity token."
247
  error_not_mentioned: "You cannot mention this user because they do not have access rights."
247 248
  error_query_statement_invalid: "An error occurred while executing the query and has been logged. Please report this error to your Redmine administrator."
248 249

  
249 250
  mail_subject_lost_password: "Your %{value} password"
public/javascripts/application.js
1121 1121
      at: "center top"
1122 1122
    }
1123 1123
  });
1124

  
1125
  $("[data-warning-tooltip]:not(.no-tooltip)").tooltip({
1126
    items: '[data-warning-tooltip]',
1127
    content: function() {
1128
      return $(this).data('warning-tooltip');
1129
    },
1130
    tooltipClass: 'warning',
1131
    show: {
1132
      delay: 400
1133
    },
1134
    position: {
1135
      my: "center bottom-5",
1136
      at: "center top"
1137
    }
1138
  });
1124 1139
});
1125 1140

  
1126 1141
function inlineAutoComplete(element) {
public/stylesheets/application.css
1573 1573
  box-shadow: none;
1574 1574
  white-space: pre-wrap;
1575 1575
}
1576
.ui-tooltip.warning {
1577
  background-color: #F3EDD1;
1578
  border-color: #eadbbc;
1579
  color: #A6750C;
1580
}
1576 1581

  
1577 1582
/***** Icons *****/
1578 1583
.icon {
test/helpers/application_helper_test.rb
580 580
    end
581 581
  end
582 582

  
583
  def test_mention_link_to_users_who_are_not_authorised_to_view_the_object
584
    set_language_if_valid 'en'
585
    with_settings :text_formatting => 'textile' do
586
      issue = Issue.find(4)
587
      assert_not issue.visible?(User.find(3))
588
      assert_equal "<p>#{link_to_user(User.find(3), only_path: true, class: 'user-mention', mention: true, data: {warning_tooltip: 'You cannot mention this user because they do not have access rights.'})}</p>", textilizable("@#{User.find(3).login}", :object => issue)
589

  
590
      journal = Journal.find(2)
591
      assert_equal '<p><a href="#note-2">#note-2</a></p>', textilizable('#note-2', :object => journal)
592
    end
593
  end
594

  
583 595
  def test_link_to_note_within_the_same_page
584 596
    with_settings :text_formatting => 'textile' do
585 597
      issue = Issue.find(1)
(2-2/7)