Changeset - b293ec74ef98
[Not reviewed]
stable
0 1 0
Thomas De Schampheleire (patrickdp) - 6 years ago 2019-04-14 18:32:10
thomas.de.schampheleire@gmail.com
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.
1 file changed with 10 insertions and 10 deletions:
0 comments (0 inline, 0 general) First comment
kallithea/templates/files/files.html
Show inline comments
 
@@ -205,16 +205,6 @@ var post_load_state = function(state) {
 
          }
 
        }
 
    });
 
    $('#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 @@ var post_load_state = function(state) {
 
            $("#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();
 
            }
 
        });
 
    });
 

	
 
});
 

	
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now