11870: link repositories menu item in user menu to repositories index page.
authorradhika <radhika@curoverse.com>
Thu, 29 Jun 2017 00:47:23 +0000 (20:47 -0400)
committerradhika <radhika@curoverse.com>
Thu, 29 Jun 2017 00:47:23 +0000 (20:47 -0400)
Arvados-DCO-1.1-Signed-off-by: Radhika Chippada <radhika@curoverse.com>

apps/workbench/app/controllers/users_controller.rb
apps/workbench/app/views/layouts/body.html.erb
apps/workbench/app/views/repositories/_show_help.html.erb
apps/workbench/app/views/repositories/_show_repositories.html.erb
apps/workbench/app/views/users/_repositories.html.erb [deleted file]
apps/workbench/app/views/users/repositories.html.erb [deleted file]

index 350f297af3bbcea1b3f9797b273ab15c7cf072c0..d3b8bfe99cf0158fad01198c0e2e2a15b30d63a9 100644 (file)
@@ -256,28 +256,6 @@ class UsersController < ApplicationController
     end
   end
 
-  def repositories
-    # all repositories accessible by current user
-    all_repositories = Hash[Repository.all.order('name asc').collect {|repo| [repo.uuid, repo]}]
-
-    @my_repositories = [] # we want them ordered as owned and the rest
-    @repo_writable = {}
-
-    # owned repos
-    all_repositories.each do |_, repo|
-      if repo.owner_uuid == current_user.uuid
-        @repo_writable[repo.uuid] = 'can_write'
-        @my_repositories << repo
-      end
-    end
-
-    # rest of the repos
-    handled = @my_repositories.map(&:uuid)
-    all_repositories.each do |_, repo|
-      @my_repositories << repo if !repo.uuid.in?(handled)
-    end
-  end
-
   def virtual_machines
     @my_vm_logins = {}
     Link.where(tail_uuid: @object.uuid,
index 456f15f218cee86cc76098acb33f2fab9d78cc23..0357866d44bcc392830c595c700b5b5656fa7c45 100644 (file)
                     <i class="fa fa-lg fa-terminal fa-fw"></i> Virtual machines
                   <% end %>
                 </li>
-                <li role="menuitem">
-                  <%= link_to repositories_user_path(current_user), role: 'menu-item' do %>
-                    <i class="fa fa-lg fa-code-fork fa-fw"></i> Repositories
-                  <% end %>
-                </li>
+                <li role="menuitem"><a href="/repositories" role="menuitem"><i class="fa fa-lg fa-code-fork fa-fw"></i> Repositories </a></li>
                 <li role="menuitem"><a href="/current_token" role="menuitem"><i class="fa fa-lg fa-ticket fa-fw"></i> Current token</a></li>
                 <li role="menuitem">
                   <%= link_to ssh_keys_user_path(current_user), role: 'menu-item' do %>
index 50ec8809dc48cf4a2f271dfe37da77fadd5772e8..0983d8738543404d665a1199cbb7164d9df45c2e 100644 (file)
@@ -1,4 +1,10 @@
-<% if (example = @objects.select(&:push_url).first) %>
+<%
+    filters = @filters + [["owner_uuid", "=", current_user.uuid]]
+    example = Repository.all.order("name ASC").limit(1).filter(filters).results.first
+    example = Repository.all.order("name ASC").limit(1).results.first if !example
+%>
+
+<% if example %>
 
 <p>
 Sample git quick start:
index d52229388ed76d1867732f124a35dc65b25010f7..1a74eabaf2ffc815f63b8dae7fa31941737190d3 100644 (file)
@@ -1,18 +1,28 @@
 <%= render partial: "add_repository_modal" %>
 
 <div class="container" style="width: 100%">
-  <div class="pull-right">
-    <%= link_to raw('<i class="fa fa-plus"></i> Add new repository'), "#",
-                    {class: 'btn btn-xs btn-primary', 'data-toggle' => "modal",
-                     'data-target' => '#add-repository-modal'}  %>
+  <div class="row">
+    <div class="col-md-pull-9 pull-left">
+      <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, <%= link_to ssh_keys_user_path(current_user) do%> add an SSH key to your account<%end%> and clone the git@ URLs.
+      </p>
+    </div>
+    <div class="col-md-pull-3 pull-right">
+      <%= link_to raw('<i class="fa fa-plus"></i> Add new repository'), "#",
+                      {class: 'btn btn-xs btn-primary', 'data-toggle' => "modal",
+                       'data-target' => '#add-repository-modal'}  %>
+    </div>
   </div>
 
   <div>
     <table class="table table-condensed table-fixedlayout repositories-table">
       <colgroup>
-        <col style="width: 5%" />
+        <col style="width: 10%" />
         <col style="width: 30%" />
-        <col style="width: 60%" />
+        <col style="width: 55%" />
         <col style="width: 5%" />
       </colgroup>
       <thead>
diff --git a/apps/workbench/app/views/users/_repositories.html.erb b/apps/workbench/app/views/users/_repositories.html.erb
deleted file mode 100644 (file)
index ba91b9c..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-<div class="panel panel-default">
-  <div class="panel-heading">
-    <div class="pull-right">
-      <%= link_to raw('<i class="fa fa-plus"></i> Add new repository'), "#",
-                   {class: 'btn btn-xs btn-primary', 'data-toggle' => "modal",
-                    'data-target' => '#add-repository-modal'}  %>
-    </div>
-    <h4 class="panel-title">
-      <%= link_to repositories_user_path(current_user) do%>
-        Repositories
-      <%end%>
-    </h4>
-  </div>
-
-  <div id="manage_repositories" class="panel-body">
-    <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, <%= link_to ssh_keys_user_path(current_user) do%> add an SSH key to your account<%end%> and clone the git@ URLs.
-    </p>
-
-    <% if !@my_repositories.any? %>
-      You do not seem to have access to any repositories. If you would like to request access, please contact your system admin.
-    <% else %>
-      <table class="table repositories-table">
-        <colgroup>
-          <col style="width: 5%" />
-          <col style="width: 30%" />
-          <col style="width: 60%" />
-          <col style="width: 5%" />
-        </colgroup>
-        <thead>
-          <tr>
-            <th></th>
-            <th> Name </th>
-            <th> URL </th>
-            <th></th>
-          </tr>
-        </thead>
-        <tbody>
-          <% @my_repositories.andand.each do |repo| %>
-            <tr>
-              <td>
-                <%= render :partial => "show_object_button", :locals => {object: repo, size: 'xs' } %>
-              </td>
-              <td style="word-break:break-all;">
-                <%= repo[:name] %>
-              </td>
-              <td style="word-break:break-all;">
-                <code><%= repo.http_fetch_url %></code><br/>
-                <code><%= @repo_writable[repo.uuid] ? repo.push_url : repo.fetch_url %></code>
-              </td>
-              <td>
-                <% if repo.editable? %>
-                    <%= link_to(repository_path(id: repo.uuid), method: :delete, class: 'btn btn-sm', data: {confirm: "Really delete '#{repo.name || repo.uuid}'?"}) do %>
-                        <i class="fa fa-fw fa-trash-o"></i>
-                    <% end %>
-                <% end %>
-              </td>
-            </tr>
-          <% end %>
-        </tbody>
-      </table>
-    <% end %>
-  </div>
-</div>
diff --git a/apps/workbench/app/views/users/repositories.html.erb b/apps/workbench/app/views/users/repositories.html.erb
deleted file mode 100644 (file)
index 98a1715..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-<%= render :partial => 'repositories' %>
-<%= render partial: "add_repository_modal" %>