[ARVADOS] updated: b8dc9c22c0a76b5ed8b36a42d06c45bd3069b6f5

git at public.curoverse.com git at public.curoverse.com
Fri May 2 16:26:58 EDT 2014


Summary of changes:
 .../app/assets/stylesheets/application.css.scss    |   13 ++++++-
 .../app/controllers/folders_controller.rb          |    4 ++
 apps/workbench/app/models/arvados_resource_list.rb |    2 +-
 apps/workbench/app/models/group.rb                 |    6 +++
 apps/workbench/app/views/folders/show.html.erb     |   22 ++++++++---
 apps/workbench/config/routes.rb                    |    4 ++-
 services/api/app/models/arvados_model.rb           |   18 +++++++++
 services/api/app/models/group.rb                   |    1 +
 .../arvados/v1/groups_controller_test.rb           |   37 ++++++++++++++++++++
 9 files changed, 97 insertions(+), 10 deletions(-)

       via  b8dc9c22c0a76b5ed8b36a42d06c45bd3069b6f5 (commit)
       via  a8fd97bee8b0d194a7013dffa0c8bfb8533e669b (commit)
       via  20cbe1178d370b71e7df2650afa7d6dc7e8c73b8 (commit)
       via  4b9281d9e47bf308d229ca4dde8af499a6674c9c (commit)
       via  7f3b351ccea1beee195c1176be229ffa6d104d3e (commit)
      from  c19ef999c3b938e6d3cdc3746fab5bad8aba3403 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit b8dc9c22c0a76b5ed8b36a42d06c45bd3069b6f5
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri May 2 16:26:47 2014 -0400

    Add "remove item from folder" buttons

diff --git a/apps/workbench/app/controllers/folders_controller.rb b/apps/workbench/app/controllers/folders_controller.rb
index 0c9b963..0a7f0f9 100644
--- a/apps/workbench/app/controllers/folders_controller.rb
+++ b/apps/workbench/app/controllers/folders_controller.rb
@@ -7,6 +7,10 @@ class FoldersController < ApplicationController
     %w(My_folders Shared_with_me)
   end
 
+  def remove_item
+    raise "Not implemented yet!"
+  end
+
   def index
     @my_folders = []
     @shared_with_me = []
diff --git a/apps/workbench/app/models/group.rb b/apps/workbench/app/models/group.rb
index 53a9496..dde6019 100644
--- a/apps/workbench/app/models/group.rb
+++ b/apps/workbench/app/models/group.rb
@@ -11,4 +11,10 @@ class Group < ArvadosBase
   def class_for_display
     group_class == 'folder' ? 'Folder' : super
   end
+
+  def editable?
+    respond_to?(:writable_by) and
+      writable_by and
+      writable_by.index(current_user.uuid)
+  end
 end
diff --git a/apps/workbench/app/views/folders/show.html.erb b/apps/workbench/app/views/folders/show.html.erb
index 85398e5..e2fca64 100644
--- a/apps/workbench/app/views/folders/show.html.erb
+++ b/apps/workbench/app/views/folders/show.html.erb
@@ -128,7 +128,8 @@
               <col width="30%" />
               <col width="15%" />
               <col width="15%" />
-              <col width="29%" />
+              <col width="24%" />
+              <col width="5%" />
             </colgroup>
             <% @objects_and_names.each do |object, name_link| %>
             <tr>
@@ -152,6 +153,13 @@
               <td class="arvados-uuid">
                 <%= object.uuid %>
               </td>
+              <td>
+                <% if @object.editable? %>
+                  <%= link_to({action: 'remove_item', id: @object.uuid, item_uuid: object.uuid}, method: :delete, remote: true, data: {confirm: "You are about to remove #{object.class_for_display} #{object.uuid} from this folder.\n\nAre you sure?"}, class: 'btn btn-xs btn-default') do %>
+                    Remove <i class="fa fa-fw fa-ban"></i>
+                  <% end %>
+                <% end %>
+              </td>
             </tr>
             <% end %>
           </tbody>
@@ -173,6 +181,8 @@
               <th>
                 uuid
               </th>
