<div
  class="uk-flex uk-overflow-hidden uk-height-max-1 uk-height-1-1"
  data-test-document-view
  data-test-sort-key={{this.sort}}
  data-test-sort-direction={{this.sortDirection}}
>
  <div
    class="uk-width-1 uk-flex uk-flex-column uk-overflow-hidden uk-height-max-1"
  >
    <div class="uk-flex uk-flex-middle uk-padding-small">
      <DocumentUploadButton
        @categoryId={{@category}}
        @afterUpload={{this.refreshDocumentList}}
        data-test-upload
      />

      <TagFilter
        @category={{@category}}
        @documents={{this.documentsInCategory}}
        @selectedTags={{@filters.tags}}
        @selectedMarks={{@filters.marks}}
        class="uk-margin-left"
      />

      <DocumentViewToggle
        @viewList={{@listView}}
        data-test-toggle-side-panel
        {{on "click" this.toggleView}}
      />
      <SidePanelToggle />
    </div>

    {{! Drag'n'Drop Area }}
    <div
      class="uk-padding-small uk-height-1-1 uk-overflow-auto
        {{if this.isDragOver 'document-grid--dragover'}}
        {{unless this.canDrop 'document-grid--disallowed'}}
        "
      {{on "dragenter" this.onDragEnter}}
      {{on "dragleave" this.onDragLeave}}
      {{on "dragover" this.onDragOver}}
      {{on "drop" this.onDrop.perform}}
      ...attributes
    >
      <div class="document-view">
        {{! List & Grid View }}
        {{#if @listView}}
          <DocumentList
            @columns={{this.config.documentListColumns}}
            @loading={{this.fetchedDocuments.isRunning}}
            @fetchedDocuments={{this.documentsInCategory}}
            @setSort={{this.setSort}}
            @selectedDocuments={{this.documents.selectedDocuments}}
            @onClickDocument={{this.handleDocumentSelection}}
            @onDoubleClickDocument={{this.openDocument.perform}}
            @onDragStart={{this.dragDocument}}
            @sort={{@sort}}
          />
        {{else}}
          <DocumentGrid
            @loading={{this.fetchedDocuments.isRunning}}
            @fetchedDocuments={{this.documentsInCategory}}
            @selectedDocuments={{this.documents.selectedDocuments}}
            @onClickDocument={{this.handleDocumentSelection}}
            @onDoubleClickDocument={{this.openDocument.perform}}
            @onDragStart={{this.dragDocument}}
          />
        {{/if}}
      </div>
      {{#if this.isDragOver}}
        <button
          class="uk-width-1 uk-padding-remove uk-position-bottom uk-button uk-button-primary"
          type="button"
        >
          {{#if this.onDrop.isRunning}}
            <UkSpinner />
          {{else if this.canDrop}}
            {{t "alexandria.document-grid.drop-to-upload"}}
          {{else}}
            {{t "alexandria.document-grid.drop-not-allowed"}}
          {{/if}}
        </button>
      {{/if}}
    </div>
  </div>
  <DocumentsSidePanel
    @selectedDocuments={{this.documents.selectedDocuments}}
    @refreshDocumentList={{this.refreshDocumentList}}
  />
</div>

<div
  class="drag-info uk-background-default uk-box-shadow-medium uk-border-rounded uk-width-auto"
  {{did-insert this.registerDragInfo}}
>
  {{t "alexandria.move-document" count=this.documents.selectedDocuments.length}}
</div>