Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions app/views/header/projects/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,21 @@ See COPYRIGHT and LICENSE files for more details.
test_selector: "op-header-project-select--list" }
)
) do |tree| %>
<% @tree.each do |node| %>
<%= render Header::Projects::NodeComponent.new(
component: tree,
node:,
current_project_id: @current_project_id,
favorited_ids: @favorited_ids,
jump: @jump
) %>
<% if @tree.empty? && params[:filter_mode] == "favorited" && params[:query].blank? %>
<% tree.with_leaf(
label: t("header.project_select_component.no_favorite_projects"),
disabled: true,
data: { test_selector: "op-header-project-select--no-favourites" }
) %>
<% else %>
<% @tree.each do |node| %>
<%= render Header::Projects::NodeComponent.new(
component: tree,
node:,
current_project_id: @current_project_id,
favorited_ids: @favorited_ids,
jump: @jump
) %>
<% end %>
<% end %>
<% end %>
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3608,6 +3608,7 @@ en:
all_projects: "All projects"
favorites: "Favorites"
leave_project: "Leave project"
no_favorite_projects: "You have no favorite projects."
title: "Projects"

toggle_switch:
Expand Down
15 changes: 15 additions & 0 deletions spec/controllers/header/projects_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
end

describe "#index" do
render_views
shared_let(:parent_project) { create(:project, name: "Alpha Parent") }
shared_let(:child_project) { create(:project, name: "Beta Child", parent: parent_project) }
shared_let(:other_project) { create(:project, name: "Gamma Other") }
Expand Down Expand Up @@ -117,6 +118,20 @@
make_request
expect(assigns(:projects)).to be_empty
end

it "renders the no-favourites placeholder" do
make_request
expect(response.body).to include("op-header-project-select--no-favourites")
end

context "when a query is present" do
subject(:make_request) { get :index, params: { filter_mode: "favorited", query: "Alpha" } }

it "does not render the no-favourites placeholder" do
make_request
expect(response.body).not_to include("op-header-project-select--no-favourites")
end
end
end

context "when the user is anonymous" do
Expand Down
Loading