Changeset - 43cafe348c9a
[Not reviewed]
default
0 3 0
Mads Kiilerich - 11 years ago 2014-08-21 23:46:55
madski@unity3d.com
files: show a select2 branch selector on the files page
3 files changed with 30 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/files.py
Show inline comments
 
@@ -189,6 +189,15 @@ class FilesController(BaseRepoController
 
        if request.environ.get('HTTP_X_PARTIAL_XHR'):
 
            return render('files/files_ypjax.html')
 

	
 
        # TODO: tags and bookmarks?
 
        c.revision_options = [(c.changeset.raw_id, 
 
                              _('%s at %s') % (c.changeset.branch, h.short_id(c.changeset.raw_id)))] + \
 
            [(n, b) for b, n in c.db_repo_scm_instance.branches.items()]
 
        if c.db_repo_scm_instance.closed_branches:
 
            prefix = _('(closed)') + ' '
 
            c.revision_options += [('-', '-')] + \
 
                [(n, prefix + b) for b, n in c.db_repo_scm_instance.closed_branches.items()]
 

	
 
        return render('files/files.html')
 

	
 
    @LoginRequired()
kallithea/templates/files/files.html
Show inline comments
 
@@ -29,8 +29,8 @@ ${self.repo_context_bar('files', c.revis
 
    <div class="title">
 
        ${self.breadcrumbs()}
 
        <ul class="links">
 
            <li>
 
              <span><a href="#">${_('Branch')}: ${c.changeset.branch}</a></span>
 
            <li style="color:white">
 
              ${_("Branch filter:")} ${h.select('branch_selector',c.changeset.raw_id,c.revision_options)}
 
            </li>
 
        </ul>
 
    </div>
 
@@ -239,6 +239,23 @@ $(document).ready(function(){
 
       }
 
    }
 
    fileBrowserListeners(_State.url, _State.data.node_list_url, _State.data.url_base);
 

	
 
    // change branch filter
 
    $("#branch_selector").select2({
 
        dropdownAutoWidth: true,
 
        minimumInputLength: 1,
 
        });
 

	
 
    $("#branch_selector").change(function(e){
 
        var selected = e.currentTarget.options[e.currentTarget.selectedIndex].value;
 
        if(selected && selected != "${c.changeset.raw_id}"){
 
            window.location = pyroutes.url('files_home', {'repo_name': "${h.safe_unicode(c.repo_name)}", 'revision': selected, 'f_path': "${h.safe_unicode(c.file.path)}"});
 
            $("#browserblock").hide();
 
        } else {
 
            $("#branch_selector").val("${c.changeset.raw_id}");
 
        }
 
    });
 

	
 
});
 

	
 
</script>
kallithea/tests/functional/test_files.py
Show inline comments
 
@@ -73,7 +73,7 @@ class TestFilesController(TestController
 
                                    revision='97e8b885c04894463c51898e14387d80c30ed1ee',
 
                                    f_path='/'))
 

	
 
        response.mustcontain("""<a href="#">Branch: git</a>""")
 
        response.mustcontain("""<option selected="selected" value="97e8b885c04894463c51898e14387d80c30ed1ee">git at 97e8b885c048</option>""")
 

	
 
    def test_index_paging(self):
 
        self.log_user()
 
@@ -105,7 +105,7 @@ Improved test to clone into uniq reposit
 
removed extra unicode conversion in diff.</div>
 
""")
 

	
 
        response.mustcontain("""<a href="#">Branch: default</a>""")
 
        response.mustcontain("""<option selected="selected" value="8911406ad776fdd3d0b9932a2e89677e57405a48">default at 8911406ad776</option>""")
 

	
 
    def test_file_source_history(self):
 
        self.log_user()
0 comments (0 inline, 0 general)