<div ng-hide="inDashboard" class="logbar" ng-controller="Wiki.NavBarController">
  <div class="wiki logbar-container">
    <ul class="nav nav-tabs">
      <li ng-show="branches.length || branch" class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown"
           title="The branch to view">
          <span class="contained c-medium">{{branch || 'branch'}}</span>
          <span class="caret"></span>
        </a>
        <ul class="dropdown-menu">
          <li ng-repeat="otherBranch in branches">
            <a ng-href="{{branchLink(otherBranch)}}{{hash}}"
               ng-hide="otherBranch === branch"
               title="Switch to the {{otherBranch}} branch"
               data-placement="bottom">
              {{otherBranch}}</a>
          </li>
        </ul>
      </li>
      <li ng-repeat="link in breadcrumbs" ng-class='{active : isActive(link.href) && !objectId}'>
        <a class="breadcrumb-link" ng-href="{{link.href}}{{hash}}">
          <span class="contained c-medium">{{link.name}}</span>
        </a>
      </li>
      <li ng-show="objectId">
        <a ng-href="{{historyLink}}{{hash}}">History</a>
      </li>
      <li ng-show="objectId" class="active">
        <a>{{objectId}}</a>
      </li>

      <li class="pull-right dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
          Actions <span class="caret"></span>
        </a>
        <ul class="dropdown-menu">
          <li ng-show="sourceLink()">
            <a ng-href="{{sourceLink()}}" title="View source code"
               data-placement="bottom">
              <i class="icon-file-alt"></i> Source</a>
          </li>
          <li>
            <a ng-href="{{historyLink}}{{hash}}" ng-hide="!historyLink" title="View the history of this file"
               data-placement="bottom">
              <i class="icon-comments-alt"></i> History</a>
          </li>
          <!--
          <li class="divider">
          </li>
          -->
          <li ng-hide="gridOptions.selectedItems.length !== 1">
            <a ng-click="openRenameDialog()"
               title="Rename the selected document"
               data-placement="bottom">
              <i class="icon-adjust"></i> Rename</a>
          </li>
          <li ng-hide="!gridOptions.selectedItems.length">
            <a ng-click="openMoveDialog()"
               title="move the selected documents to a new folder"
               data-placement="bottom">
              <i class="icon-move"></i> Move</a>
          </li>
          <!--
          <li class="divider">
          </li>
          -->
          <li ng-hide="!gridOptions.selectedItems.length">
            <a ng-click="openDeleteDialog()"
               title="Delete the selected document(s)"
               data-placement="bottom">
              <i class="icon-remove"></i> Delete</a>
          </li>
          <li class="divider" ng-show="childActions.length">
          </li>
          <li ng-repeat="childAction in childActions">
            <a ng-click="childAction.doAction()"
               title="{{childAction.title}}"
               data-placement="bottom">
              <i class="{{childAction.icon}}"></i> {{childAction.name}}</a>
          </li>
        </ul>
      </li>
      <li class="pull-right">
        <a ng-href="{{editLink()}}{{hash}}" ng-hide="!editLink()" title="Edit this page"
           data-placement="bottom">
          <i class="icon-edit"></i> Edit</a>
      </li>
      <li class="pull-right">
        <a title="Create new page" ng-click="openAddDialog()"
           data-placement="bottom">
          <i class="icon-plus"></i> Create</a>
        <!--
                  <a ng-href="{{createLink()}}{{hash}}" title="Create new page"
                     data-placement="bottom">
                    <i class="icon-plus"></i> Create</a>
        -->
      </li>
      <li class="pull-right">
        <a ng-hide="children || profile" title="Add to dashboard" ng-href="{{createDashboardLink()}}"
           data-placement="bottom">
          <i class="icon-share"></i>
        </a>
      </li>
    </ul>
  </div>
</div>

