5365: Do not link to job, log, output in pipeline instance if the user, mainly anonym...
[arvados.git] / apps / workbench / app / views / application / _content.html.erb
index 782a6af07996efe888489b33bf04c0145d76d9d3..1f7f2d29c50d7e4538872fcdf28d6df4c2f484dd 100644 (file)
@@ -5,10 +5,33 @@
   <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 %>">
+
+      <% data_toggle = "tab" %>
+      <% tab_tooltip = "" %>
+
+      <% if !current_user and pane_name == "Log"
+          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"
+              end
+            end
+          elsif controller.model_class.to_s == 'PipelineInstance'
+            log_uuids = [@object.uuid] + pipeline_jobs(@object).collect{|x|x[:job].andand[:uuid]}.compact
+            if stderr_log_history(log_uuids, 1).empty?
+              data_toggle = "disabled"
+              tab_tooltip = "Log data is not available"
+            end
+          end
+        end
+      %>
+
+      <li class="<%= 'active' if i==0 %>" data-toggle="tooltip" data-placement="top" title="<%=tab_tooltip%>">
         <a href="#<%= pane_name %>"
            id="<%= pane_name %>-tab"
-           data-toggle="tab"
+           data-toggle="<%= data_toggle %>"
            data-tab-history=true
            data-tab-history-update-url=true
            >