Merge branch 'master' into 6588-split-manage-account
authorManoj <jonam33@gmail.com>
Mon, 3 Aug 2015 14:02:23 +0000 (10:02 -0400)
committerManoj <jonam33@gmail.com>
Mon, 3 Aug 2015 14:02:23 +0000 (10:02 -0400)
15 files changed:
apps/workbench/app/controllers/users_controller.rb
apps/workbench/app/views/layouts/body.html.erb
apps/workbench/app/views/users/_manage_current_token.html.erb
apps/workbench/app/views/users/_manage_repositories.html.erb
apps/workbench/app/views/users/_manage_ssh_keys.html.erb
apps/workbench/app/views/users/_manage_virtual_machines.html.erb
apps/workbench/app/views/users/manage_current_token.html.erb [new file with mode: 0644]
apps/workbench/app/views/users/manage_repositories.html.erb [new file with mode: 0644]
apps/workbench/app/views/users/manage_ssh_keys.html.erb [new file with mode: 0644]
apps/workbench/app/views/users/manage_virtual_machines.html.erb [new file with mode: 0644]
apps/workbench/config/routes.rb
apps/workbench/test/integration/application_layout_test.rb
apps/workbench/test/integration/user_manage_account_test.rb
apps/workbench/test/integration/user_profile_test.rb
services/api/test/fixtures/users.yml

index 4cf1fffc09bb3e3a815311f86c2550bbe16e5f3d..6cf15a854244c4eeac4fc644db7f8bab46e004d2 100644 (file)
@@ -255,6 +255,63 @@ class UsersController < ApplicationController
     end
   end
 
+  def manage_repositories
+    repo_links = Link.
+      filter([['head_uuid', 'is_a', 'arvados#repository'],
+              ['tail_uuid', '=', current_user.uuid],
+              ['link_class', '=', 'permission'],
+             ])
+
+    owned_repositories = Repository.where(owner_uuid: current_user.uuid)
+
+    @my_repositories = (Repository.where(uuid: repo_links.collect(&:head_uuid)) |
+                        owned_repositories).
+                       uniq { |repo| repo.uuid }
+
+
+    @repo_writable = {}
+    repo_links.each do |link|
+      if link.name.in? ['can_write', 'can_manage']
+        @repo_writable[link.head_uuid] = link.name
+      end
+    end
+
+    owned_repositories.each do |repo|
+      @repo_writable[repo.uuid] = 'can_manage'
+    end
+
+    respond_to do |f|
+      f.html { render template: 'users/manage_repositories' }
+    end
+  end
+
+  def manage_virtual_machines
+    @my_vm_logins = {}
+    Link.where(tail_uuid: current_user.uuid,
+               link_class: 'permission',
+               name: 'can_login').
+          each do |perm_link|
+            if perm_link.properties.andand[:username]
+              @my_vm_logins[perm_link.head_uuid] ||= []
+              @my_vm_logins[perm_link.head_uuid] << perm_link.properties[:username]
+            end
+          end
+    @my_virtual_machines = VirtualMachine.where(uuid: @my_vm_logins.keys)
+
+    respond_to do |f|
+      f.html { render template: 'users/manage_virtual_machines' }
+    end
+  end
+
+  def manage_ssh_keys
+    @my_ssh_keys = AuthorizedKey.where(key_type: 'SSH', owner_uuid: current_user.uuid)
+
+    @page = params["page"]
+    respond_to do |f|
+      f.html { render template: 'users/manage_ssh_keys' }
+    end
+  end
+
   def manage_account
     # repositories current user can read / write
     repo_links = Link.
index 0f90c416f0c929c660dd97616dd54db32a2f4750..4a17abb768021d10673c3987cce58d274fd6c71e 100644 (file)
                   <%= current_user.email %>
                 </li>
                 <% if current_user.is_active %>
