Skip to content

Commit

Permalink
Reverted changes to git import form.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 committed Jul 10, 2019
1 parent 9e1feb4 commit 3f4607d
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/helpers/miq_ae_tools_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@ module MiqAeToolsHelper
def git_import_button_enabled?
GitBasedDomainImportService.available?
end

def git_import_submit_help
unless git_import_button_enabled?
content_tag(
:i,
"",
:class => ["fa", "fa-lg", "fa-question-circle"],
:title => _("Please enable the git owner role in order to import git repositories")
)
end
end
end
34 changes: 33 additions & 1 deletion app/views/miq_ae_tools/_import_export.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,39 @@
%hr
%h3
= _('Import Datastore via git')
= react('ImportDatastoreViaGit', { :disableSubmit => !git_import_button_enabled? })
= form_tag({:action => "retrieve_git_datastore"},
:target => "upload_target",
:method => :post,
:id => "retrieve-git-datastore-form") do
.form-horizontal
.form-group
%label.col-sm-2.control-label
= _('Git URL:')
.col-md-8
= text_field_tag(:git_url, nil, :size => 128)
.form-group
%label.col-sm-2.control-label
= _('Username (optional):')
.col-md-8
= text_field_tag(:git_username, nil)
.form-group
%label.col-sm-2.control-label
= _('Password (optional):')
.col-md-8
= password_field_tag(:git_password, nil)
.form-group
%label.col-md-2.control-label
= _("Verify Peer Certificate")
.col-md-8
= check_box_tag(:git_verify_ssl, true, true)
.form-group
.col-sm-2
.col-md-8
= submit_tag(_("Submit"),
:id => "git-url-import",
:class => "git-retrieve-datastore btn btn-default",
:disabled => !git_import_button_enabled?)
= git_import_submit_help

%hr
%h3
Expand Down
25 changes: 25 additions & 0 deletions spec/helpers/miq_ae_tools_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,29 @@
end
end
end

describe "#git_import_submit_help" do
let(:my_region) { double("MiqRegion") }

before do
allow(MiqRegion).to receive(:my_region).and_return(my_region)
allow(my_region).to receive(:role_active?).with("git_owner").and_return(active_git_owner)
end

context "when the MiqRegion has an active git_owner role" do
let(:active_git_owner) { true }

it "renders nothing" do
expect(helper.git_import_submit_help).to eq(nil)
end
end

context "when the MiqRegion does not have an active git_owner role" do
let(:active_git_owner) { false }

it "renders an i tag with a title and class" do
expect(helper.git_import_submit_help).to eq("<i class=\"fa fa-lg fa-question-circle\" title=\"Please enable the git owner role in order to import git repositories\"></i>")
end
end
end
end

0 comments on commit 3f4607d

Please sign in to comment.