From 801add452adb8804711ee10deff82243913fc9df Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Wed, 21 Oct 2020 16:02:12 -0400 Subject: [PATCH] 17010: Redesign "Re-run..." button to choose project to run in Also move workflow step reuse to the "Inputs" tab instead of a modal. Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- .../container_requests_controller.rb | 44 ++++++++++++++--- .../app/helpers/application_helper.rb | 5 ++ .../workbench/app/models/container_request.rb | 20 ++++++++ .../_extra_tab_line_buttons.html.erb | 47 +++++-------------- .../container_requests/_show_inputs.html.erb | 18 +++---- 5 files changed, 85 insertions(+), 49 deletions(-) diff --git a/apps/workbench/app/controllers/container_requests_controller.rb b/apps/workbench/app/controllers/container_requests_controller.rb index 8ce068198e..c42e93375b 100644 --- a/apps/workbench/app/controllers/container_requests_controller.rb +++ b/apps/workbench/app/controllers/container_requests_controller.rb @@ -121,6 +121,23 @@ class ContainerRequestsController < ApplicationController end end params[:merge] = true + + if !@updates[:reuse_steps].nil? + if @updates[:reuse_steps] == "false" + @updates[:reuse_steps] = false + end + @updates[:command] ||= @object.command + if @updates[:reuse_steps] + @updates[:command] = @updates[:command] - ["--disable-reuse"] + @updates[:command].insert(1, '--enable-reuse') + else + @updates[:command] -= @updates[:command] - ["--enable-reuse"] + @updates[:command].insert(1, '--disable-reuse') + end + + @updates.delete(:reuse_steps) + end + begin super rescue => e @@ -134,6 +151,27 @@ class ContainerRequestsController < ApplicationController @object = ContainerRequest.new + # set owner_uuid to that of source, provided it is a project and writable by current user + if params[:work_unit][:owner_uuid] + @object.owner_uuid = src.owner_uuid = params[:work_unit][:owner_uuid] + else + current_project = Group.find(src.owner_uuid) rescue nil + if (current_project && current_project.writable_by.andand.include?(current_user.uuid)) + @object.owner_uuid = src.owner_uuid + end + end + + if src.command[0] == 'arvados-cwl-runner' + command.each_with_index do |arg, i| + if arg.start_with? "--project-uuid=" + command[i] = "--project-uuid=#{@object.owner_uuid}" + end + if arg == "--disable-reuse" + command[i] = "--enable-reuse" + end + end + end + # By default the copied CR won't be reusing containers, unless use_existing=true # param is passed. command = src.command @@ -167,12 +205,6 @@ class ContainerRequestsController < ApplicationController @object.scheduling_parameters = src.scheduling_parameters @object.state = 'Uncommitted' - # set owner_uuid to that of source, provided it is a project and writable by current user - current_project = Group.find(src.owner_uuid) rescue nil - if (current_project && current_project.writable_by.andand.include?(current_user.uuid)) - @object.owner_uuid = src.owner_uuid - end - super end diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb index 330d30976f..786716eb33 100644 --- a/apps/workbench/app/helpers/application_helper.rb +++ b/apps/workbench/app/helpers/application_helper.rb @@ -247,11 +247,15 @@ module ApplicationHelper end input_type = 'text' + opt_selection = nil attrtype = object.class.attribute_info[attr.to_sym].andand[:type] if attrtype == 'text' or attr == 'description' input_type = 'textarea' elsif attrtype == 'datetime' input_type = 'date' + elsif attrtype == 'boolean' + input_type = 'select' + opt_selection = ([{value: "true", text: "true"}, {value: "false", text: "false"}]).to_json else input_type = 'text' end @@ -279,6 +283,7 @@ module ApplicationHelper "data-emptytext" => '(none)', "data-placement" => "bottom", "data-type" => input_type, + "data-source" => opt_selection, "data-title" => "Edit #{attr.to_s.gsub '_', ' '}", "data-name" => htmloptions['selection_name'] || attr, "data-object-uuid" => object.uuid, diff --git a/apps/workbench/app/models/container_request.rb b/apps/workbench/app/models/container_request.rb index 48920c55e7..be97a6cfb5 100644 --- a/apps/workbench/app/models/container_request.rb +++ b/apps/workbench/app/models/container_request.rb @@ -22,4 +22,24 @@ class ContainerRequest < ArvadosBase def work_unit(label=nil, child_objects=nil) ContainerWorkUnit.new(self, label, self.uuid, child_objects=child_objects) end + + def editable_attributes + super + ["reuse_steps"] + end + + def reuse_steps + command.each do |arg| + if arg == "--enable-reuse" + return true + end + end + false + end + + def self.attribute_info + self.columns + @attribute_info[:reuse_steps] = {:type => "boolean"} + @attribute_info + end + end diff --git a/apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb b/apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb index b698c938a1..cc5d2dec5c 100644 --- a/apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb +++ b/apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb @@ -9,40 +9,19 @@ SPDX-License-Identifier: AGPL-3.0 %> } - <%= link_to raw(' Re-run...'), - "#", - {class: 'btn btn-sm btn-primary', 'data-toggle' => 'modal', - 'data-target' => '#clone-and-edit-modal-window', - title: 'This will make a copy and take you there. You can then make any needed changes and run it'} %> - - <% end %> diff --git a/apps/workbench/app/views/container_requests/_show_inputs.html.erb b/apps/workbench/app/views/container_requests/_show_inputs.html.erb index fd8e363838..07bf7c4d76 100644 --- a/apps/workbench/app/views/container_requests/_show_inputs.html.erb +++ b/apps/workbench/app/views/container_requests/_show_inputs.html.erb @@ -17,23 +17,23 @@ n_inputs = if @object.mounts[:"/var/lib/cwl/workflow.json"] && @object.mounts[:" <% if workflow %> <% inputs = get_cwl_inputs(workflow) %> <% inputs.each do |input| %> - -
-

- <%= render_cwl_input @object, input, [:mounts, :"/var/lib/cwl/cwl.input.json", :content] %> +

+ + <%= render_cwl_input @object, input, [:mounts, :"/var/lib/cwl/cwl.input.json", :content] %> +

+ <%= input[:doc] %>

-

- <%= input[:doc] %> -

<% end %> <% end %>
<% end %> +

Reuse past workflow steps if available? <%= render_editable_attribute(@object, :reuse_steps) %>

+ <% if n_inputs == 0 %>

This workflow does not need any further inputs specified. Click the "Run" button at the bottom of the page to start the workflow.

<% else %> -- 2.30.2