Merge branch 'master' into 4232-slow-pipes-n-jobs
[arvados.git] / apps / workbench / app / views / application / _title_and_buttons.html.erb
1 <% object_class = @object.class_for_display.downcase %>
2 <% content_for :page_title do %>
3   <%= (@object.respond_to?(:properties) and !@object.properties.nil? ? @object.properties[:page_title] : nil) ||
4       @name_link.andand.name ||
5       @object.friendly_link_name %>
6 <% end %>
7
8 <% content_for :content_top do %>
9   <% if !['Group','User', 'Collection'].include? @object.class.to_s # projects and collections handle it themselves %>
10     <%= render partial: 'name_and_description' %>
11   <% end %>
12 <% end %>
13
14 <% if @object.class.goes_in_projects? && @object.uuid != current_user.andand.uuid # Not the "Home" project %>
15   <% content_for :tab_line_buttons do %>
16     <% if current_user.andand.is_active && @object.class.copies_to_projects? %>
17       <%= link_to(
18           choose_projects_path(
19            title: "Copy this #{object_class} to:",
20            action_name: 'Copy',
21            action_href: actions_path,
22            action_method: 'post',
23            action_data: {
24              copy_selections_into_project: true,
25              selection: @name_link.andand.uuid || @object.uuid,
26              selection_param: 'uuid',
27              success: 'redirect-to-created-object'
28            }.to_json),
29           { class: "btn btn-sm btn-primary", remote: true, method: 'get',
30             title: "Make a copy of this #{object_class}" }) do %>
31         <i class="fa fa-fw fa-copy"></i> Copy to project...
32       <% end %>
33     <% end %>
34     <% if (ArvadosBase.find(@object.owner_uuid).writable_by.include?(current_user.andand.uuid) rescue nil) %>
35       <%= link_to(
36           choose_projects_path(
37            title: "Move this #{object_class} to:",
38            action_name: 'Move',
39            action_href: actions_path,
40            action_method: 'post',
41            action_data: {
42              move_selections_into_project: true,
43              selection: @name_link.andand.uuid || @object.uuid,
44              selection_param: 'uuid',
45              success: 'redirect-to-created-object'
46            }.to_json),
47           { class: "btn btn-sm btn-primary force-cache-reload", remote: true, method: 'get',
48             title: "Move this #{object_class} to a different project"}) do %>
49         <i class="fa fa-fw fa-truck"></i> Move <%=object_class%>...
50       <% end %>
51     <% end %>
52   <% end %>
53 <% end %>
54
55 <%
56   # Display any flash messages in an alert. If there is any entry with "error" key, alert-danger is used.
57   flash_msg = ''
58   flash_msg_is_error = false
59   flash.each do |msg|
60     flash_msg_is_error ||= (msg[0]=='error')
61     flash_msg += ('<p class="contain-align-left">' + msg[1] + '</p>')
62   end
63   if flash_msg != ''
64 %>
65 <div class="flash-message alert <%= flash_msg_is_error ? 'alert-danger' : 'alert-warning' %>"><%=flash_msg.html_safe%></div>
66 <% end %>