3654: disable search icon collection show page rather than hide it when it is not...
[arvados.git] / apps / workbench / app / views / collections / _show_files.html.erb
1 <div class="selection-action-container" style="padding-left: 1em">
2   <% if !defined? no_checkboxes or !no_checkboxes %>
3   <div class="row">
4     <div class="pull-left">
5       <div class="btn-group btn-group-sm">
6         <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Selection... <span class="caret"></span></button>
7         <ul class="dropdown-menu" role="menu">
8           <li><%= link_to "Create new collection with selected files", '#',
9                   'data-href' => combine_selected_path,
10                   'data-selection-param-name' => 'selection[]',
11                   'data-selection-action' => 'combine-collections',
12                   'method' => 'post',
13                   'data-toggle' => 'dropdown'
14             %></li>
15         </ul>
16       </div>
17     </div>
18   </div>
19   <p/>
20   <% end %>
21
22 <% file_tree = @object.andand.files_tree %>
23 <% if file_tree.nil? or file_tree.empty? %>
24   <p>This collection is empty.</p>
25 <% else %>
26   <ul id="collection_files" class="collection_files">
27   <% dirstack = [file_tree.first.first] %>
28   <% file_tree.take(10000).each_with_index do |(dirname, filename, size), index| %>
29     <% file_path = CollectionsHelper::file_path([dirname, filename]) %>
30     <% while dirstack.any? and (dirstack.last != dirname) %>
31       <% dirstack.pop %></ul></li>
32     <% end %>
33     <li>
34     <% if size.nil?  # This is a subdirectory. %>
35       <% dirstack.push(File.join(dirname, filename)) %>
36       <div class="collection_files_row">
37        <div class="collection_files_name"><i class="fa fa-fw fa-folder-open"></i> <%= filename %></div>
38       </div>
39       <ul class="collection_files">
40     <% else %>
41       <% link_params = {controller: 'collections', action: 'show_file',
42                         uuid: @object.portable_data_hash, file: file_path, size: size} %>
43        <div class="collection_files_row">
44         <div class="collection_files_buttons pull-right">
45           <%= raw(human_readable_bytes_html(size)) %>
46           <% disable_search = (Rails.configuration.filename_suffixes_with_view_icon.include? file_path.split('.')[-1]) ? false : true %>
47           <%= link_to(raw('<i class="fa fa-search"></i>'),
48                       link_params.merge(disposition: 'inline'),
49                       {title: "View #{file_path}", class: "btn btn-info btn-sm", disabled: disable_search}) %>
50           <%= link_to(raw('<i class="fa fa-download"></i>'),
51                       link_params.merge(disposition: 'attachment'),
52                       {title: "Download #{file_path}", class: "btn btn-info btn-sm"}) %>
53         </div>
54
55         <div class="collection_files_name">
56           <% if !defined? no_checkboxes or !no_checkboxes %>
57           <%= check_box_tag 'uuids[]', "#{@object.uuid}/#{file_path}", false, {
58                 :class => 'persistent-selection',
59                 :friendly_type => "File",
60                 :friendly_name => "#{@object.uuid}/#{file_path}",
61                 :href => url_for(controller: 'collections', action: 'show_file',
62                                  uuid: @object.portable_data_hash, file: file_path),
63                 :title => "Include #{file_path} in your selections",
64               } %>
65           <span>&nbsp;</span>
66           <% end %>
67       <% if CollectionsHelper::is_image(filename) %>
68           <i class="fa fa-fw fa-bar-chart-o"></i> <%= filename %></div>
69        </div>
70         <div class="collection_files_inline">
71           <%= link_to(image_tag("#{url_for @object}/#{file_path}"),
72                       link_params.merge(disposition: 'inline'),
73                       {title: file_path}) %>
74         </div>
75       <% else %>
76           <i class="fa fa-fw fa-file"></i> <%= filename %></div>
77        </div>
78       <% end %>
79       </li>
80     <% end  # if file or directory %>
81   <% end  # file_tree.each %>
82   <%= raw(dirstack.map { |_| "</ul>" }.join("</li>")) %>
83 <% end  # if file_tree %>
84
85 <% content_for :footer_html do %>
86 <div id="collection-sharing-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
87 <% end %>
88
89 </div>