ManageIQ/manageiq-ui-classic

View on GitHub
app/views/ops/_rbac_group_details.html.haml

Summary

Maintainability
Test Coverage
- mode = ::Settings.authentication.mode
- oidc_enabled = ::Settings.authentication.oidc_enabled
- saml_enabled = ::Settings.authentication.saml_enabled
- can_lookup_groups = mode.downcase.start_with?('ldap')
- can_lookup_groups = mode.downcase == "httpd" && ! (saml_enabled || oidc_enabled) unless can_lookup_groups
= render :partial => "layouts/flash_msg"

%div{:id => "warn_div", :style => ""}
  - if @deleted_belongsto_filters.present?
    .flash_text_div
      .alert.alert-warning.alert-dismissable
        %span.pficon-warning-triangle-o
        %strong= h('These outdated filters need review as it affects their visibility. We suggest editing and saving the group to delete these outdated filters.')
        %ul
          %li
            %strong
              = _("Clusters, Datastores, Hosts, Managers & Providers")
            %ul
              - @deleted_belongsto_filters.each do |deleted_filter|
                %li
                  %strong= h(deleted_filter)
- if @edit
  - url = url_for_only_path(:action => 'rbac_group_field_changed', :id => (@edit[:group_id] || "new"))
  - combo_url = "/ops/rbac_group_field_changed/#{@edit[:group_id] || 'new'}"
  = render :partial => "ldap_auth_users"

  #group_info
  %h3
    = _("Group Information")
  .form-horizontal
    .form-group
      %label.col-md-2.control-label
        = _("Description")
      .col-md-8
        - if @edit
          = text_field_tag("description",
                           @edit[:new][:description],
                           :maxlength         => 50,
                           :class => "form-control",
                           "data-miq_observe" => {:interval => '.5',
                                                  :url      => url}.to_json)
          - if can_lookup_groups
            = check_box_tag("lookup",
                            "1",
                            false,
                            "data-miq_observe_checkbox" => {:url => url}.to_json)
            = _("(Look up %{authentication_mode_name} Groups)") % {:authentication_mode_name => auth_mode_name}
          = javascript_tag(javascript_focus('description'))
    .form-group
      %label.col-md-2.control-label
        = _("Detailed Description")
      .col-md-8
        - if @edit
          = text_field_tag("detailed_description",
                           @edit[:new][:detailed_description],
                           :maxlength         => 255,
                           :class             => "form-control",
                           "data-miq_observe" => {:interval => '.5',
                                                  :url      => url}.to_json)
    .form-group
      %label.col-md-2.control-label
        = _("Role")
      .col-md-8
        - if @edit
          - disabled_item = ["<Choose a Role>", nil]
          - selected_item = @edit[:new][:role] || disabled_item
          = select_tag('group_role',
                       options_for_select(@edit[:roles], :selected => selected_item, :disabled => disabled_item),
                       :class => "selectpicker")
          :javascript
            miqInitSelectPicker();
            miqSelectPickerEvent("group_role", "#{combo_url}")
    .form-group
      %label.col-md-2.control-label
        = _("Project/Tenant")
      .col-md-8
        - if @edit
          = select_tag('group_tenant',
              grouped_options_for_select(@edit[:projects_tenants], @edit[:new][:group_tenant]),
               :class  => "selectpicker")
          :javascript
            miqSelectPickerEvent("group_tenant", "#{combo_url}")
    - if @edit
      #group_lookup{:style => "display:none"}
        %hr
        %h3
          = _("LDAP Group Look Up")
        .form-horizontal
          .form-group#user_id_ext_auth_form_group
            %label.col-md-2.control-label
              = _("User to Look Up")
            .col-md-8
              = text_field_tag("user",
                               @edit[:new][:user],
                               :maxlength         => 255,
                               :class             => "form-control",
                               "data-miq_observe" => {:interval => '.5',
                                                      :url      => url}.to_json)
          - unless mode == "httpd"
            .form-group#user_name_form_group
              %label.col-md-2.control-label
                = _("Username")
              .col-md-8
                = text_field_tag("user_id",
                                  @edit[:new][:user_id],
                                  :maxlength         => 255,
                                  :class             => "form-control",
                                  "data-miq_observe" => {:interval => '.5',
                                                        :url      => url}.to_json)
            .form-group#user_password_form_group
              %label.col-md-2.control-label
                = _("Password")
              .col-md-8
                = password_field_tag("password",
                                     @edit[:new][:password],
                                     :maxlength         => 50,
                                     :class => "form-control",
                                     "data-miq_observe" => {:interval => '.5',
                                                            :url      => url}.to_json)
          .col-md-12{:align => "right", :valign => "bottom"}
            = link_to("Retrieve",
                      {:action => "rbac_group_user_lookup",
                       :button => "submit",
                       :id     => @edit[:group_id] || "new"},
                      :class                 => "btn btn-primary",
                      :alt                   => t = _("LDAP Group Lookup"),
                      "data-miq_sparkle_on"  => true,
                      "data-miq_sparkle_off" => true,
                      :remote                => true,
                      "data-method"          => :post,
                      :title                 => t)
- unless @edit
  = group_rbac_details_summary(@group)
  = render :partial => "rbac_tag_box"
%hr
%h3
  = @edit ? _("Assign Filters") : _("Assigned Filters (read only)")

#rbac_group_tabs
  %ul.nav.nav-tabs{'role' => 'tablist'}
    = miq_tab_header('rbac_customer_tags', @sb[:active_rbac_group_tab], {:onclick => "rbacGroupLoadTab('rbac_customer_tags')"}) do
      = _("%{current_tenant} Tags") % {:current_tenant => current_tenant.name}
    = miq_tab_header('rbac_hosts_clusters', @sb[:active_rbac_group_tab], {:onclick => "rbacGroupLoadTab('rbac_hosts_clusters')"}) do
      = _("Clusters, Datastores, Hosts, Managers & Providers")
    = miq_tab_header('rbac_vms_templates', @sb[:active_rbac_group_tab], {:onclick => "rbacGroupLoadTab('rbac_vms_templates')"}) do
      = _("VMs & Templates")

  .tab-content
    = miq_tab_content('rbac_customer_tags', @sb[:active_rbac_group_tab], {:lazy => true}) do
      = render :partial => 'ops/rbac_group/customer_tags'
    = miq_tab_content('rbac_hosts_clusters', @sb[:active_rbac_group_tab], {:lazy => true}) do
      = render :partial => 'ops/rbac_group/hosts_clusters'
    = miq_tab_content('rbac_vms_templates', @sb[:active_rbac_group_tab], {:lazy => true}) do
      = render :partial => 'ops/rbac_group/vms_templates'
:javascript
  miq_tabs_init('#rbac_group_tabs');