11870: minor update
[arvados.git] / apps / workbench / app / views / application / _content.html.erb
index 0e3fa0b9789ed386643c7cc69b8f854952a35ba0..a22608d3c9e93f06e72314ab66d83f37964c8cb0 100644 (file)
@@ -1,51 +1,69 @@
-<% content_for :content_top do %>
-  <% if @object and not @object.is_a?(Group) and @object.class.goes_in_folders? and @object.owner_uuid == current_user.uuid %>
-    <div class="pull-right" style="width: 40%">
-      <div class="alert alert-warning alert-dismissable">
-        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
-        <strong>Hey.</strong> This <%= @object.class_for_display.downcase %> belongs to your account, but it's not in any of your folders. If you want it to be easy to find in the future, you should move it to a folder.<br />
-        <%= button_to(choose_folders_path(
-                   title: 'Move to...',
-                   editable: true,
-                   action_name: 'Move',
-                   action_href: url_for(action: :update),
-                   action_method: 'patch',
-                   action_data: {selection_param: @object.resource_param_name+'[owner_uuid]', success: 'page-refresh'}.to_json),
-                  { class: "btn btn-primary btn-sm", remote: true, method: 'get' }) do %>
-          <i class="fa fa-fw fa-folder"></i> Choose a folder...
-        <% end %>
-      </div>
-    </div>
-  <% end %>
-<% end %>
-
 <% content_for :tab_panes do %>
 
-<% comparable = controller.respond_to? :compare %>
-<% pane_list ||= %w(recent) %>
-<% panes = Hash[pane_list.map { |pane|
-     [pane, render(partial: 'show_' + pane.downcase,
-                   locals: { comparable: comparable, objects: @objects })]
-   }.compact] %>
+  <% comparable = controller.respond_to? :compare %>
 
-<ul class="nav nav-tabs">
-  <% panes.each_with_index do |(pane, content), i| %>
-    <li class="<%= 'active' if i==0 %>"><a href="#<%= pane %>" data-toggle="tab" id="<%= pane %>-tab"> <%= pane.gsub('_', ' ') %></a></li>
-  <% end %>
-</ul>
-<div class="tab-content">
-<% panes.each_with_index do |(pane, content), i| %>
-  <div id="<%= pane %>" class="tab-pane fade <%= 'in active' if i==0 %>">
-    <div id="<%= pane %>-scroll" class="<%= 'smart-scroll' if pane.match(/graph/) %>" style="margin-top:0.5em;">
-      <%= content %>
-    </div>
-  </div>
-<% end %>
-</div>
+  <ul class="nav nav-tabs" data-tab-counts-url="<%= url_for(action: :tab_counts) rescue '' %>">
+    <% pane_list.each_with_index do |pane, i| %>
+      <% pane_name = (pane.is_a?(Hash) ? pane[:name] : pane) %>
 
-<% end %>
+      <% data_toggle = "tab" %>
+      <% tab_tooltip = "" %>
+      <% link_disabled = "" %>
+
+      <% if (pane_name == "Log") and !(ArvadosBase.find(@object.owner_uuid).writable_by.include?(current_user.andand.uuid) rescue nil)
+          if controller.model_class.to_s == 'Job'
+            if @object.log and !@object.log.empty?
+              logCollection = Collection.find? @object.log
+              if !logCollection
+                data_toggle = "disabled"
+                tab_tooltip = "Log data is not available"
+                link_disabled = "disabled"
+              end
+            end
+          elsif (controller.model_class.to_s == 'PipelineInstance' and
+                 !@object.has_readable_logs?)
+            data_toggle = "disabled"
+            tab_tooltip = "Log data is not available"
+            link_disabled = "disabled"
+          end
+        end
+      %>
+
+      <li class="<%= 'active' if i==0 %> <%= link_disabled %> tab-pane-<%=pane_name%>" data-toggle="tooltip" data-placement="top" title="<%=tab_tooltip%>">
+        <a href="#<%= pane_name %>"
+           id="<%= pane_name %>-tab"
+           data-toggle="<%= data_toggle %>"
+           data-tab-history=true
+           data-tab-history-update-url=true
+           >
+          <%= pane_name.gsub('_', ' ') %> <span id="<%= pane_name %>-count"></span>
+        </a>
+      </li>
+    <% end %>
+  </ul>
+
+  <div class="tab-content">
+    <% pane_list.each_with_index do |pane, i| %>
+      <% pane_name = (pane.is_a?(Hash) ? pane[:name] : pane) %>
+      <div id="<%= pane_name %>"
+           class="tab-pane fade <%= 'in active pane-loaded' if i==0 %> arv-log-event-listener arv-refresh-on-log-event arv-log-event-subscribe-to-pipeline-job-uuids"
+           <% if controller.action_name == "index" %>
+             data-object-kind="arvados#<%= ArvadosApiClient.class_kind controller.model_class %>"
+           <% else %>
+             data-object-uuid="<%= @object.uuid %>"
+           <% end %>
+           data-pane-content-url="<%= url_for(params.merge(tab_pane: pane_name)) %>"
+           style="margin-top:0.5em;"
+           >
+        <div class="pane-content">
+          <% if i == 0 %>
+            <%= render_pane pane_name, to_string: true %>
+          <% else %>
+            <div class="spinner spinner-32px spinner-h-center"></div>
+          <% end %>
+        </div>
+      </div>
+    <% end %>
+  </div>
 
-<% content_for :js do %>
-    $(window).on('load', smart_scroll_fixup);
-    $(document).on('shown.bs.tab', 'ul.nav-tabs > li > a', smart_scroll_fixup);
 <% end %>