From 56cbc6672e10cfc585426e90ca9f60a014973242 Mon Sep 17 00:00:00 2001 From: Alexander Zagaynov Date: Wed, 4 Sep 2019 16:56:32 +0200 Subject: [PATCH] use credentials partial --- .../angular-bootstrap/_any_field.html.haml | 24 ------------ ...th_credentials_angular_bootstrap.html.haml | 23 +++++++++++ .../angular/_multi_auth_credentials.html.haml | 38 +++++++++---------- 3 files changed, 40 insertions(+), 45 deletions(-) delete mode 100644 app/views/layouts/angular-bootstrap/_any_field.html.haml diff --git a/app/views/layouts/angular-bootstrap/_any_field.html.haml b/app/views/layouts/angular-bootstrap/_any_field.html.haml deleted file mode 100644 index ed8bf3e9e6ee..000000000000 --- a/app/views/layouts/angular-bootstrap/_any_field.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -- prefix ||= 'default' -- input_type ||= 'text' -- input_name ||= '' -- input_desc ||= '' -- input_emsg ||= '' -- input_id ||= [prefix, input_name].select(&:present?).join("_") - -%div - .form-group{"ng-class" => "{'has-error': angularForm.#{input_id}.$invalid}"} | - %label.col-md-2.control-label{"for" => input_id} - = input_desc - .col-md-4 - %input.form-control{"type" => input_type, - "id" => input_id, - "ng-required" => false, - "name" => input_id, - "ng-model" => "#{ng_model}.#{input_id}", - "checkchange" => "", - "ng-trim" => false, - "detect_spaces" => "", - "prefix" => prefix, - "reset-validation-status" => "#{prefix}_auth_status"} - %span.help-block{"ng-show" => "angularForm.#{input_id}.$error.url"} - = input_emsg diff --git a/app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml b/app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml index 65c161ea1338..072e959aee5d 100644 --- a/app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml +++ b/app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml @@ -17,8 +17,30 @@ - vm_scope ||= false - validate_button ||= true - main_scope = vm_scope ? "$parent.vm" : "$parent" +- ng_show_service_account ||= false +- service_account_label ||= _("Service account") %div{"ng-controller" => "CredentialsController as vm", "vm-scope" => "$parent.vm.model ? $parent.vm : $parent"} + + %div{"ng-show" => "#{ng_show} && #{ng_show_service_account}"} + .form-group{"ng-class" => "{'has-error': angularForm.service_account.$invalid}"} + %label.col-md-2.control-label{"for" => "#{prefix}_service_account"} + = service_account_label + .col-md-4 + - hash_for_service_account = {"type" => "text", + "id" => "#{prefix}_service_account", + "ng-required" => false, + "ng-disabled" => false, + "name" => "service_account", + "ng-model" => "#{main_scope}.#{ng_model}.service_account", + "checkchange" => "", + "ng-trim" => false, + "detect_spaces" => "", + "prefix" => "#{prefix}", + "main-scope" => "#{main_scope}", + "reset-validation-status" => "#{prefix}_auth_status"} + %input.form-control{hash_for_service_account} + %div{"ng-show" => "#{ng_show} && #{ng_show_userid}"} .form-group{"ng-class" => "{'has-error': angularForm.#{prefix}_userid.$invalid}"} %label.col-md-2.control-label{"for" => "#{prefix}_userid"} @@ -75,6 +97,7 @@ = change_stored_password %a{:href => "", "ng-show" => "vm.bChangeStoredPassword", "ng-click" => "vm.cancelPasswordChange()"} = cancel_password_change + %div{"ng-show" => "#{ng_show}", "ng-if" => "#{validate_button}"} .form-group %label.col-md-2 diff --git a/app/views/layouts/angular/_multi_auth_credentials.html.haml b/app/views/layouts/angular/_multi_auth_credentials.html.haml index ead69516cfd1..da75ee2e778a 100644 --- a/app/views/layouts/angular/_multi_auth_credentials.html.haml +++ b/app/views/layouts/angular/_multi_auth_credentials.html.haml @@ -67,28 +67,24 @@ .col-md-12{"ng-if" => "#{ng_model}" == "emsCommonModel" && "#{ng_model}.emstype == 'ec2'"} = render :partial => "layouts/angular-bootstrap/endpoints_for_url", :locals => {:prefix => "default", :ng_model => "#{ng_model}"} - = render :partial => "layouts/angular-bootstrap/any_field", - :locals => {:prefix => "", - :input_name => "service_account", - :input_desc => _("Assume role ARN"), - :input_emsg => _("Invalid ARN"), - :ng_model => "#{ng_model}"} = render :partial => "layouts/angular-bootstrap/auth_credentials_angular_bootstrap", - :locals => {:ng_show => true, - :ng_model => "#{ng_model}", - :ng_reqd_userid => true, - :ng_reqd_password => true, - :validate_url => validate_url, - :userid_label => _("Access Key ID"), - :password_label => _("Secret Access Key"), - :verify_label => _("Confirm Secret Access Key"), - :passwd_mismatch => _("Secret Access Keys do not match"), - :change_stored_password => _("Change stored secret access key"), - :cancel_password_change => _("Cancel secret access key change"), - :id => record.id, - :prefix => "default", - :verify_title_off => _("Access Key ID and matching Secret Access Key fields are needed to perform verification of credentials"), - :basic_info_needed => true} + :locals => {:ng_show => true, + :ng_model => "#{ng_model}", + :ng_reqd_userid => true, + :ng_reqd_password => true, + :validate_url => validate_url, + :userid_label => _("Access Key ID"), + :password_label => _("Secret Access Key"), + :verify_label => _("Confirm Secret Access Key"), + :passwd_mismatch => _("Secret Access Keys do not match"), + :change_stored_password => _("Change stored secret access key"), + :cancel_password_change => _("Cancel secret access key change"), + :ng_show_service_account => true, + :service_account_label => _("Assume role ARN"), + :id => record.id, + :prefix => "default", + :verify_title_off => _("Access Key ID and matching Secret Access Key fields are needed to perform verification of credentials"), + :basic_info_needed => true} .col-md-12{"ng-if" => "#{ng_model}" == "emsCommonModel" && "#{ng_model}.emstype == 'gce'"} = render :partial => "layouts/angular/auth_service_account_angular", :locals => {:ng_show => true,