Commit 0b9cd0a1 authored by Annabel Dunstone's avatar Annabel Dunstone

Populate dropdowns with current build on pageload

parent f97939a7
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
Build.state = null; Build.state = null;
function Build(page_url, build_url, build_status, state1) { function Build(page_url, build_url, build_status, build_stage, build_name, state1) {
this.page_url = page_url; this.page_url = page_url;
this.build_url = build_url; this.build_url = build_url;
this.build_status = build_status; this.build_status = build_status;
...@@ -17,7 +17,12 @@ ...@@ -17,7 +17,12 @@
clearInterval(Build.interval); clearInterval(Build.interval);
this.bp = Breakpoints.get(); this.bp = Breakpoints.get();
$('.js-build-sidebar').niceScroll(); $('.js-build-sidebar').niceScroll();
this.populateJobDropdown(build_stage);
this.updateStageDropdownText(build_stage);
this.updateJobDropdownText(build_name);
this.hideSidebar(); this.hideSidebar();
$(document).off('click', '.js-sidebar-build-toggle').on('click', '.js-sidebar-build-toggle', this.toggleSidebar); $(document).off('click', '.js-sidebar-build-toggle').on('click', '.js-sidebar-build-toggle', this.toggleSidebar);
$(window).off('resize.build').on('resize.build', this.hideSidebar); $(window).off('resize.build').on('resize.build', this.hideSidebar);
$(document).on('click', '.stage-item', this.updateDropdown); $(document).on('click', '.stage-item', this.updateDropdown);
...@@ -139,10 +144,19 @@ ...@@ -139,10 +144,19 @@
$('.build-job[data-stage="' + stage + '"]').show(); $('.build-job[data-stage="' + stage + '"]').show();
}; };
Build.prototype.updateStageDropdownText = function(stage) {
$('.stage-selection').text(stage);
this.updateJobDropdownText('-');
};
Build.prototype.updateJobDropdownText = function(name) {
$('.build-selection').text(name);
};
Build.prototype.updateDropdown = function(e) { Build.prototype.updateDropdown = function(e) {
e.preventDefault(); e.preventDefault();
var stage = e.target.text; var stage = e.target.text;
$('.stage-selection').text(stage); this.updateStageDropdownText(stage);
this.populateJobDropdown(stage); this.populateJobDropdown(stage);
}; };
......
...@@ -82,4 +82,4 @@ ...@@ -82,4 +82,4 @@
= render "sidebar" = render "sidebar"
:javascript :javascript
new Build("#{namespace_project_build_url(@project.namespace, @project, @build)}", "#{namespace_project_build_url(@project.namespace, @project, @build, :json)}", "#{@build.status}", "#{trace_with_state[:state]}") new Build("#{namespace_project_build_url(@project.namespace, @project, @build)}", "#{namespace_project_build_url(@project.namespace, @project, @build, :json)}", "#{@build.status}", "#{@build.stage}", "#{@build.name}", "#{trace_with_state[:state]}")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment