2659: Toggle features according to editable? and creatable? instead of current_user...
authorTom Clegg <tom@curoverse.com>
Tue, 3 Feb 2015 19:27:10 +0000 (14:27 -0500)
committerTom Clegg <tom@curoverse.com>
Tue, 3 Feb 2015 19:27:10 +0000 (14:27 -0500)
apps/workbench/app/views/jobs/_show_job_buttons.html.erb
apps/workbench/app/views/pipeline_instances/_running_component.html.erb
apps/workbench/app/views/pipeline_instances/_show_inputs.html.erb
apps/workbench/app/views/pipeline_templates/show.html.erb
apps/workbench/app/views/projects/_show_tab_contents.html.erb

index a1866154277fc97afd7cb269f4042a9ad5308f2c..b6c39df9a50c1e85ccc644a9f7de4e2a3d48d7f3 100644 (file)
@@ -1,4 +1,4 @@
-<% if @object.state != "Running" && current_user.andand.is_active %>
+<% if @object.state != "Running" and Job.creatable? %>
   <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#jobRerunModal">
     <i class="fa fa-fw fa-gear"></i> Re-run job...
   </button>
index d0929d5044040798602441b51b6f8ffa6d09efc4..f87dede2a6e5386f8d98251df5800982cd6e2acd 100644 (file)
@@ -75,8 +75,7 @@
             </div>
           <% end %>
 
-          <% if current_user.andand.is_active %>
-          <% if current_job[:state].in? ["Queued", "Running"] %>
+          <% if current_job[:state].in? ["Queued", "Running"] and @object.editable? %>
             <%# column offset 11 %>
             <div class="col-md-1 pipeline-instance-spacing">
               <%= form_tag "/jobs/#{current_job[:uuid]}/cancel", remote: true, style: "display:inline; padding-left: 1em" do |f| %>
@@ -85,7 +84,6 @@
               <% end %>
             </div>
           <% end %>
-          <% end %>
         <% end %>
       </div>
     </div>
index 952337508f2d88fb996c271dc35c35f7f0bee79a..e6b7ef20347cf2a5c25af1b0304da4554a981b7a 100644 (file)
   <p>This pipeline does not need any further inputs specified. You can start it by clicking the "Run" button whenever you're ready. (It's not too late to change existing settings, though.)</p>
 <% else %>
   <p><i>Provide <%= n_inputs > 1 ? 'values' : 'a value' %> for the following <%= n_inputs > 1 ? 'parameters' : 'parameter' %>, then click the "Run" button to start the pipeline.</i></p>
-  <%= content_for :pi_input_form %>
-
-  <% if current_user.andand.is_active %>
-  <%= link_to(url_for('pipeline_instance[state]' => 'RunningOnServer'),
-      class: 'btn btn-primary run-pipeline-button',
-      method: :patch
-      ) do %>
-    Run <i class="fa fa-fw fa-play"></i>
-  <% end %>
+  <% if @object.editable? %>
+    <%= content_for :pi_input_form %>
+      <%= link_to(url_for('pipeline_instance[state]' => 'RunningOnServer'),
+          class: 'btn btn-primary run-pipeline-button',
+          method: :patch
+          ) do %>
+        Run <i class="fa fa-fw fa-play"></i>
+    <% end %>
   <% end %>
 
 <% end %>
