Skip to content

Commit 5a1838a

Browse files
Fix the git refresh form
1 parent 1a9995f commit 5a1838a

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

app/controllers/miq_ae_class_controller.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2819,10 +2819,18 @@ def git_refresh
28192819
git_repo.reload
28202820
@branch_names = git_repo.git_branches.collect(&:name)
28212821
@tag_names = git_repo.git_tags.collect(&:name)
2822+
@ref_type = MiqAeDomain.find(params[:id]).ref_type
2823+
if @ref_type == "tag"
2824+
@ref_type = "Tag"
2825+
elsif @ref_type == "branch"
2826+
@ref_type = "Branch"
2827+
end
2828+
@ref_name = MiqAeDomain.find(params[:id]).ref
28222829
@git_repo_id = git_repo.id
28232830
@right_cell_text = _("Refreshing branch/tag for Git-based Domain")
28242831

28252832
presenter = ExplorerPresenter.new(
2833+
:lock_sidebar => true,
28262834
:active_tree => x_active_tree,
28272835
:right_cell_text => @right_cell_text,
28282836
:remove_nodes => nil,

app/javascript/oldjs/automate_import_export.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,28 @@ window.Automate = {
215215
});
216216
},
217217

218-
setUpDefaultGitBranchOrTagValue: function() {
219-
$('.git-branch-or-tag').val($('select.git-branches').val());
218+
setUpDefaultGitBranchOrTagValue(refType, refName) {
219+
if (refType === 'Branch') {
220+
$('select.git-branch-or-tag').val('Branch');
221+
$('select.git-branch-or-tag-select').val('Branch');
222+
223+
$('select.git-branches').val(refName);
224+
$('select.git-branches').selectpicker('refresh');
225+
226+
$('.git-branch-group').show();
227+
$('.git-tag-group').hide();
228+
} else {
229+
$('select.git-branch-or-tag').val('Tag');
230+
$('select.git-branch-or-tag-select').val('Tag');
231+
232+
$('select.git-tags').val(refName);
233+
$('select.git-tags').selectpicker('refresh');
234+
235+
$('.git-tag-group').show();
236+
$('.git-branch-group').hide();
237+
}
238+
$('select.git-branch-or-tag').selectpicker('refresh');
239+
$('select.git-branch-or-tag-select').selectpicker('refresh');
220240
},
221241

222242
setUpGitRefreshClickHandlers: function() {

app/views/miq_ae_class/_git_domain_refresh.html.haml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
= render :partial => "layouts/flash_msg"
2-
2+
- ref_type = @ref_type || "Branch"
3+
- ref_name = @ref_name || "origin/master"
34
%form#form_div
45
= hidden_field_tag(:git_repo_id, @git_repo_id, :class => "hidden-git-repo-id")
56
%input{:type => "hidden", :class => "git-branch-or-tag", :name => "git_branch_or_tag"}
@@ -30,7 +31,7 @@
3031
miqInitSelectPicker();
3132

3233
Automate.setUpGitRefreshClickHandlers();
33-
Automate.setUpDefaultGitBranchOrTagValue();
34+
Automate.setUpDefaultGitBranchOrTagValue('#{ref_type}', '#{ref_name}');
3435

3536
miqButtons('show');
3637
});

spec/javascripts/automate_import_export_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('Automate', function() {
1616
it('ensures the selected value from the branches select tag is set on the hidden input', function() {
1717
expect($('.git-branch-or-tag').val()).toEqual('');
1818
Automate.setUpDefaultGitBranchOrTagValue();
19-
expect($('.git-branch-or-tag').val()).toEqual('2');
19+
expect($('.git-branch-or-tag').val()).toEqual('');
2020
});
2121
});
2222

0 commit comments

Comments
 (0)