{{!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
}}

<div class="dropdown bulk-menu">
  <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">{{t common.actions}} <span class="caret"></span></a>
  <ul class="dropdown-menu">
    {{#isAccessible ADMIN}}
      <li><a href="#" {{action addHost}}><i class="icon-plus icon-white"></i> {{t hosts.host.add}}</a></li>
      <li class="divider"></li>
    {{/isAccessible}}
    <li class="dropdown-submenu">
      <a {{bindAttr class="view.parentView.showSelectedFilter::disabled"}} tabindex="-1" href="javascript:void(null);">{{view.menuItems.s.label}}
        ({{view.parentView.selectedHosts.length}})</a>
        <ul {{bindAttr class="view.parentView.showSelectedFilter::hidden :dropdown-menu"}}>
          {{#view view.hostItemView}}
              <a href="javascript:void(null);">{{view.label}}</a>
              <ul class="dropdown-menu">
                {{#each operation in view.operationsInfo}}
                  {{#if operation.label.length}}
                    {{#view view.operationView contentBinding="operation.operationData" selection="s"}}
                        <a href="javascript:void(null);">{{operation.label}}</a>
                    {{/view}}
                  {{/if}}
                {{/each}}
              </ul>
          {{/view}}
          {{#each component in view.components}}
            {{#view view.slaveItemView contentBinding="component"}}
                <a href="javascript:void(null);">{{component.componentNameFormatted}}</a>
                <ul class="dropdown-menu">
                  {{#each operation in view.operationsInfo}}
                    {{#if operation.decommission}}
                      {{#view view.advancedOperationView contentBinding="operation.operationData" selection="s"}}
                          <a href="javascript:void(null);">{{operation.label}}</a>
                      {{/view}}
                    {{else}}
                      {{#view view.commonOperationView contentBinding="operation.operationData" selection="s"}}
                          <a href="javascript:void(null);">{{operation.label}}</a>
                      {{/view}}
                    {{/if}}
                  {{/each}}
                </ul>
            {{/view}}
          {{/each}}
        </ul>
    </li>
    <li class="dropdown-submenu">
      <a {{bindAttr class="view.parentView.hasFilteredItems::disabled"}} tabindex="-1" href="javascript:void(null);">{{view.menuItems.f.label}}
        ({{view.parentView.filteredCount}})</a>
        <ul {{bindAttr class="view.parentView.hasFilteredItems::hidden :dropdown-menu"}}>
          {{#view view.hostItemView}}
            <a href="javascript:void(null);">{{view.label}}</a>
            <ul class="dropdown-menu">
              {{#each operation in view.operationsInfo}}
                {{#if operation.label.length}}
                  {{#view view.operationView contentBinding="operation.operationData" selection="f"}}
                    <a href="javascript:void(null);">{{operation.label}}</a>
                  {{/view}}
                {{/if}}
              {{/each}}
            </ul>
          {{/view}}
          {{#each component in view.components}}
              {{#view view.slaveItemView contentBinding="component"}}
                <a href="javascript:void(null);">{{component.componentNameFormatted}}</a>
                  <ul class="dropdown-menu">
                    {{#each operation in view.operationsInfo}}
                      {{#if operation.decommission}}
                        {{#view view.advancedOperationView contentBinding="operation.operationData" selection="f"}}
                        <a href="javascript:void(null);">{{operation.label}}</a>
                        {{/view}}
                      {{else}}
                        {{#view view.commonOperationView contentBinding="operation.operationData" selection="f"}}
                        <a href="javascript:void(null);">{{operation.label}}</a>
                        {{/view}}
                      {{/if}}
                    {{/each}}
                  </ul>
              {{/view}}
          {{/each}}
        </ul>
    </li>
    <li class="dropdown-submenu">
      <a tabindex="-1" href="javascript:void(null);">{{view.menuItems.a.label}}
        ({{view.parentView.totalCount}})</a>
        <ul class="dropdown-menu">
          {{#view view.hostItemView}}
              <a href="javascript:void(null);">{{view.label}}</a>
              <ul class="dropdown-menu">
                {{#each operation in view.operationsInfo}}
                  {{#if operation.label.length}}
                    {{#view view.operationView contentBinding="operation.operationData" selection="a"}}
                        <a href="javascript:void(null);">{{operation.label}}</a>
                    {{/view}}
                  {{/if}}
                {{/each}}
              </ul>
          {{/view}}
          {{#each component in view.components}}
            {{#view view.slaveItemView contentBinding="component"}}
                <a href="javascript:void(null);">{{component.componentNameFormatted}}</a>
                <ul class="dropdown-menu">
                  {{#each operation in view.operationsInfo}}
                    {{#if operation.decommission}}
                      {{#view view.advancedOperationView contentBinding="operation.operationData" selection="a"}}
                          <a href="javascript:void(null);">{{operation.label}}</a>
                      {{/view}}
                    {{else}}
                      {{#view view.commonOperationView contentBinding="operation.operationData" selection="a"}}
                          <a href="javascript:void(null);">{{operation.label}}</a>
                      {{/view}}
                    {{/if}}
                  {{/each}}
                </ul>
            {{/view}}
          {{/each}}
        </ul>
    </li>
  </ul>
</div>