+              <th>
+              </th>
             </tr>
           </thead>
         </table>
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb
index 473ebe3..e8862c2 100644
--- a/apps/workbench/config/routes.rb
+++ b/apps/workbench/config/routes.rb
@@ -44,7 +44,9 @@ ArvadosWorkbench::Application.routes.draw do
     post 'set_persistent', on: :member
   end
   get '/collections/:uuid/*file' => 'collections#show_file', :format => false
-  resources :folders
+  resources :folders do
+    match 'remove/:item_uuid', on: :member, via: :delete, action: :remove_item
+  end
 
   post 'actions' => 'actions#post'
   get 'websockets' => 'websocket#index'

commit a8fd97bee8b0d194a7013dffa0c8bfb8533e669b
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri May 2 16:26:37 2014 -0400

    Add writable_by to Group API response.

diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb
index 4f06f05..70bd446 100644
--- a/services/api/app/models/arvados_model.rb
+++ b/services/api/app/models/arvados_model.rb
@@ -59,6 +59,24 @@ class ArvadosModel < ActiveRecord::Base
     self.columns.select { |col| col.name == attr.to_s }.first
   end
 
+  # Return nil if current user is not allowed to see the list of
+  # writers. Otherwise, return a list of user_ and group_uuids with
+  # write permission. (If not returning nil, current_user is always in
+  # the list because can_manage permission is needed to see the list
+  # of writers.)
+  def writable_by
+    unless (owner_uuid == current_user.uuid or
+            current_user.is_admin or
+            current_user.groups_i_can(:manage).index(owner_uuid))
+      return nil
+    end
+    [owner_uuid, current_user.uuid] + permissions.collect do |p|
+      if ['can_write', 'can_manage'].index p.name
+        p.tail_uuid
+      end
+    end.compact.uniq
+  end
+
   # Return a query with read permissions restricted to the union of of the
   # permissions of the members of users_list, i.e. if something is readable by
   # any user in users_list, it will be readable in the query returned by this
diff --git a/services/api/app/models/group.rb b/services/api/app/models/group.rb
index 7391df5..4d7f630 100644
--- a/services/api/app/models/group.rb
+++ b/services/api/app/models/group.rb
@@ -7,5 +7,6 @@ class Group < ArvadosModel
     t.add :name
     t.add :group_class
     t.add :description
+    t.add :writable_by
   end
 end
diff --git a/services/api/test/functional/arvados/v1/groups_controller_test.rb b/services/api/test/functional/arvados/v1/groups_controller_test.rb
index e7f0371..f8f9eae 100644
--- a/services/api/test/functional/arvados/v1/groups_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/groups_controller_test.rb
@@ -206,4 +206,41 @@ class Arvados::V1::GroupsControllerTest < ActionController::TestCase
     end
   end
 
+  test 'get writable_by list for owned group' do
+    authorize_with :active
+    get :show, {
+      id: groups(:afolder).uuid,
+      format: :json
+    }
+    assert_response :success
+    assert_not_nil(json_response['writable_by'],
+                   "Should receive uuid list in 'writable_by' field")
+    assert_includes(json_response['writable_by'], users(:active).uuid,
+                    "owner should be included in writable_by list")
+  end
+
+  test 'no writable_by list for group with read-only access' do
+    authorize_with :rominiadmin
+    get :show, {
+      id: groups(:testusergroup_admins).uuid,
+      format: :json
+    }
+    assert_response :success
+    assert_nil(json_response['writable_by'],
+               "Should not receive uuid list in 'writable_by' field")
+  end
+
+  test 'get writable_by list by admin user' do
+    authorize_with :admin
+    get :show, {
+      id: groups(:testusergroup_admins).uuid,
+      format: :json
+    }
+    assert_response :success
+    assert_not_nil(json_response['writable_by'],
+                   "Should receive uuid list in 'writable_by' field")
+    assert_includes(json_response['writable_by'],
+                    users(:admin).uuid,
+                    "Current user should be included in 'writable_by' field")
+  end
 end

commit 20cbe1178d370b71e7df2650afa7d6dc7e8c73b8
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri May 2 14:22:21 2014 -0400

    Unify button styles.

