<% if can_manage_asset?(asset) %>
  <div class="dropdown asset-context-menu">
    <button class="btn btn-light dropdown-toggle icon-btn" type="button" id="dropdownAssetContextMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
      <i class="fas fa-ellipsis-h"></i>
    </button>
    <ul class="dropdown-menu dropdown-menu-right"
        aria-labelledby="dropdownAssetContextMenu"
        data-asset-id="<%= asset.id %>"
        data-toggle-view-url="<%= toggle_view_mode_path(asset) %>">
      <% if editable %>
        <% if wopi_enabled? && wopi_file?(asset) %>
          <li>
            <% edit_supported, title = wopi_file_edit_button_status(asset) %>
            <%= render partial: 'assets/wopi/file_wopi_controls.html.erb',
              locals: {
                asset: asset,
                edit_supported: edit_supported,
                title: title
              } %>
          </li>
          <li role="separator" class="divider"></li>
        <% elsif asset.file.metadata[:asset_type] == 'marvinjs' %>
          <li>
            <a class="btn btn-light marvinjs-edit-button"
              data-sketch-id="<%= asset.id %>"
              data-update-url="<%= marvin_js_asset_path(asset) %>"
              data-sketch-start-edit-url="<%= start_editing_marvin_js_asset_path(asset) %>"
              data-sketch-name="<%= asset.file.metadata[:name] %>"
              data-sketch-description="<%= asset.file.metadata[:description] %>"
            >
              <%= image_tag 'icon_small/marvinjs.svg' %>
              <%= t('assets.file_preview.edit_in_marvinjs') %>
            </a>
          </li>
          <li role="separator" class="divider"></li>
        <% elsif asset.bio_eddie? && BioEddieService.enabled?(current_user) %>
          <li>
            <a class="btn btn-light bio-eddie-edit-button"
              data-molecule-id="<%= asset.id %>"
              data-update-url="<%= bio_eddie_asset_path(asset) %>"
              data-edit-url="<%= start_editing_bio_eddie_asset_path(asset) %>"
              data-molecule-name="<%= asset.file.metadata[:name] || asset.file_name %>"
              data-molecule-description="<%= asset.file.metadata[:description] || asset.file.download %>"
            >
              <%= image_tag 'icon_small/bio_eddie.png' %>
              <%= t('assets.file_preview.edit_in_bio_eddie') %>
            </a>
          </li>
          <li role="separator" class="divider"></li>
        <% elsif asset.editable_image? %>
          <li>
            <a class="btn btn-light image-edit-button"
              data-image-id="<%= asset.id %>"
              data-image-name="<%= asset.file_name %>"
              data-image-url="<%= asset_file_url_path(asset) %>"
              data-image-quality="<%= asset.file_image_quality || 80 %>"
              data-image-mime-type="<%= asset.file.content_type %>"
              data-image-start-edit-url="<%= start_edit_image_path(asset) %>"
            >
              <span class="fas fa-pencil-alt"></span>
              <%= t('assets.file_preview.edit_in_scinote') %>
            </a>
          </li>
          <li role="separator" class="divider"></li>
        <% end %>
      <% end %>
      <li class="divider-label"><%= t("assets.context_menu.set_view_size") %></li>
      <% ['inline', 'thumbnail', 'list'].each do |view_mode| %>
        <li>
          <a class="change-preview-type <%= 'selected' if view_mode == asset.view_mode %>"  data-preview-type="<%= view_mode %>">
            <%= t("assets.context_menu.#{view_mode}_html") %>
          </a>
        </li>
      <% end %>
      <% if deletable %>
        <li role="separator" class="divider"></li>
        <li>
          <a class="delete-asset" href="<%= asset_destroy_path(asset) %>" data-file-name="<%= asset.render_file_name %>">
            <i class="fas fa-trash"></i>
            <%= t("assets.context_menu.delete") %>
          </a>
        </li>
      <% end %>
    </ul>
  </div>
<% end %>
