From: Ward Vandewege Date: Tue, 30 Mar 2021 20:40:52 +0000 (-0400) Subject: 17119: Merge branch 'master' into 17119-add-filter-groups X-Git-Tag: 2.2.0~84^2 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/d63eaa465e157dd289a80738c5da83edaf03e784?hp=5eacdd4d7ad270ac40448e1c5fdb29c9ae65e7fd 17119: Merge branch 'master' into 17119-add-filter-groups Arvados-DCO-1.1-Signed-off-by: Ward Vandewege --- diff --git a/apps/workbench/app/assets/javascripts/components/search.js b/apps/workbench/app/assets/javascripts/components/search.js index fc63086780..83ed1a68d4 100644 --- a/apps/workbench/app/assets/javascripts/components/search.js +++ b/apps/workbench/app/assets/javascripts/components/search.js @@ -127,6 +127,12 @@ window.Search = { filters: [['group_class', '=', 'project']], description: 'project', }, + { + wb_path: 'projects', + api_path: 'arvados/v1/groups', + filters: [['group_class', '=', 'filter']], + description: 'project', + }, { wb_path: 'collections', api_path: 'arvados/v1/collections', diff --git a/apps/workbench/app/controllers/actions_controller.rb b/apps/workbench/app/controllers/actions_controller.rb index 885f539363..b0b7a0b64d 100644 --- a/apps/workbench/app/controllers/actions_controller.rb +++ b/apps/workbench/app/controllers/actions_controller.rb @@ -34,7 +34,7 @@ class ActionsController < ApplicationController @object.link_class == 'name' and ArvadosBase::resource_class_for_uuid(@object.head_uuid) == Collection redirect_to collection_path(id: @object.uuid) - elsif @object.is_a?(Group) and @object.group_class == 'project' + elsif @object.is_a?(Group) and (@object.group_class == 'project' or @object.group_class == 'filter') redirect_to project_path(id: @object.uuid) elsif @object redirect_to @object diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index 6d139cd5fd..04055f8485 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -95,7 +95,7 @@ class ApplicationController < ActionController::Base # exception here than in a template.) unless current_user.nil? begin - my_starred_projects current_user + my_starred_projects current_user, 'project' build_my_wanted_projects_tree current_user rescue ArvadosApiClient::ApiError # Fall back to the default-setting code later. @@ -239,7 +239,7 @@ class ApplicationController < ActionController::Base if objects.respond_to?(:result_offset) and objects.respond_to?(:result_limit) next_offset = objects.result_offset + objects.result_limit - if objects.respond_to?(:items_available) and (next_offset < objects.items_available) + if objects.respond_to?(:items_available) and (objects.items_available != nil) and (next_offset < objects.items_available) next_offset elsif @objects.results.size > 0 and (params[:count] == 'none' or (params[:controller] == 'search' and params[:action] == 'choose')) @@ -824,7 +824,7 @@ class ApplicationController < ActionController::Base helper_method :all_projects def all_projects @all_projects ||= Group. - filter([['group_class','=','project']]).order('name') + filter([['group_class','IN',['project','filter']]]).order('name') end helper_method :my_projects @@ -925,13 +925,17 @@ class ApplicationController < ActionController::Base end helper_method :my_starred_projects - def my_starred_projects user + def my_starred_projects user, group_class return if defined?(@starred_projects) && @starred_projects links = Link.filter([['owner_uuid', 'in', ["#{Rails.configuration.ClusterID}-j7d0g-publicfavorites", user.uuid]], ['link_class', '=', 'star'], ['head_uuid', 'is_a', 'arvados#group']]).with_count("none").select(%w(head_uuid)) uuids = links.collect { |x| x.head_uuid } - starred_projects = Group.filter([['uuid', 'in', uuids]]).order('name').with_count("none") + if group_class == "" + starred_projects = Group.filter([['uuid', 'in', uuids]]).order('name').with_count("none") + else + starred_projects = Group.filter([['uuid', 'in', uuids],['group_class', '=', group_class]]).order('name').with_count("none") + end @starred_projects = starred_projects.results end @@ -949,7 +953,7 @@ class ApplicationController < ActionController::Base @too_many_projects = false @reached_level_limit = false while from_top.size <= page_size*2 - current_level = Group.filter([['group_class','=','project'], + current_level = Group.filter([['group_class','IN',['project','filter']], ['owner_uuid', 'in', uuids]]) .order('name').limit(page_size*2) break if current_level.results.size == 0 diff --git a/apps/workbench/app/controllers/groups_controller.rb b/apps/workbench/app/controllers/groups_controller.rb index 5da55be0b5..6abd2ff11d 100644 --- a/apps/workbench/app/controllers/groups_controller.rb +++ b/apps/workbench/app/controllers/groups_controller.rb @@ -4,7 +4,7 @@ class GroupsController < ApplicationController def index - @groups = Group.filter [['group_class', '!=', 'project']] + @groups = Group.filter [['group_class', '!=', 'project'], ['group_class', '!=', 'filter']] @group_uuids = @groups.collect &:uuid @links_from = Link.where(link_class: 'permission', tail_uuid: @group_uuids).with_count("none") @links_to = Link.where(link_class: 'permission', head_uuid: @group_uuids).with_count("none") @@ -12,7 +12,7 @@ class GroupsController < ApplicationController end def show - if @object.group_class == 'project' + if @object.group_class == 'project' or @object.group_class == 'filter' redirect_to(project_path(@object)) else super diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb index 786716eb33..f22ab50166 100644 --- a/apps/workbench/app/helpers/application_helper.rb +++ b/apps/workbench/app/helpers/application_helper.rb @@ -176,7 +176,7 @@ module ApplicationHelper raw(link_name) else controller_class = resource_class.to_s.tableize - if controller_class.eql?('groups') and object.andand.group_class.eql?('project') + if controller_class.eql?('groups') and (object.andand.group_class.eql?('project') or object.andand.group_class.eql?('filter')) controller_class = 'projects' end (link_to raw(link_name), { controller: controller_class, action: 'show', id: ((opts[:name_link].andand.uuid) || link_uuid) }, style_opts) + raw(tags) diff --git a/apps/workbench/app/models/group.rb b/apps/workbench/app/models/group.rb index 08b13bf34b..ea3da2db5e 100644 --- a/apps/workbench/app/models/group.rb +++ b/apps/workbench/app/models/group.rb @@ -20,6 +20,13 @@ class Group < ArvadosBase ret end + def editable? + if group_class == 'filter' + return false + end + super + end + def contents params={} res = arvados_api_client.api self.class, "/#{self.uuid}/contents", { _method: 'GET' @@ -30,7 +37,7 @@ class Group < ArvadosBase end def class_for_display - group_class == 'project' ? 'Project' : super + (group_class == 'project' or group_class == 'filter') ? 'Project' : super end def textile_attributes diff --git a/apps/workbench/app/views/application/_projects_tree_menu.html.erb b/apps/workbench/app/views/application/_projects_tree_menu.html.erb index 08d3b81110..805d5279cc 100644 --- a/apps/workbench/app/views/application/_projects_tree_menu.html.erb +++ b/apps/workbench/app/views/application/_projects_tree_menu.html.erb @@ -2,7 +2,7 @@ SPDX-License-Identifier: AGPL-3.0 %> -<% starred_projects = my_starred_projects current_user%> +<% starred_projects = my_starred_projects current_user, '' %> <% if starred_projects.andand.any? %>