<!--
* 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="left-navbar" xmlns="http://www.w3.org/1999/html">
  <div class="panel panel-default">
    <div class="panel-heading"><span class="glyphicon glyphicon-cloud"></span> {{'common.clusters' | translate}}</div>
    <div class="panel-body">
      <div class="cluster-section" ng-show="cluster">
        <div id="cluster-name"  ng-switch on="editCluster.editingName">
          <h5 ng-switch-when="false"><div title={{cluster.Clusters.cluster_name}} class="clusterDisplayName">{{clusterDisplayName()}}</div>
            <i ng-show="cluster.Clusters.provisioning_state == 'INSTALLED'"
               ng-click="toggleEditName()"
               class="glyphicon glyphicon-edit pull-right edit-cluster-name renameCluster" tooltip="{{'common.renameCluster' | translate}}">
            </i>
          </h5>

          <form ng-keyup="toggleEditName($event)"
                tabindex="1"
                name="editClusterNameForm"
                class="editClusterNameForm"
                ng-switch-when="true"
                ng-submit="editCluster.name !== cluster.Clusters.cluster_name && editClusterNameForm.newClusterName.$valid && confirmClusterNameChange()">
            <div class="form-group"
                 ng-class="{'has-error': editClusterNameForm.newClusterName.$invalid && !editClusterNameForm.newClusterName.$pristine }">
              <input
                  autofocus
                  type="text"
                  name="newClusterName"
                  ng-required="true"
                  ng-pattern="/^\w*$/"
                  ng-trim="false"
                  ng-model="editCluster.name"
                  class="form-control input-sm"
                  ng-maxlength="80"
                  tooltip="{{'common.renameClusterTip' | translate}}"
                  tooltip-trigger="focus">
              <button ng-click="toggleEditName()"
                      class="btn btn-xs">
                <i class="glyphicon glyphicon-remove"></i>
              </button>
              <button
                  type="submit"
                  class="btn btn-primary btn-xs"
                  ng-class="{'disabled': editClusterNameForm.newClusterName.$invalid || editCluster.name == cluster.Clusters.cluster_name}">
                <i class="glyphicon glyphicon-ok"></i>
              </button>
            </div>
          </form>

        </div>

        <ul class="nav nav-pills nav-stacked" ng-show="cluster.Clusters.provisioning_state == 'INSTALLED' ">
          <li ng-class="{active: isActive('clusters.manageAccess') || isActive('clusters.userAccessList')}">
            <a href="#/clusters/{{cluster.Clusters.cluster_name}}/manageAccess" class="permissions">{{'common.roles' | translate}}</a>
          </li>
          <li><a href="{{fromSiteRoot('/#/dashboard')}}" class="gotodashboard">{{'common.goToDashboard' | translate}}</a></li>
        </ul>
        <span class="cluster-installation-progress-label" ng-show="cluster.Clusters.provisioning_state == 'INIT'"><a href="{{fromSiteRoot('/#/')}}">{{'common.clusterCreationInProgress' | translate}}</a></span>
      </div>


      <div ng-hide="cluster">
        <ul class="nav nav-pills nav-stacked">
          <li><p class="noclusters">{{'common.noClusters' | translate}}</p></li>
        </ul>
      </div>
      <ul class="nav nav-pills nav-stacked" >
        <li ng-class="{active: isActive('stackVersions.list')}" ng-show="cluster && totalRepos > 0">
          <a href="#/stackVersions">{{'common.versions' | translate}}</a>
        </li>
        <li ng-class="{active: isActive('remoteClusters.list')}">
          <a href="#/remoteClusters">{{'common.remoteClusters' | translate}}</a>
        </li>
      </ul>
    </div>
  </div>

  <div class="panel panel-default">
    <div class="panel-heading"><span class="glyphicon glyphicon-th"></span> {{'common.views' | translate}}</div>
    <div class="panel-body">
      <ul class="nav nav-pills nav-stacked">
        <li ng-class="{active: isActive('views.list')}"><link-to route="views.list" class="viewslist-link">{{'common.views' | translate}}</link-to></li>
        <li ng-class="{active: isActive('views.listViewUrls') || isActive('views.createViewUrl') || isActive('views.editViewUrl') }"><link-to route="views.listViewUrls" class="viewslistviewurls-link">{{'common.viewUrls' | translate}}</link-to></li>
      </ul>
    </div>
  </div>


  <div class="panel panel-default">
    <div class="panel-heading"><span class="glyphicon glyphicon-user"></span> {{'common.userGroupManagement' | translate}}</div>
    <div class="panel-body">
      <ul class="nav nav-pills nav-stacked">
        <li ng-class="{active: isActive('users.list')}"><link-to route="users.list" class="userslist-link">{{'common.users' | translate}}</link-to></li>
        <li ng-class="{active: isActive('groups.list')}"><link-to route="groups.list" class="groupslist-link">{{'common.groups' | translate}}</link-to></li>
      </ul>
    </div>
  </div>

  <div class="panel panel-default" ng-show="settings.isLoginActivitiesSupported || settings.isLDAPConfigurationSupported">
    <div class="panel-heading"><span class="glyphicon glyphicon-cog"></span> {{'common.settings' | translate}}</div>
    <div class="panel-body">
      <ul class="nav nav-pills nav-stacked">
        <li ng-class="{active: isActive('authentication.main')}" ng-show="settings.isLDAPConfigurationSupported"><link-to route="authentication.main">{{'common.authentication' | translate}}</link-to></li>
        <li ng-class="{active: isActive('loginActivities.loginMessage')}" ng-show="settings.isLoginActivitiesSupported"><link-to route="loginActivities.loginMessage">{{'common.loginActivities.loginActivities' | translate}}</link-to></li>
      </ul>
    </div>
  </div>
</div>