index f9f94808e646af65a74f840107dc843699b34371..b4264e5ef269d069508ba6fc415ecda5fa1ebd75 100644 (file)
@@ -1,21 +1,25 @@
-<% if current_user.andand.is_active %>
-<% content_for :tab_line_buttons do %>
-  <%= link_to(choose_projects_path(id: "run-pipeline-button",
-                                     title: 'Choose project',
-                                     editable: true,
-                                     action_name: 'Choose',
-                                     action_href: pipeline_instances_path,
-                                     action_method: 'post',
-                                     action_data: {selection_param: 'pipeline_instance[owner_uuid]',
-                                                   'pipeline_instance[pipeline_template_uuid]' => @object.uuid,
-                                                   '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, title: 'Run this pipeline' }
-               ) do %>
-                   <i class="fa fa-gear"></i> Run this pipeline
-                 <% end %>
-<% end %>
+<% if @object.editable? %>
+  <% content_for :tab_line_buttons do %>
+    <%= link_to(choose_projects_path(
+        id: "run-pipeline-button",
+        title: 'Choose project',
+        editable: true,
+        action_name: 'Choose',
+        action_href: pipeline_instances_path,
+        action_method: 'post',
+        action_data: {
+          'selection_param' => 'pipeline_instance[owner_uuid]',
+          'pipeline_instance[pipeline_template_uuid]' => @object.uuid,
+          '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,
+          title: 'Run this pipeline'
+        }) do %>
+      <i class="fa fa-gear"></i> Run this pipeline
+    <% end %>
+  <% end %>
 <% end %>
 
 <%= render file: 'application/show.html.erb', locals: local_assigns %>
index b3b599329f82c73397c2ba00791943c0fccad586..0b308db6ff072e1f22c833831a586707cfbaa652 100644 (file)
@@ -5,17 +5,17 @@
       <div class="btn-group btn-group-sm">
         <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Selection <span class="caret"></span></button>
         <ul class="dropdown-menu" role="menu">
-          <% if current_user.andand.is_active %>
-          <li><%= link_to "Create new collection with selected collections", '#',
-                  'data-href' => combine_selected_path(
-                    action_data: {current_project_uuid: @object.uuid}.to_json
-                  ),
-                  'id' => 'combine_selections_button',
-                  method: :post,
-                  'data-selection-param-name' => 'selection[]',
-                  'data-selection-action' => 'combine-project-contents',
-                  'data-toggle' => 'dropdown'
-            %></li>
+          <% if Collection.creatable? %>
+            <li><%= link_to "Create new collection with selected collections", '#',
+                    'data-href' => combine_selected_path(
+                      action_data: {current_project_uuid: @object.uuid}.to_json
+                    ),
+                    'id' => 'combine_selections_button',
+                    method: :post,
+                    'data-selection-param-name' => 'selection[]',
+                    'data-selection-action' => 'combine-project-contents',
+                    'data-toggle' => 'dropdown'
+              %></li>
           <% end %>
           <li><%= link_to "Compare selected", '#',
                   'data-href' => compare_pipeline_instances_path,
                   'data-selection-action' => 'compare',
                   'data-toggle' => 'dropdown'
             %></li>
-          <% if current_user.andand.is_active %>
-          <li><%= link_to "Copy selected...", '#',
-                  'data-href' => choose_projects_path(
-                    title: 'Copy selected items to...',
-                    editable: true,
-                    action_name: 'Copy',
-                    action_href: actions_path,
-                    action_method: 'post',
-                    action_data_from_params: ['selection'],
-                    action_data: {
-                      copy_selections_into_project: true,
-                      selection_param: 'uuid',
-                      success: 'page-refresh'}.to_json),
-                  'data-remote' => true,
-                  'data-selection-param-name' => 'selection[]',
-                  'data-selection-action' => 'copy',
-                  'data-toggle' => 'dropdown'
-            %></li>
+          <% if Collection.creatable? %>
+            <li><%= link_to "Copy selected...", '#',
+                    'data-href' => choose_projects_path(
+                      title: 'Copy selected items to...',
+                      editable: true,
+                      action_name: 'Copy',
+                      action_href: actions_path,
+                      action_method: 'post',
+                      action_data_from_params: ['selection'],
+                      action_data: {
+                        copy_selections_into_project: true,
+                        selection_param: 'uuid',
+                        success: 'page-refresh'}.to_json),
+                    'data-remote' => true,
+                    'data-selection-param-name' => 'selection[]',
+                    'data-selection-action' => 'copy',
+                    'data-toggle' => 'dropdown'
+              %></li>
           <% end %>
           <% if @object.editable? %>
-          <li><%= link_to "Move selected...", '#',
-                  'data-href' => choose_projects_path(
-                    title: 'Move selected items to...',
-                    editable: true,
-                    action_name: 'Move',
-                    action_href: actions_path,
-                    action_method: 'post',
-                    action_data_from_params: ['selection'],
-                    action_data: {
-                      move_selections_into_project: true,
-                      selection_param: 'uuid',
-                      success: 'page-refresh'}.to_json),
-                  'data-remote' => true,
-                  'data-selection-param-name' => 'selection[]',
-                  'data-selection-action' => 'move',
-                  'data-toggle' => 'dropdown'
-            %></li>
-          <li><%= link_to "Remove selected", '#',
-                  method: :delete,
-                  'data-href' => url_for(action: :remove_items),
-                  'data-selection-param-name' => 'item_uuids[]',
-                  'data-selection-action' => 'remove',
-                  'data-remote' => true,
-                  'data-toggle' => 'dropdown'
-            %></li>
+            <li><%= link_to "Move selected...", '#',
+                    'data-href' => choose_projects_path(
+                      title: 'Move selected items to...',
+                      editable: true,
+                      action_name: 'Move',
+                      action_href: actions_path,
+                      action_method: 'post',
+                      action_data_from_params: ['selection'],
+                      action_data: {
+                        move_selections_into_project: true,
+                        selection_param: 'uuid',
+                        success: 'page-refresh'}.to_json),
+                    'data-remote' => true,
+                    'data-selection-param-name' => 'selection[]',
+                    'data-selection-action' => 'move',
+                    'data-toggle' => 'dropdown'
+              %></li>
+            <li><%= link_to "Remove selected", '#',
+                    method: :delete,
+                    'data-href' => url_for(action: :remove_items),
+                    'data-selection-param-name' => 'item_uuids[]',
+                    'data-selection-action' => 'remove',
+                    'data-remote' => true,
+                    'data-toggle' => 'dropdown'
+              %></li>
           <% end %>
         </ul>
       </div>