<div>
  <div class="file-list-toolbar">
    <ul class="nav nav-tabs" ng-controller="Wiki.NavBarController">
      <li class="caption">
        {{$parent.caption}}
      </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>
            <a ng-click="openRenameDialog()" ng-disabled="gridOptions.selectedItems.length !== 1"
               title="Rename the selected document"
               data-placement="bottom">
              <i class="icon-adjust"></i> Rename</a>
          </li>
          <li>
            <a ng-click="openMoveDialog()" ng-disabled="!gridOptions.selectedItems.length"
               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>
            <a ng-click="openDeleteDialog()" ng-disabled="!gridOptions.selectedItems.length"
               title="Delete the selected document(s)"
               data-placement="bottom">
              <i class="icon-remove"></i> Delete</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>
      </li>
    </ul>
  </div>

  <div>
    <div ng-hide="!children">
      <div class="wikiGridStyle" ng-grid="gridOptions"></div>
    </div>

    <!--
    <div ng-hide="!html">
      <div ng-bind-html-unsafe="html"></div>
    </div>
    -->
    <!--
    <div ng-include="sourceView" class="editor-autoresize"></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()">
          <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()"
               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="fileName">
          </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>
</div>
