- user_can_modify_package = User.possibly_nobody.can_modify?(package) && package.scmsync.blank?
- nobody = !User.session

.card-body
  - if files.present?
    %table.table.table-bordered.table-hover.table-sm.dt-responsive.w-100#files-table
      %thead
        %tr
          %th Filename
          %th Size
          %th Changed
          - unless nobody
            %th Actions
      %tbody
        - file_locals = { package: package, project: project, expand: expand, is_current_rev: is_current_rev,
        can_modify: user_can_modify_package, nobody: nobody, srcmd5: srcmd5 }
        = render partial: 'file', collection: files,
        cached: proc { |file| [file['name'], file['mtime'], file['md5'], file_locals].hash }, locals: file_locals
  - else
    %i This package has no files yet
  - if user_can_modify_package
    .nav
      = form_tag(project_package_files_path(project, package), multipart: true, class: 'nav-item') do
        = file_field_tag 'files[]', class: 'd-none', id: 'filechooser', multiple: true
        %label.nav-link{ for: 'filechooser' }
          %i.fas.fa-hard-drive.text-primary
          Add local files
      .nav-item
        = link_to(new_project_package_file_path(project, package), class: 'nav-link') do
          %i.fas.fa-plus-circle.text-primary
          Add an empty file or service
    = render DeleteConfirmationDialogComponent.new(modal_id: 'delete-file-modal',
                                                   method: :delete,
                                                   options: { modal_title: 'Do you really want to remove this file?' })

- unless files.blank? || spider_bot
  - if revision.present?
    - if is_current_rev
      %h5.card-header.border-top Latest Revision
    - else
      %h5.card-header.border-top
        Revision #{revision} (latest revision is #{current_rev})
    .card-body
      = render partial: 'commit_item', locals: { project: project, package: package, revision: revision, commit: package.commit(revision) }
  - elsif srcmd5
    %h5
      Source MD5 is #{srcmd5} (latest revision is #{current_rev})

- content_for :ready_function do
  initializeDataTable('#files-table');
