changeset 7635:b293ec74ef98 stable

files: restore 'Show Authors' functionality Commit d66201a7ce6e ("files: change "callbacks" function to the more descriptive name "post_load_state" and let it take an actual state data object") broke the 'Show Authors' button when visiting a file in the files browser. The button normally shows a count of authors and their avatars, but after the aforementioned commit it did nothing. Following patch would have fixed the problems in commit d66201a7ce6e: diff --git a/kallithea/templates/files/files_source.html b/kallithea/templates/files/files_source.html --- a/kallithea/templates/files/files_source.html +++ b/kallithea/templates/files/files_source.html @@ -81,11 +81,13 @@ <script> $(document).ready(function(){ var state = { + data: { node_list_url: node_list_url.replace('__REV__',${h.js(c.changeset.raw_id)}).replace('__FPATH__', ${h.js(h.safe_unicode(c.file.path))}), url_base: url_base.replace('__REV__',${h.js(c.changeset.raw_id)}), rev: ${h.js(c.changeset.raw_id)}, f_path: ${h.js(h.safe_unicode(c.file.path))} + } } - post_load_state(State.data); // defined in files.html + post_load_state(state.data); // defined in files.html }); </script> But, later the code got refactored more, and commit 006d68c4d7b9 ("files: use the web browsers built-in js history instead of native.history.js") broke the feature further: the click handler for the button no longer got installed on the 'document-ready' event, but only when a new 'state' is loaded. And it seems there is never a situation where a new state preserves the button, so it makes no sense installing the click handler at that moment. Instead, move the click handler back to the 'document-ready' event.
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Sun, 14 Apr 2019 20:32:10 +0200
parents 6df08d78f8e7
children 25bdf9f62ab6
files kallithea/templates/files/files.html
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/templates/files/files.html	Mon Apr 08 22:06:12 2019 +0200
+++ b/kallithea/templates/files/files.html	Sun Apr 14 20:32:10 2019 +0200
@@ -205,16 +205,6 @@
           }
         }
     });
-    $('#show_authors').on('click', function(){
-        $.ajax({
-            url: pyroutes.url('files_authors_home', {'revision': _rev, 'f_path': _f_path}),
-            success: function(data) {
-                $('#file_authors').html(data);
-                $('#file_authors').show();
-                tooltip_activate();
-            }
-        });
-    });
 }
 
 $(document).ready(function(){
@@ -247,6 +237,16 @@
             $("#branch_selector").val(${h.js(c.changeset.raw_id)});
         }
     });
+    $('#show_authors').on('click', function(){
+        $.ajax({
+            url: pyroutes.url('files_authors_home', {'revision': ${h.js(c.changeset.raw_id)}, 'f_path': ${h.js(h.safe_unicode(c.file.path))}}),
+            success: function(data) {
+                $('#file_authors').html(data);
+                $('#file_authors').show();
+                tooltip_activate();
+            }
+        });
+    });
 
 });