Merge branch '8784-dir-listings'
[arvados.git] / apps / workbench / app / views / application / _content.html.erb
index e37225ce80c6082fe13e40367282f710795508af..7f3542083e91180f9c943e3a93c16bf416c2930b 100644 (file)
@@ -1,39 +1,70 @@
+<%# Copyright (C) The Arvados Authors. All rights reserved.
+
+SPDX-License-Identifier: AGPL-3.0 %>
+
 <% content_for :tab_panes do %>
 
   <% comparable = controller.respond_to? :compare %>
 
-<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) %>
-    <li class="<%= 'active' if i==0 %>">
-      <a href="#<%= pane_name %>" data-toggle="tab"
-         class="pane-anchor"
-         id="<%= pane_name %>-tab"
-         data-pane-content-url="<%= url_for(params.merge(tab_pane: pane)) %>">
-        <%= 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| %>
+  <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) %>
-  <div id="<%= pane_name %>"
-       class="tab-pane fade <%= 'in active loaded' if i==0 %> arv-log-event-listener"
-<% if controller.action_name == "index" %>
-       data-object-kind="arvados#<%= ArvadosApiClient.class_kind controller.model_class %>"
-<% else %>
-       data-object-uuid="<%= @object.uuid %>"
-<% end %>
-  >
-        <div id="<%= pane_name %>-scroll" 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>
+
+      <% 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 %>