Feature #30829

Simpler link syntax "#note-123" to make a link to a note of the current issue

Added by Go MAEDA 5 months ago. Updated 4 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Text formatting
Target version:4.1.0
Resolution:Fixed

Description

Currently, you can link to issue notes using the syntax #98765#note-123. I propose a new syntax #note-123 to link to a note of the current issue.

Sometimes I feel that the markup used to link to a note of the current issue is too lengthy. Suppose that you are editing issue #98765 and you want to link to note-123. You can link to the note with the markup #98765#note-123. But I think #note-123 is enough when the link destination is in the current issue. Copy and paste the current issue is waste of time.

We can save time a bit if Redmine supports a new link syntax #note-123 that allows omitting issue number when linking to a note of the current issue.

30829-linkto-current-issue-note.patch Magnifier (4.06 KB) Yuichi HARADA, 2019-03-04 07:52

30829-help.patch Magnifier - Patch for wiki formatting help (102 KB) Go MAEDA, 2019-03-21 14:27

Associated revisions

Revision 17993
Added by Go MAEDA 4 months ago

Simpler link syntax "#note-123" to make a link to a note of the current issue (#30829).

Contributed by Marius BALTEANU and Yuichi HARADA.

Revision 18002
Added by Go MAEDA 4 months ago

Add a link syntax "#note-6" to help files (#30829).

Contributed by Hinako Tajima.

History

#1 Updated by Bernhard Rohloff 5 months ago

I think it's a nice usability improvement.
+1

#2 Updated by Yuuki NARA 5 months ago

+1

#3 Updated by Anonymous 5 months ago

+1

#4 Updated by Holger Just 5 months ago

Since #16313, you can already use [[#note-123]] to link to an arbitrary ID on the current page, regardless of whether this is an issue note, a wiki header, or any other id.

Maybe this is already sufficient?

#5 Updated by Go MAEDA 5 months ago

Holger Just wrote:

Since #16313, you can already use [[#note-123]] to link to an arbitrary ID on the current page, regardless of whether this is an issue note, a wiki header, or any other id.

Oh, I didn't know that! Thank you.

But my team already has a working patch. The patch will be posted soon.

I think #note-123 is even more intuitive than [[#note-123]] because it is more consistent with the syntax #98765#note-123. And [[#note-123]] looks like a link to a Wiki page.

#6 Updated by Yuichi HARADA 4 months ago

+1
The link to a note of current issue is very easy to write.
I attached a patch.

#7 Updated by Go MAEDA 4 months ago

  • Target version set to Candidate for next major release

#8 Updated by Go MAEDA 4 months ago

  • Target version changed from Candidate for next major release to 4.1.0

LGTM. Setting the target version to 4.1.0.

#9 Updated by Marius BALTEANU 4 months ago

Go MAEDA wrote:

LGTM. Setting the target version to 4.1.0.

The patch as it is cannot be committed because we should link only to anchor and not to the entire url in order to preserve existing parameters (eg: issue_count, issue_position, etc) and to prevent issue/page reloading.

#10 Updated by Marius BALTEANU 4 months ago

Maybe the below changes are enough to implement this feature:

diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 8fa56ac..c477169 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -949,6 +949,8 @@ module ApplicationHelper
                           :class => issue.css_classes,
                           :title => "#{issue.tracker.name}: #{issue.subject.truncate(100)} (#{issue.status.name})")
                 end
+              elsif identifier == 'note'
+                link = link_to("#note-#{comment_id}", "#note-#{comment_id}")
               end
             when 'document'
               if document = Document.visible.find_by_id(oid)
@@ -1066,7 +1068,7 @@ module ApplicationHelper
                 )
               )
               (
-                (?<identifier1>\d+)
+                (?<identifier1>((\d)+|(note)))
                 (?<comment_suffix>
                   (\#note)?
                   -(?<comment_id>\d+)

#11 Updated by Go MAEDA 4 months ago

Test code for Marius's patch in #30829#note-10.

diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index 619a9e544..8c841a081 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -28,7 +28,7 @@ class ApplicationHelperTest < Redmine::HelperTest
            :members, :member_roles, :roles,
            :repositories, :changesets,
            :projects_trackers,
-           :trackers, :issue_statuses, :issues, :versions, :documents,
+           :trackers, :issue_statuses, :issues, :versions, :documents, :journals,
            :wikis, :wiki_pages, :wiki_contents,
            :boards, :messages, :news,
            :attachments, :enumerations,
@@ -423,6 +423,14 @@ RAW
     to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" }
   end

+  def test_link_to_note_within_the_same_page
+    issue = Issue.find(1)
+    assert_equal '<p><a href="#note-14">#note-14</a></p>', textilizable('#note-14', :object => issue)
+
+    journal = Journal.find(2)
+    assert_equal '<p><a href="#note-2">#note-2</a></p>', textilizable('#note-2', :object => journal)
+  end
+
   def test_user_links_with_email_as_login_name_should_not_be_parsed_textile
     with_settings :text_formatting => 'textile' do
       u = User.generate!(:login => 'jsmith@somenet.foo')

#12 Updated by Go MAEDA 4 months ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you for improving Redmine.

#13 Updated by Go MAEDA 4 months ago

  • Status changed from Closed to Reopened

Also help files (public/help/*/wiki_syntax_detailed_*.html) should be updated.

#14 Updated by Go MAEDA 4 months ago

Go MAEDA wrote:

Also help files (public/help/*/wiki_syntax_detailed_*.html) should be updated.

Attaching a patch for help files on behalf of Hinako Tajima.

#15 Updated by Go MAEDA 4 months ago

  • Status changed from Reopened to Closed

Committed the patch for help files in r18002.

Also available in: Atom PDF