normalized = arv_normalize combined
newc = Collection.new({:manifest_text => normalized})
newc.name = newc.name || "Collection created at #{Time.now.localtime}"
+
+ # set owner_uuid to current project, provided it is writable
+ current_project_writable = false
+ action_data = JSON.parse(params['action_data']) if params['action_data']
+ if action_data && action_data['current_project_uuid']
+ current_project = Group.find(action_data['current_project_uuid']) rescue nil
+ if (current_project && current_project.writable_by.andand.include?(current_user.uuid))
+ newc.owner_uuid = action_data['current_project_uuid']
+ current_project_writable = true
+ end
+ end
+
newc.save!
chash.each do |k,v|
l.save!
end
- action_data = JSON.parse(params['action_data']) if params['action_data']
- if action_data && action_data['selection_param'].eql?('project')
- redirect_to :back
- else
- redirect_to url_for(controller: 'collections', action: :show, id: newc.uuid)
- end
+ msg = current_project_writable ?
+ "Created new collection in the project #{current_project.name}." :
+ "Created new collection in your Home project."
+
+ redirect_to newc, flash: {'message' => msg}
end
def report_issue_popup
+<% 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 ||
<% if @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 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) %>
<%= 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", 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 %>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Selection... <span class="caret"></span></button>
<ul class="dropdown-menu" role="menu">
<li><%= link_to "Create new collection with selected files", '#',
- 'data-href' => combine_selected_path,
+ 'data-href' => combine_selected_path(
+ action_data: {current_project_uuid: @object.owner_uuid}.to_json
+ ),
'data-selection-param-name' => 'selection[]',
'data-selection-action' => 'combine-collections',
'method' => 'post',
<% [:script_parameters, :runtime_constraints].each do |d| %>
<%= hidden_field :job, d, :value => JSON.dump(@object[d]) %>
<% end %>
- <%= button_tag "Re-run same version", {class: 'btn btn-sm btn-primary', id: "re-run-same-job-button"} %>
+ <%= button_tag ({class: 'btn btn-sm btn-primary', id: "re-run-same-job-button",
+ title: 'Re-run job using the same script version as this run'}) do %>
+ <i class="fa fa-fw fa-gear"></i> Re-run same version
+ <% end %>
<% end %>
<% if @object.respond_to? :supplied_script_version and !@object.supplied_script_version.nil? and !@object.supplied_script_version.empty? and @object.script_version != @object.supplied_script_version%>
<%= form_tag '/jobs', style: "display:inline" do |f| %>
<% [:script_parameters, :runtime_constraints].each do |d| %>
<%= hidden_field :job, d, :value => JSON.dump(@object[d]) %>
<% end %>
- <%= button_tag "Re-run latest version", {class: 'btn btn-sm btn-primary', id: "re-run-latest-job-button"} %>
+ <%= button_tag ({class: 'btn btn-sm btn-primary', id: "re-run-latest-job-button",
+ title: 'Re-run job using the latest script version'}) do%>
+ <i class="fa fa-fw fa-gear"></i> Re-run latest version
+ <% end %>
<% end %>
<% end %>
<% end %>
<%= link_to(copy_pipeline_instance_path('id' => @object.uuid, 'script' => "use_latest", "components" => "use_latest", "pipeline_instance[state]" => "RunningOnServer"),
class: 'btn btn-primary',
+ title: 'Re-run with latest options',
#data: {toggle: :tooltip, placement: :top}, title: 'Re-run',
method: :post,
) do %>
<i class="fa fa-fw fa-play"></i> Re-run with latest
<% end %>
- <%= link_to raw('<i class="fa fa-fw fa-cogs"></i> Re-run options'),
+ <%= link_to raw('<i class="fa fa-fw fa-cogs"></i> Re-run options...'),
"#",
{class: 'btn btn-primary', 'data-toggle' => "modal",
- 'data-target' => '#clone-and-edit-modal-window'} %>
+ 'data-target' => '#clone-and-edit-modal-window',
+ title: 'Re-run with options'} %>
<% end %>
<% if @object.state.in? ['New', 'Ready'] %>
<%= link_to(url_for('pipeline_instance[state]' => 'RunningOnServer'),
class: 'btn btn-primary run-pipeline-button',
+ title: 'Run this pipeline',
method: :patch
) do %>
<i class="fa fa-fw fa-play"></i> Run
<% if @object.state.in? ['RunningOnClient', 'RunningOnServer'] %>
<%= link_to(url_for('pipeline_instance[state]' => 'Paused'),
class: 'btn btn-primary run-pipeline-button',
+ title: 'Pause this pipeline',
method: :patch
) do %>
<i class="fa fa-fw fa-pause"></i> Pause
<% elsif @object.state == 'Paused' %>
<%= link_to(url_for('pipeline_instance[state]' => 'RunningOnServer'),
class: 'btn btn-primary run-pipeline-button',
+ title: 'Resume this pipeline',
method: :patch
) do %>
<i class="fa fa-fw fa-play"></i> Resume
'pipeline_instance[description]' => "Created at #{Time.now.localtime}" + (@object.name.andand.size.andand>0 ? " using the pipeline template *#{@object.name}*" : ""),
'success' => 'redirect-to-created-object'
}.to_json),
- { class: "btn btn-primary btn-sm", remote: true, method: 'get' }
+ { class: "btn btn-primary btn-sm", remote: true, method: 'get', title: 'Run this pipeline' }
) do %>
- Run this pipeline
+ <i class="fa fa-gear"></i> Run this pipeline
<% end %>
<% end %>
<ul class="dropdown-menu" role="menu">
<li><%= link_to "Create new collection with selected collections", '#',
'data-href' => combine_selected_path(
- action_data: {selection_param: 'project'}.to_json
+ action_data: {current_project_uuid: @object.uuid}.to_json
),
'id' => 'combine_selections_button',
'data-selection-param-name' => 'selection[]',
action_href: actions_path(id: @object.uuid),
action_method: 'post',
action_data: {selection_param: 'selection[]', copy_selections_into_project: @object.uuid, success: 'page-refresh'}.to_json),
- { class: "btn btn-primary btn-sm", remote: true, method: 'get', data: {'event-after-select' => 'page-refresh'} }) do %>
+ { class: "btn btn-primary btn-sm", remote: true, method: 'get', title: "Add data to this project", data: {'event-after-select' => 'page-refresh'} }) do %>
<i class="fa fa-fw fa-plus"></i> Add data...
<% end %>
<%= link_to(
action_href: pipeline_instances_path,
action_method: 'post',
action_data: {'selection_param' => 'pipeline_instance[pipeline_template_uuid]', 'pipeline_instance[owner_uuid]' => @object.uuid, 'success' => 'redirect-to-created-object'}.to_json),
- { class: "btn btn-primary btn-sm", remote: true, method: 'get' }) do %>
+ { class: "btn btn-primary btn-sm", remote: true, method: 'get', title: "Run a pipeline in this project" }) do %>
<i class="fa fa-fw fa-gear"></i> Run a pipeline...
<% end %>
- <%= link_to projects_path({'project[owner_uuid]' => @object.uuid, 'options' => {'ensure_unique_name' => true}}), method: 'post', class: 'btn btn-sm btn-primary' do %>
+ <%= link_to projects_path({'project[owner_uuid]' => @object.uuid, 'options' => {'ensure_unique_name' => true}}), method: 'post', title: "Add a subproject to this project", class: 'btn btn-sm btn-primary' do %>
<i class="fa fa-fw fa-plus"></i>
Add a subproject
<% end %>
assert(page.has_text?('foo'), "Collection page did not include foo file")
assert(page.has_no_text?(bar_collection['name']), "Collection page did not include foo file")
assert(page.has_text?('bar'), "Collection page did not include bar file")
-
+ assert(page.has_text?('Created new collection in your Home project'),
+ 'Not found flash message that new collection is created in Home project')
headless.stop
end
- test "combine selected collection files into new collection" do
- headless = Headless.new
- headless.start
- Capybara.current_driver = :selenium
+ [
+ ['active', 'foo_file', false],
+ ['active', 'foo_collection_in_aproject', true],
+ ['project_viewer', 'foo_file', false],
+ ['project_viewer', 'foo_collection_in_aproject', false], #aproject not writable
+ ].each do |user, collection, expect_collection_in_aproject|
+ test "combine selected collection files into new collection #{user} #{collection} #{expect_collection_in_aproject}" do
+ headless = Headless.new
+ headless.start
+ Capybara.current_driver = :selenium
- foo_collection = api_fixture('collections')['foo_file']
+ my_collection = api_fixture('collections')[collection]
- visit page_with_token('active', "/collections")
+ visit page_with_token(user, "/collections")
- # choose file from foo collection
- within('tr', text: foo_collection['uuid']) do
- click_link 'Show'
- end
+ # choose file from foo collection
+ within('tr', text: my_collection['uuid']) do
+ click_link 'Show'
+ end
- # now in collection page
- find('input[type=checkbox]').click
+ # now in collection page
+ find('input[type=checkbox]').click
- click_button 'Selection...'
- within('.selection-action-container') do
- click_link 'Create new collection with selected files'
- end
+ click_button 'Selection...'
+ within('.selection-action-container') do
+ click_link 'Create new collection with selected files'
+ end
- # now in the newly created collection page
- assert(page.has_text?('Copy to project'), "Copy to project text not found in new collection page")
- assert(page.has_no_text?(foo_collection['name']), "Collection page did not include foo file")
- assert(page.has_text?('foo'), "Collection page did not include foo file")
+ # now in the newly created collection page
+ assert(page.has_text?('Copy to project'), "Copy to project text not found in new collection page")
+ assert(page.has_no_text?(my_collection['name']), "Collection page did not include foo file")
+ assert(page.has_text?('foo'), "Collection page did not include foo file")
+ if expect_collection_in_aproject
+ aproject = api_fixture('groups')['aproject']
+ assert page.has_text?("Created new collection in the project #{aproject['name']}"),
+ 'Not found flash message that new collection is created in aproject'
+ else
+ assert page.has_text?("Created new collection in your Home project"),
+ 'Not found flash message that new collection is created in Home project'
+ end
- headless.stop
+ headless.stop
+ end
end
end
end
wait_for_ajax
- click_link 'Move to project...'
+ click_link 'Move project...'
find('.selectable', text: 'Project 1234').click
find('.modal-footer a,button', text: 'Move').click
wait_for_ajax
end
end
- test "combine selected collections into new collection" do
- my_project = api_fixture('groups')['aproject']
- my_collection = api_fixture('collections')['collection_to_move_around_in_aproject']
-
- visit page_with_token 'active', '/'
- find("#projects-menu").click
- find(".dropdown-menu a", text: my_project['name']).click
- assert page.has_text?(my_collection['name']), 'Collection not found in project'
+ [
+ ['active', true],
+ ['project_viewer', false],
+ ].each do |user, expect_collection_in_aproject|
+ test "combine selected collections into new collection #{user} #{expect_collection_in_aproject}" do
+ my_project = api_fixture('groups')['aproject']
+ my_collection = api_fixture('collections')['collection_to_move_around_in_aproject']
+
+ visit page_with_token user, '/'
+ find("#projects-menu").click
+ find(".dropdown-menu a", text: my_project['name']).click
+ assert page.has_text?(my_collection['name']), 'Collection not found in project'
+
+ within('tr', text: my_collection['name']) do
+ find('input[type=checkbox]').click
+ end
- within('tr', text: my_collection['name']) do
- find('input[type=checkbox]').click
- end
+ click_button 'Selection...'
+ within('.selection-action-container') do
+ click_link 'Create new collection with selected collections'
+ end
- click_button 'Selection...'
- within('.selection-action-container') do
- click_link 'Create new collection with selected collections'
+ # now in the new collection page
+ if expect_collection_in_aproject
+ assert page.has_text?("Created new collection in the project #{my_project['name']}"),
+ 'Not found flash message that new collection is created in aproject'
+ else
+ assert page.has_text?("Created new collection in your Home project"),
+ 'Not found flash message that new collection is created in Home project'
+ end
+ assert page.has_text?('Content hash'), 'Not found content hash in collection page'
end
-
- # back in project page
- assert page.has_text?(my_collection['name']), 'Collection not found in project'
- assert page.has_link?('Jobs and pipelines'), 'Jobs and pipelines link not found in project'
end
- [["jobs", "/jobs"],
- ["pipelines", "/pipeline_instances"],
- ["collections", "/collections"]
+ [
+ ["jobs", "/jobs"],
+ ["pipelines", "/pipeline_instances"],
+ ["collections", "/collections"]
].each do |target,path|
test "Test dashboard button all #{target}" do
visit page_with_token 'active', '/'