<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">
          {{branch || 'branch'}}
          <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 ng-href="{{link.href}}{{hash}}">{{link.name}}</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 class="modal-large">
  <div modal="addDialog.show" close="addDialog.close()" ng-options="addDialog.options">
    <div class="modal-header"><h4>Create Document</h4></div>
    <div class="modal-body">
      <div class="control-group">
        <div hawtio-tree="createDocumentTree" hideRoot="true" onSelect="onCreateDocumentSelect"
             activateNodes="createDocumentTreeActivations"></div>
      </div>

      <div class="control-group">
        <div class="well">
          {{selectedCreateDocumentTemplate.tooltip}}
        </div>
      </div>

      <form class="form-inline" ng-submit="addAndCloseDialog(newDocumentName)">
        <label class="control-label" for="fileName">Name: </label>

        <input id="fileName" type="text" ng-model="newDocumentName"
               placeholder="{{selectedCreateDocumentTemplate.exemplar}}"/>
      </form>

      <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 id="submit" class="btn btn-primary add" type="submit" ng-click="addAndCloseDialog(newDocumentName)"
             ng-disabled="!selectedCreateDocumentTemplate.exemplar || fileExists.exists"
             value="Create">
      <button class="btn btn-warning cancel" type="button" ng-click="addDialog.close()">Cancel</button>
    </div>
  </div>
</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="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="!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="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>
