<div
  class="doc-table-container"
  ng-if="hits.length"
  ng-class="{ loading: searchSource.activeFetchCount > 0 }"
>
  <div ng-if="!infiniteScroll">
    <div class="kuiBar docTableBar">
      <div class="kuiBarSection">
        <div
          ng-if="shouldShowLimitedResultsWarning()"
          class="kuiToolBarText kuiSubduedText"
        >
          {{ limitedResultsWarning }}
        </div>
        <!-- Pagination -->
        <tool-bar-pager-text
          start-item="pager.startItem"
          end-item="pager.endItem"
          total-items="totalHitCount"
        ></tool-bar-pager-text>
        <tool-bar-pager-buttons
          has-previous-page="pager.hasPreviousPage"
          has-next-page="pager.hasNextPage"
          on-page-next="onPageNext"
          on-page-previous="onPagePrevious"
        ></tool-bar-pager-buttons>
      </div>
    </div>
    <table class="kbn-table table" ng-if="indexPattern">
      <thead
        kbn-table-header
        columns="columns"
        index-pattern="indexPattern"
        sort-order="sorting"
        on-change-sort-order="onChangeSortOrder"
        on-move-column="onMoveColumn"
        on-remove-column="onRemoveColumn"
      ></thead>
      <tbody>
        <tr ng-repeat="row in pageOfItems|limitTo:limit track by row._index+row._type+row._id+row._score+row._version"
          kbn-table-row="row"
          columns="columns"
          sorting="sorting"
          index-pattern="indexPattern"
          filter="filter"
          filters="filters"
          class="discover-table-row"
          on-add-column="onAddColumn"
          on-change-sort-order="onChangeSortOrder"
          on-remove-column="onRemoveColumn"
        ></tr>
      </tbody>
    </table>
    <!-- ToolBarFooter -->
    <div class="kuiBar docTableBar">
      <div class="kuiBarSection">
        <div
          ng-if="shouldShowLimitedResultsWarning()"
          class="kuiToolBarText kuiSubduedText"
        >
          {{ limitedResultsWarning }}
        </div>
        <!-- Pagination -->
        <tool-bar-pager-text
          start-item="pager.startItem"
          end-item="pager.endItem"
          total-items="totalHitCount"
        ></tool-bar-pager-text>
        <tool-bar-pager-buttons
          has-previous-page="pager.hasPreviousPage"
          has-next-page="pager.hasNextPage"
          on-page-next="onPageNext"
          on-page-previous="onPagePrevious"
        ></tool-bar-pager-buttons>
      </div>
    </div>
  </div>

  <table ng-if="infiniteScroll" class="kbn-table table" ng-if="indexPattern" data-test-subj="docTable">
    <thead
      kbn-table-header
      columns="columns"
      index-pattern="indexPattern"
      sort-order="sorting"
      on-change-sort-order="onChangeSortOrder"
      on-move-column="onMoveColumn"
      on-remove-column="onRemoveColumn"
    ></thead>
    <tbody>
      <tr ng-repeat="row in hits|limitTo:limit track by row._index+row._type+row._id+row._score+row._version"
        kbn-table-row="row"
        columns="columns"
        sorting="sorting"
        index-pattern="indexPattern"
        filter="filter"
        filters="filters"
        class="discover-table-row"
        ng-class="{'discover-table-row--highlight': row['$$_isAnchor']}"
        data-test-subj="docTableRow{{ row['$$_isAnchor'] ? ' docTableAnchorRow' : ''}}"
        on-add-column="onAddColumn"
        on-change-sort-order="onChangeSortOrder"
        on-remove-column="onRemoveColumn"
      ></tr>
    </tbody>
  </table>
  <kbn-infinite-scroll ng-if="infiniteScroll" more="addRows"></kbn-infinite-scroll>
</div>

<div ng-if="hits != null && !hits.length" class="table-vis-error">
  <h2><i class="fa fa-meh-o"></i></h2>
  <h4>No results found</h4>
</div>