-                <li role="menuitem"><a href="/projects/<%=current_user.uuid%>" role="menuitem"><i class="fa fa-home fa-fw"></i> Home project </a></li>
-                <li role="menuitem"><a href="/manage_account" role="menuitem"><i class="fa fa-key fa-fw"></i> Manage account</a></li>
+                <li role="menuitem"><a href="/projects/<%=current_user.uuid%>" role="menuitem"><i class="fa fa-lg fa-home fa-fw"></i> My home project </a></li>
+
+                <li role="menuitem"><a href="/manage_virtual_machines" role="menuitem"><i class="fa fa-lg fa-terminal fa-fw"></i> My virtual machines</a></li>
+                <li role="menuitem"><a href="/manage_repositories" role="menuitem"><i class="fa fa-lg fa-code-fork fa-fw"></i> My repositories</a></li>
+                <li role="menuitem"><a href="/manage_current_token" role="menuitem"><i class="fa fa-lg fa-ticket fa-fw"></i> My current token</a></li>
+                <li role="menuitem"><a href="/manage_ssh_keys" role="menuitem"><i class="fa fa-lg fa-key fa-fw"></i> My SSH keys</a></li>
+
+                <li role="menuitem"><a href="/manage_account" role="menuitem"><i class="fa fa-lg fa-key fa-fw"></i> Manage account</a></li>
+
                 <% if Rails.configuration.user_profile_form_fields %>
-                  <li role="menuitem"><a href="/users/<%=current_user.uuid%>/profile" role="menuitem"><i class="fa fa-key fa-fw"></i> Manage profile</a></li>
+                  <li role="menuitem"><a href="/users/<%=current_user.uuid%>/profile" role="menuitem"><i class="fa fa-lg fa-user fa-fw"></i> Manage profile</a></li>
                 <% end %>
                 <% end %>
-                <li role="menuitem"><a href="<%= logout_path %>" role="menuitem"><i class="fa fa-sign-out fa-fw"></i> Log out</a></li>
+                <li role="presentation" class="divider"></li>
+                <li role="menuitem"><a href="<%= logout_path %>" role="menuitem"><i class="fa fa-lg fa-sign-out fa-fw"></i> Log out</a></li>
                 <% if user_notifications.any? %>
                   <li role="presentation" class="divider"></li>
                   <% user_notifications.each_with_index do |n, i| %>
@@ -80,7 +88,7 @@
                 </a>
                 <ul class="dropdown-menu" role="menu">
                   <li role="presentation" class="dropdown-header">
-                    Settings
+                    Admin Settings
                   </li>
                   <li role="menuitem"><a href="/repositories">
                       <i class="fa fa-lg fa-code-fork fa-fw"></i> Repositories
index f4436ba8b96fbd10686a9ed5e3f81bbddb031801..de601cb6be630df6b86df8f12b46e17899a97a14 100644 (file)
@@ -1,7 +1,7 @@
 <div class="panel panel-default">
   <div class="panel-heading">
     <h4 class="panel-title">
-      <a data-parent="#arv-adv-accordion" href="#manage_current_token">
+      <a data-parent="#arv-adv-accordion" href="/manage_current_token">
         Current Token
       </a>
     </h4>
@@ -9,7 +9,7 @@
 
 <div id="#manage_current_token" class="panel-body">
 <p>The Arvados API token is a secret key that enables the Arvados SDKs to access Arvados with the proper permissions. For more information see <%= link_to raw('Getting an API token'), "#{Rails.configuration.arvados_docsite}/user/reference/api-tokens.html", target: "_blank"%>.</p>
-<p>Paste the following lines at a shell prompt to set up the necessary environment for Arvados SDKs to authenticate to your account, <b><%= current_user.email %></b></p>
+<p>Paste the following lines at a shell prompt to set up the necessary environment for Arvados SDKs to authenticate to your <b><%= current_user.username %></b> account.</p>
 
 <pre>
 HISTIGNORE=$HISTIGNORE:'export ARVADOS_API_TOKEN=*'
@@ -21,5 +21,6 @@ export ARVADOS_API_HOST_INSECURE=true
 unset ARVADOS_API_HOST_INSECURE
 <% end %>
 </pre>
