Mercurial > kallithea
changeset 4456:43cafe348c9a
files: show a select2 branch selector on the files page
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 21 Aug 2014 23:46:55 +0200 |
parents | 97f8ae90566a |
children | 3d968d66c9b9 |
files | kallithea/controllers/files.py kallithea/templates/files/files.html kallithea/tests/functional/test_files.py |
diffstat | 3 files changed, 30 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/files.py Thu Aug 21 23:46:55 2014 +0200 +++ b/kallithea/controllers/files.py Thu Aug 21 23:46:55 2014 +0200 @@ -189,6 +189,15 @@ 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()
--- a/kallithea/templates/files/files.html Thu Aug 21 23:46:55 2014 +0200 +++ b/kallithea/templates/files/files.html Thu Aug 21 23:46:55 2014 +0200 @@ -29,8 +29,8 @@ <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 @@ } } 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>
--- a/kallithea/tests/functional/test_files.py Thu Aug 21 23:46:55 2014 +0200 +++ b/kallithea/tests/functional/test_files.py Thu Aug 21 23:46:55 2014 +0200 @@ -73,7 +73,7 @@ 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 @@ 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()