diff --git a/apps/workbench/app/views/folders/show.html.erb b/apps/workbench/app/views/folders/show.html.erb
index e02e9db..85398e5 100644
--- a/apps/workbench/app/views/folders/show.html.erb
+++ b/apps/workbench/app/views/folders/show.html.erb
@@ -8,11 +8,11 @@
       </div>
       <div class="panel-body">
         <img src="/favicon.ico" class="pull-right" alt="" style="opacity: 0.3"/>
-	<p>
-	  <%= render_editable_attribute @object, 'description', nil, { 'data-emptytext' => "Created: #{@object.created_at.to_s(:long)}", 'data-toggle' => 'manual', 'id' => "#{@object.uuid}-description" } %>
-	</p>
+	<%= render_editable_attribute @object, 'description', nil, { 'data-emptytext' => "Created: #{@object.created_at.to_s(:long)}", 'data-toggle' => 'manual', 'id' => "#{@object.uuid}-description" } %>
         <% if @object.attribute_editable? 'description' %>
-	<a href="#" class="btn btn-xs btn-info" data-toggle="x-editable" data-toggle-selector="#<%= @object.uuid %>-description">Edit description</a>
+        <div style="margin-top: 1em;">
+          <a href="#" class="btn btn-xs btn-default" data-toggle="x-editable" data-toggle-selector="#<%= @object.uuid %>-description"><i class="fa fa-fw fa-pencil"></i> Edit description</a>
+        </div>
         <% end %>
       </div>
     </div>
@@ -40,7 +40,7 @@
         <% if @logs.any? %>
 	<%= link_to raw('Show all activity   <i class="fa fa-fw fa-arrow-circle-right"></i>'),
             logs_path(filters: [['object_uuid','=', at object.uuid]].to_json),
-            class: 'btn btn-sm btn-default' %>
+            class: 'btn btn-xs btn-default' %>
         <% else %>
         <p>
           Created: <%= @object.created_at.to_s(:long) %>

commit 4b9281d9e47bf308d229ca4dde8af499a6674c9c
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri May 2 13:34:30 2014 -0400

    Add shadow to left nav.

diff --git a/apps/workbench/app/assets/stylesheets/application.css.scss b/apps/workbench/app/assets/stylesheets/application.css.scss
index 37e8e72..51c96d7 100644
--- a/apps/workbench/app/assets/stylesheets/application.css.scss
+++ b/apps/workbench/app/assets/stylesheets/application.css.scss
@@ -171,8 +171,11 @@ table.table-fixed-header-row tbody {
     z-index:1055;
 }
 
-.side-nav {
-    border-right: 1px solid #e7e7e7;
+.navbar-nav.side-nav {
+    box-shadow: inset -1px 0 #e7e7e7;
+}
+.navbar-nav.side-nav > li:first-child {
+    margin-top: 5px; /* keep "hover" bg below top nav bottom border */
 }
 .navbar-nav.side-nav > li > a {
     padding-top: 10px;
@@ -182,3 +185,9 @@ table.table-fixed-header-row tbody {
     padding-top: 5px;
     padding-bottom: 5px;
 }
+.navbar-nav.side-nav a.active,
+.navbar-nav.side-nav a:hover,
+.navbar-nav.side-nav a:focus {
+    border-right: 1px solid #ffffff;
+    background: #ffffff;
+}

commit 7f3b351ccea1beee195c1176be229ffa6d104d3e
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri May 2 10:34:10 2014 -0400

    Fix name_for method name.

diff --git a/apps/workbench/app/models/arvados_resource_list.rb b/apps/workbench/app/models/arvados_resource_list.rb
index d585b3c..1e2cf64 100644
--- a/apps/workbench/app/models/arvados_resource_list.rb
+++ b/apps/workbench/app/models/arvados_resource_list.rb
@@ -165,7 +165,7 @@ class ArvadosResourceList
   end
 
   # Note: this arbitrarily chooses one of (possibly) multiple names.
-  def names_for item_or_uuid
+  def name_for item_or_uuid
     links_for(item_or_uuid, 'name').first.andand.name
   end
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list