Skip to content

Commit

Permalink
Fix displaying 'Add a Provider' page on a fresh appliance
Browse files Browse the repository at this point in the history
  • Loading branch information
hstastna committed Jul 8, 2019
1 parent 79e4310 commit 2b9a53d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/services/user_validation_service.rb
Expand Up @@ -49,9 +49,8 @@ def validate_user(user, task_id = nil, request = nil, authenticate_options = {})

# Start super admin at the main db if the main db has no records yet
# If the main db has no records the default starting view is set to "Infrastructure Provider" view - the idea here is there is no point showing another view since it would be empty.
return validate_user_handle_no_records if db_user.super_admin_user? &&
::Settings.product.maindb &&
!::Settings.product.maindb.constantize.first
# The above is true except Embedded Ansible provider which is added by default
return validate_user_handle_no_records if db_user.super_admin_user? && no_records?

startpage = start_url_for_user(start_url)
unless startpage
Expand All @@ -62,6 +61,12 @@ def validate_user(user, task_id = nil, request = nil, authenticate_options = {})

private

def no_records?
if ::Settings.product.maindb
::Settings.product.maindb.constantize.count <= ::ManageIQ::Providers::EmbeddedAnsible::AutomationManager.count
end
end

def validate_user_handle_no_records
ValidateResult.new(:pass, nil, url_for_only_path(:controller => "ems_infra", :action => 'show_list'))
end
Expand Down

0 comments on commit 2b9a53d

Please sign in to comment.