+<p>Arvados <a href="/manage_virtual_machines"> virtual machines</a> do this for you automatically. This setup is needed only when you use the API remotely (e.g., from your own workstation).</p>
 </div>
 </div>
index b616b6d6347fe2056d1f2666bbb060cac44ffb50..b16e29dd384d4bab1f2af5ac446cd0c56b7aec61 100644 (file)
@@ -6,7 +6,7 @@
                     'data-target' => '#add-repository-modal'}  %>
     </div>
     <h4 class="panel-title">
-      <a data-parent="#arv-adv-accordion" href="#manage_repositories">
+      <a data-parent="#arv-adv-accordion" href="/manage_repositories">
         Repositories
       </a>
     </h4>
@@ -61,3 +61,5 @@
   <% end %>
 </div>
 </div>
+  <p>When you are using an Arvados virtual machine, you should clone the https:// URLs. This will authenticate automatically using your API token.</p>
+  <p>In order to clone git repositories using SSH, <a href="/manage_ssh_keys"> add an SSH key to your account</a> and clone the git@ URLs.</p>
index 951b79c6dea19551f58cb47ac4a84a6a33c74933..b3f9bddde467f569bd7a7234a3852de787989ab0 100644 (file)
@@ -6,7 +6,7 @@
                     'data-target' => '#add-ssh-key-modal-window'}  %>
     </div>
     <h4 class="panel-title">
-      <a data-parent="#arv-adv-accordion" href="#manage_ssh_keys">
+      <a data-parent="#arv-adv-accordion" href="/manage_ssh_keys">
         SSH Keys
       </a>
     </h4>
 
 <div id="manage_ssh_keys" class="panel-body">
   <% if !@my_ssh_keys.any? %>
-     <p> You have not yet set up an SSH public key for use with Arvados. </p>
-     <p>  <%= link_to "Click here",
+     <p> You have not yet set up an SSH public key for use with Arvados. <%= link_to "Learn more.",
                   "#{Rails.configuration.arvados_docsite}/user/getting_started/ssh-access-unix.html",
                   style: "font-weight: bold",
-                  target: "_blank" %>  to learn about SSH keys in Arvados.
+                  target: "_blank" %>
      </p>
      <p> When you have an SSH key you would like to use, add it using the <b>Add</b> button. </p>
   <% else %>
index 295311d33d62b848e7e47baab25a8662a7f6043c..65ecfff9a45904516a08230bb95d0bfd9ee0119a 100644 (file)
@@ -1,7 +1,7 @@
 <div class="panel panel-default">
   <div class="panel-heading">
     <h4 class="panel-title">
-      <a data-parent="#arv-adv-accordion" href="#manage_virtual_machines">
+      <a data-parent="#arv-adv-accordion" href="/manage_virtual_machines">
         Virtual Machines
       </a>
     </h4>
         <% end %>
       </tbody>
     </table>
-
-    <p>Sample SSH Conig  <i>~/.ssh/config:</i></p>
+  <% end %>
+</div>
+</div>
+  <p>In order to access virtual machines using SSH, <a href="/manage_ssh_keys"> add an SSH key to your account</a> and add a section like this to your SSH configuration file ( <i>~/.ssh/config</i>):</p>
     <pre>Host *.arvados
       TCPKeepAlive yes
       ServerAliveInterval 60
       ProxyCommand ssh -p2222 turnout@switchyard.<%= current_api_host || 'xyzzy.arvadosapi.com' %> -x -a $SSH_PROXY_FLAGS %h
     </pre>
