[ARVADOS] created: 7b82554aa0de6f490170fba9117f252f777f0e2f

git at public.curoverse.com git at public.curoverse.com
Thu Jul 17 16:51:50 EDT 2014


        at  7b82554aa0de6f490170fba9117f252f777f0e2f (commit)


commit 7b82554aa0de6f490170fba9117f252f777f0e2f
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Jul 17 16:51:22 2014 -0400

    3214: Hide "create subproject" button when showing a non-editable project.
    
    Change "new project" link in top nav dropdown to create a new project
    at top level, instead of inside the current project.

diff --git a/apps/workbench/app/views/layouts/application.html.erb b/apps/workbench/app/views/layouts/application.html.erb
index 63de6c2..ec2c98b 100644
--- a/apps/workbench/app/views/layouts/application.html.erb
+++ b/apps/workbench/app/views/layouts/application.html.erb
@@ -175,7 +175,7 @@
                     link_to(project_path(pnode[:object].uuid), data: {object_uuid: pnode[:object].uuid, name: 'name'}, &block)
                   end,
                   :top_button => Proc.new do %>
-                    <% link_to projects_path('project[owner_uuid]' => current_project_uuid), method: 'post', class: 'btn btn-xs btn-default pull-right' do %>
+                    <% link_to projects_path, method: 'post', class: 'btn btn-xs btn-default pull-right' do %>
                       <i class="fa fa-plus"></i> New project
                     <% end %>
                   <% end %>
diff --git a/apps/workbench/app/views/projects/_show_contents.html.erb b/apps/workbench/app/views/projects/_show_contents.html.erb
index 0c8fab2..7d047c7 100644
--- a/apps/workbench/app/views/projects/_show_contents.html.erb
+++ b/apps/workbench/app/views/projects/_show_contents.html.erb
@@ -33,9 +33,11 @@
 	  { class: "btn btn-primary btn-sm", remote: true, method: 'get' }) do %>
       <i class="fa fa-fw fa-gear"></i> Run a pipeline...
     <% end %>
-    <%= link_to projects_path('project[owner_uuid]' => @object.uuid), method: 'post', class: 'btn btn-sm btn-primary' do %>
-      <i class="fa fa-fw fa-plus"></i>
-      Add a subproject
+    <% if @object.editable? %>
+      <%= link_to projects_path('project[owner_uuid]' => @object.uuid), method: 'post', class: 'btn btn-sm btn-primary' do %>
+	<i class="fa fa-fw fa-plus"></i>
+	Add a subproject
+      <% end %>
     <% end %>
     <%= link_to(
 	choose_projects_path(
diff --git a/apps/workbench/test/functional/projects_controller_test.rb b/apps/workbench/test/functional/projects_controller_test.rb
index b338aa8..a991ced 100644
--- a/apps/workbench/test/functional/projects_controller_test.rb
+++ b/apps/workbench/test/functional/projects_controller_test.rb
@@ -9,4 +9,23 @@ class ProjectsControllerTest < ActionController::TestCase
     assert_template 'user_agreements/index',
     "Inactive user was not presented with a user agreement at the front page"
   end
+
+  [[:active, true],
+   [:project_viewer, false]].each do |which_user, should_show|
+    test "create subproject button #{'not ' unless should_show} shown to #{which_user}" do
+      readonly_project_uuid = api_fixture('groups')['aproject']['uuid']
+      get :show, {
+        id: readonly_project_uuid
+      }, session_for(which_user)
+      buttons = css_select('[data-method=post]').select do |el|
+        el.attributes['href'].match /project.*owner_uuid.*#{readonly_project_uuid}/
+      end
+      if should_show
+        assert_not_empty(buttons, "did not offer to create a subproject")
+      else
+        assert_empty(buttons.collect(&:to_s),
+                     "offered to create a subproject in a non-writable project")
+      end
+    end
+  end
 end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list