Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverted changes to git import form. #5792

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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