Skip to content

Commit

Permalink
Add search for build names (#1758)
Browse files Browse the repository at this point in the history
Update UI to allow search build by name.
  • Loading branch information
tylerwowen authored Nov 26, 2024
1 parent 47aa7bf commit e8a36ba
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions deploy-board/deploy_board/templates/builds/build_names.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
</div>
<ul class="pager">
<li>
<a href='/builds/names/?page_index={{ pageIndex|add:"-1" }}&page_size={{ pageSize }}'
<a href='/builds/names/?{% if filter %}filter={{ filter }}&{% endif %}page_index={{ pageIndex|add:"-1" }}&page_size={{ pageSize }}'
class="btn btn-default {% if disablePrevious %}disabled{% endif %}">
<span class="glyphicon glyphicon-chevron-left"></span> Previous
</a>
</li>
<li>
<a href='/builds/names/?page_index={{ pageIndex|add:"1" }}&page_size={{ pageSize }}'
<a href='/builds/names/?{% if filter %}filter={{ filter }}&{% endif %}page_index={{ pageIndex|add:"1" }}&page_size={{ pageSize }}'
class="btn btn-default {% if disableNext %}disabled{% endif %}">
Next <span class="glyphicon glyphicon-chevron-right"></span>
</a>
Expand Down
9 changes: 7 additions & 2 deletions deploy-board/deploy_board/templates/builds/builds_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@
});

function search_builds() {
commit = $('#buildSearchInputId').val();
window.location = "/builds/search_commit/" + commit;
const term = $('#buildSearchInputId').val();
const commitRegex = /^[0-9a-f]{7,40}$/i;
if (commitRegex.test(term)) {
window.location = "/builds/search_commit/" + term;
} else {
window.location = "/builds/names/?filter=" + term;
}
}
</script>
{% endblock %}
Expand Down
20 changes: 11 additions & 9 deletions deploy-board/deploy_board/webapp/build_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ def builds_landing(request):
def get_build_names(request):
index = int(request.GET.get('page_index', '1'))
size = int(request.GET.get('page_size', common.DEFAULT_BUILD_SIZE))
build_names = builds_helper.get_build_names(request, start=index, size=size)
filter = request.GET.get('filter', None)
build_names = builds_helper.get_build_names(request, start=index, size=size, filter=filter)
return render(request, 'builds/build_names.html', {
'build_names': build_names,
"pageIndex": index,
"pageSize": common.DEFAULT_BUILD_SIZE,
"pageSize": size,
"disablePrevious": index <= 1,
"disableNext": len(build_names) < common.DEFAULT_BUILD_SIZE,
"disableNext": len(build_names) < size,
"filter": filter,
})


Expand All @@ -63,9 +65,9 @@ def list_builds(request, name):
'build_name': name,
'builds': builds,
"pageIndex": index,
"pageSize": common.DEFAULT_BUILD_SIZE,
"pageSize": size,
"disablePrevious": index <= 1,
"disableNext": len(builds) < common.DEFAULT_BUILD_SIZE,
"disableNext": len(builds) < size,
})


Expand Down Expand Up @@ -100,9 +102,9 @@ def get_all_builds(request):
"buildName": name,
"branch": branch,
"pageIndex": index,
"pageSize": common.DEFAULT_BUILD_SIZE,
"pageSize": size,
"disablePrevious": index <= 1,
"disableNext": len(builds) < common.DEFAULT_BUILD_SIZE,
"disableNext": len(builds) < size,
"overridePolicy": override_policy,
"deployState": deploy_state,
})
Expand Down Expand Up @@ -152,7 +154,7 @@ def compare_commits(request):
repo = request.GET.get('repo')
scm = request.GET.get('scm')
commits, truncated, new_start_sha = common.get_commits_batch(request, scm, repo,
startSha, endSha,
startSha, endSha,
keep_first=True)
html = render_to_string('builds/commits.tmpl', {
"commits": commits,
Expand All @@ -170,7 +172,7 @@ def compare_commits_datatables(request):
startSha = request.GET.get('start_sha')
endSha = request.GET.get('end_sha')
repo = request.GET.get('repo')
scm = request.GET.get('scm')
scm = request.GET.get('scm')
commits, truncated, new_start_sha = common.get_commits_batch(request, scm, repo,
startSha, endSha,
size=2000,
Expand Down

0 comments on commit e8a36ba

Please sign in to comment.