-  <% end %>
-</div>
-</div>
diff --git a/apps/workbench/app/views/users/manage_current_token.html.erb b/apps/workbench/app/views/users/manage_current_token.html.erb
new file mode 100644 (file)
index 0000000..7129fa1
--- /dev/null
@@ -0,0 +1 @@
+<%= render :partial => 'manage_current_token' %>
diff --git a/apps/workbench/app/views/users/manage_repositories.html.erb b/apps/workbench/app/views/users/manage_repositories.html.erb
new file mode 100644 (file)
index 0000000..0182c4d
--- /dev/null
@@ -0,0 +1,2 @@
+<%= render :partial => 'manage_repositories' %>
+<%= render partial: "add_repository_modal" %>
diff --git a/apps/workbench/app/views/users/manage_ssh_keys.html.erb b/apps/workbench/app/views/users/manage_ssh_keys.html.erb
new file mode 100644 (file)
index 0000000..786d13f
--- /dev/null
@@ -0,0 +1,2 @@
+<%= render :partial => 'manage_ssh_keys' %>
+<div id="add-ssh-key-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
diff --git a/apps/workbench/app/views/users/manage_virtual_machines.html.erb b/apps/workbench/app/views/users/manage_virtual_machines.html.erb
new file mode 100644 (file)
index 0000000..3f5fd00
--- /dev/null
@@ -0,0 +1 @@
+<%= render :partial => 'manage_virtual_machines' %>
index f72278a2a41d12d36129816c5e78621928152f7e..86140cf072050bf73062019dffd2060e8767a1e7 100644 (file)
@@ -47,6 +47,10 @@ ArvadosWorkbench::Application.routes.draw do
     get 'profile', :on => :member
     post 'request_shell_access', :on => :member
   end
+  get '/manage_virtual_machines' => 'users#manage_virtual_machines'
+  get '/manage_repositories' => 'users#manage_repositories'
+  get '/manage_current_token' => 'users#manage_current_token'
+  get '/manage_ssh_keys' => 'users#manage_ssh_keys'
   get '/manage_account' => 'users#manage_account'
   get "/add_ssh_key_popup" => 'users#add_ssh_key_popup', :as => :add_ssh_key_popup
   get "/add_ssh_key" => 'users#add_ssh_key', :as => :add_ssh_key
index 31a297f0c14c3dd4215499e8d202d294ca980ff5..b14563568742622ec9d762985416e1a6e9c38b02 100644 (file)
@@ -49,7 +49,7 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
             assert page.has_no_link?('Not active'), 'Found link - Not active'
             assert page.has_no_link?('Sign agreements'), 'Found link - Sign agreements'
 
-            assert_selector "a[href=\"/projects/#{user['uuid']}\"]", text: 'Home project'
+            assert_selector "a[href=\"/projects/#{user['uuid']}\"]", text: 'My home project'
             assert page.has_link?('Manage account'), 'No link - Manage account'
 
             if profile_config
@@ -58,7 +58,7 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
               assert page.has_no_link?('Manage profile'), 'Found link - Manage profile'
             end
           else
-            assert_no_selector 'a', text: 'Home project'
+            assert_no_selector 'a', text: 'My home project'
             assert page.has_no_link?('Manage account'), 'Found link - Manage account'
             assert page.has_no_link?('Manage profile'), 'Found link - Manage profile'
           end
index 1b80daf03ce49905e8ed4097496544c958a432bf..8da7b5821d57720823df65570908b740579511c8 100644 (file)
@@ -11,16 +11,16 @@ class UserManageAccountTest < ActionDispatch::IntegrationTest
       within('.navbar-fixed-top') do
         page.find("#notifications-menu").click
         within('.dropdown-menu') do
-          find('a', text: 'Manage account').click
+          assert_selector 'a', text: 'My virtual machines'
+          assert_selector 'a', text: 'My repositories'
+          assert_selector 'a', text: 'My current token'
+          assert_selector 'a', text: 'My SSH keys'
+          find('a', text: 'My SSH keys').click
         end
       end
 