<div modal="addDialog.show" close="addDialog.close()" ng-options="addDialog.options">
  <form name="createForm"
        novalidate
        class="form-inline no-bottom-margin"
        ng-submit="addAndCloseDialog(newDocumentName)">

    <div class="modal-header"><h4>Create Document</h4></div>
    <div class="modal-body">

      <div class="row-fluid">
        <div class="span6 scrollable-section">
          <div hawtio-tree="createDocumentTree"
               hideRoot="true"
               onSelect="onCreateDocumentSelect"
               activateNodes="createDocumentTreeActivations"></div>
        </div>
        <div class="span6 scrollable-section">
          <div class="well">
            {{selectedCreateDocumentTemplate.tooltip}}
          </div>
        </div>
      </div>

      <div class="row-fluid">

        <div class="span12">
          <p></p>
          <div ng-show="fileExists.exists" class="alert">
            Please choose a different name as <b>{{fileExists.name}}</b> already exists
          </div>

            <label class="control-label" for="fileName">Name: </label>
            <input id="fileName"
                   type="text"
                   ng-pattern="selectedCreateDocumentTemplate.regex"
                   ng-model="newDocumentName"
                   placeholder="{{selectedCreateDocumentTemplate.exemplar}}">

        </div>

      </div>

    </div>
    <div class="modal-footer">
      <input class="btn btn-primary add"
             type="submit"
             ng-click="addAndCloseDialog(newDocumentName)"
             ng-disabled="!selectedCreateDocumentTemplate.exemplar || fileExists.exists || !createForm.$valid"
             value="Create">
      <button class="btn btn-warning cancel" type="button" ng-click="addDialog.close()">Cancel</button>
    </div>
  </form>

</div>

<div hawtio-confirm-dialog="deleteDialog"
     ok-button-text="Delete"
     on-ok="deleteAndCloseDialog()">
  <div class="dialog-body">
    <p>You are about to delete
      <ng-pluralize count="gridOptions.selectedItems.length"
                    when="{'1': 'this document!', 'other': 'these {} documents!'}">
      </ng-pluralize>
    </p>
    <div ng-bind-html-unsafe="selectedFileHtml"></div>
  </div>
</div>

<div modal="moveDialog.show" close="moveDialog.close()" ng-options="moveDialog.options">
  <form class="form-horizontal" ng-submit="moveAndCloseDialog()">
    <div class="modal-header"><h4>Move Document</h4></div>
    <div class="modal-body">
      <div class="control-group">
        <label class="control-label" for="moveFolder">Folder</label>

        <div class="controls">
          <input type="text" id="moveFolder" ng-model="move.moveFolder"
                 typeahead="title for title in folderNames($viewValue) | filter:$viewValue" typeahead-editable='true'>
        </div>
      </div>
    </div>
    <div class="modal-footer">
      <input class="btn btn-primary" type="submit"
             ng-disabled="!move.moveFolder"
             value="Move">
      <button class="btn btn-warning cancel" type="button" ng-click="moveDialog.close()">Cancel</button>
    </div>
  </form>
</div>

<div modal="renameDialog.show" close="renameDialog.close()" ng-options="renameDialog.options">
  <form class="form-horizontal" ng-submit="renameAndCloseDialog()">
    <div class="modal-header"><h4>Rename Document</h4></div>
    <div class="modal-body">
      <div class="control-group">
        <label class="control-label" for="renameFileName">Name</label>

        <div class="controls">
          <input type="text" id="renameFileName" ng-model="rename.newFileName">
        </div>
      </div>

      <div class="control-group">
        <div ng-show="fileExists.exists" class="alert">
          Please choose a different name as <b>{{fileExists.name}}</b> already exists
        </div>
      </div>
    </div>
    <div class="modal-footer">
      <input class="btn btn-primary" type="submit"
             ng-disabled="!fileName || fileExists.exists"
             value="Rename">
      <button class="btn btn-warning cancel" type="button" ng-click="renameDialog.close()">Cancel</button>
    </div>
  </form>
</div>
