Merge branch 'master' into 4232-slow-pipes-n-jobs
[arvados.git] / apps / workbench / app / views / application / _title_and_buttons.html.erb
index e1ec160ec14bf96aa0701b43898d4d3132cf6d00..31ff2e6e21a6e659ad8f75d14d2630e020b4d62b 100644 (file)
@@ -1,3 +1,4 @@
+<% object_class = @object.class_for_display.downcase %>
 <% content_for :page_title do %>
   <%= (@object.respond_to?(:properties) and !@object.properties.nil? ? @object.properties[:page_title] : nil) ||
       @name_link.andand.name ||
   <% end %>
 <% end %>
 
-<% if @object.class.goes_in_projects? && @object.uuid != current_user.uuid # Not the "Home" project %>
+<% if @object.class.goes_in_projects? && @object.uuid != current_user.andand.uuid # Not the "Home" project %>
   <% content_for :tab_line_buttons do %>
-    <% if @object.class.copies_to_projects? %>
+    <% if current_user.andand.is_active && @object.class.copies_to_projects? %>
       <%= link_to(
           choose_projects_path(
-           title: 'Copy to project...',
+           title: "Copy this #{object_class} to:",
            action_name: 'Copy',
            action_href: actions_path,
            action_method: 'post',
              selection_param: 'uuid',
              success: 'redirect-to-created-object'
            }.to_json),
-          { class: "btn btn-sm btn-primary", remote: true, method: 'get' }) do %>
+          { class: "btn btn-sm btn-primary", remote: true, method: 'get',
+            title: "Make a copy of this #{object_class}" }) do %>
         <i class="fa fa-fw fa-copy"></i> Copy to project...
       <% end %>
     <% end %>
-    <% if @object.owner_uuid == current_user.uuid or (Group.find(@object.owner_uuid).writable_by.include?(current_user.uuid) rescue nil) %>
+    <% if (ArvadosBase.find(@object.owner_uuid).writable_by.include?(current_user.andand.uuid) rescue nil) %>
       <%= link_to(
           choose_projects_path(
-           title: 'Move to project...',
+           title: "Move this #{object_class} to:",
            action_name: 'Move',
            action_href: actions_path,
            action_method: 'post',
              selection_param: 'uuid',
              success: 'redirect-to-created-object'
            }.to_json),
-          { class: "btn btn-sm btn-primary", remote: true, method: 'get' }) do %>
-        <i class="fa fa-fw fa-truck"></i> Move to project...
+          { class: "btn btn-sm btn-primary force-cache-reload", remote: true, method: 'get',
+            title: "Move this #{object_class} to a different project"}) do %>
+        <i class="fa fa-fw fa-truck"></i> Move <%=object_class%>...
       <% end %>
     <% end %>
   <% end %>
 <% end %>
 
+<%
+  # Display any flash messages in an alert. If there is any entry with "error" key, alert-danger is used.
+  flash_msg = ''
+  flash_msg_is_error = false
+  flash.each do |msg|
+    flash_msg_is_error ||= (msg[0]=='error')
+    flash_msg += ('<p class="contain-align-left">' + msg[1] + '</p>')
+  end
+  if flash_msg != ''
+%>
+<div class="flash-message alert <%= flash_msg_is_error ? 'alert-danger' : 'alert-warning' %>"><%=flash_msg.html_safe%></div>
+<% end %>