-      # now in manage account page
-      assert page.has_text?('Virtual Machines'), 'No text - Virtual Machines'
-      assert page.has_text?('Repositories'), 'No text - Repositories'
-      assert page.has_text?('SSH Keys'), 'No text - SSH Keys'
-      assert page.has_text?('Current Token'), 'No text - Current Token'
-      assert page.has_text?('The Arvados API token is a secret key that enables the Arvados SDKs to access Arvados'), 'No text - Arvados API token'
+      # now in My SSH Keys page
+      assert page.has_text?('Add new SSH key'), 'No text - Add SSH key'
       add_and_verify_ssh_key
     else  # inactive user
       within('.navbar-fixed-top') do
@@ -164,7 +164,7 @@ class UserManageAccountTest < ActionDispatch::IntegrationTest
     within('.navbar-fixed-top') do
       page.find("#notifications-menu").click
       within('.dropdown-menu') do
-        find('a', text: 'Manage account').click
+        find('a', text: 'My virtual machines').click
       end
     end
     assert_text 'You do not have access to any virtual machines.'
@@ -183,4 +183,49 @@ class UserManageAccountTest < ActionDispatch::IntegrationTest
     assert_match /git@git.*:active\/workbenchtest.git/, page.text
     assert_match /https:\/\/git.*\/active\/workbenchtest.git/, page.text
   end
+
+  [
+    ['My virtual machines', nil, 'Host name'],
+    ['My repositories', 'Add new repository', 'It may take a minute or two before you can clone your new repository.'],
+    ['My current token', nil, 'HISTIGNORE=$HISTIGNORE'],
+    ['My SSH keys', 'Add new SSH key', 'Click here to learn about SSH keys in Arvados.'],
+  ].each do |page_name, button_name, look_for|
+    test "test notification menu for page #{page_name}" do
+      visit page_with_token('admin')
+      within('.navbar-fixed-top') do
+          page.find("#notifications-menu").click
+          within('.dropdown-menu') do
+            assert_selector 'a', text: page_name
+            find('a', text: page_name).click
+          end
+      end
+
+      if button_name
+        assert_selector 'a', text: button_name
+        find('a', text: button_name).click
+      end
+
+      assert page.has_text? look_for
+    end
+  end
+
+  [
+    ['My virtual machines', 'You do not have access to any virtual machines.'],
+    ['My repositories', 'You do not seem to have access to any repositories.'],
+    ['My current token', 'HISTIGNORE=$HISTIGNORE'],
+    ['My SSH keys', 'You have not yet set up an SSH public key for use with Arvados.'],
+  ].each do |page_name, look_for|
+    test "test notification menu for page #{page_name} when page is empty" do
+      visit page_with_token('user1_with_load')
+      within ('.navbar-fixed-top') do
+        page.find("#notifications-menu").click
+        within('.dropdown-menu') do
+          assert_selector 'a', text: page_name
+          find('a', text: page_name).click
+        end
+      end
+
+     assert page.has_text? look_for
+    end
+  end
 end
index 3aac6a0ea08375b7c152babf1d9086553f9af8c8..05f3c65db71ce50d1ecb6c4ff39c930515b15cfc 100644 (file)
@@ -54,7 +54,10 @@ class UserProfileTest < ActionDispatch::IntegrationTest
             assert page.has_no_link?('Not active'), 'Found link - Not active'
             assert page.has_no_link?('Sign agreements'), 'Found link - Sign agreements'
 
-            assert page.has_link?('Manage account'), 'No link - Manage account'
+            assert page.has_link?('My virtual machines'), 'No link - My Virtual Machines'
+            assert page.has_link?('My repositories'), 'No link - My Repositories'
+            assert page.has_link?('My current token'), 'No link - My Current Token'
+            assert page.has_link?('My SSH keys'), 'No link - My SSH Keys'
 
             if profile_config
               assert page.has_link?('Manage profile'), 'No link - Manage profile'
index e2088db68a73d9da53d5e1bb0bafd6d9f874f61d..db9607bc02476a5f3b5385665d9f02024178e3fc 100644 (file)
@@ -278,6 +278,7 @@ user1_with_load:
   identity_url: https://user1_with_load.openid.local
   is_active: true
   is_admin: false
+  username: user1withload
   prefs:
     profile:
       organization: example.com