From e8f24b18e2a875e9229c5aba22e711f6cda3b4b7 Mon Sep 17 00:00:00 2001 From: Mojca Lorber Date: Tue, 10 Sep 2019 11:20:18 +0200 Subject: [PATCH] Fix missing icon on shared inventories in global search --- app/controllers/search_controller.rb | 5 ++--- app/helpers/inventories_helper.rb | 2 +- app/views/search/index.html.erb | 6 +----- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index d872897df..4c04fa795 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -129,14 +129,13 @@ class SearchController < ApplicationController current_user.teams.includes(:repositories).each do |team| team_results = {} + team_results[:team] = team team_results[:count] = 0 team_results[:repositories] = {} Repository.accessible_by_teams(team).each do |repository| repository_results = {} repository_results[:id] = repository.id - if (shared_repo = repository.team_repositories.where(team: team).take) - repository_results[:shared] = shared_repo[:permission_level] - end + repository_results[:repository] = repository repository_results[:count] = 0 search_results.each do |result| if repository.id == result.id diff --git a/app/helpers/inventories_helper.rb b/app/helpers/inventories_helper.rb index c1a02fb2b..7c1f31e8a 100644 --- a/app/helpers/inventories_helper.rb +++ b/app/helpers/inventories_helper.rb @@ -11,7 +11,7 @@ module InventoriesHelper else # The icon should be hiden if repo is not shared (we're updating it dinamically) css_classes = ["repository-share-status"] - css_classes.push("hidden") unless inventory.i_shared?(current_team) + css_classes.push("hidden") unless inventory.i_shared?(team) css_title = t('repositories.icon_title.i_shared') content_tag :span, title: css_title, class: css_classes.join(" ") do diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb index 1c39707e1..1290ff54d 100644 --- a/app/views/search/index.html.erb +++ b/app/views/search/index.html.erb @@ -233,11 +233,7 @@ search_id: @search_id}.to_query %>"> <%= values[:count] %> <%= repository %> - <% if values[:shared] == 'write' %> - <%= draw_custom_icon('shared-edit') %> - <% elsif values[:shared] == 'read' %> - <%= draw_custom_icon('shared-read') %> - <% end %> + <%= inventory_shared_status_icon(values[:repository], results[:team]) %> <% end %>