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
1 change: 1 addition & 0 deletions app/components/_index.sass
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
@import "work_packages/progress/modal_body_component"
@import "work_packages/reminder/modal_body_component"
@import "work_packages/split_view_component"
@import "header/project_select_component"
@import "homescreen/link_component"
@import "homescreen/links_component"
@import "homescreen/new_features_component"
61 changes: 61 additions & 0 deletions app/components/header/project_select_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) the OpenProject GmbH

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.

OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

See COPYRIGHT and LICENSE files for more details.

++#%>

<%= render(
Primer::Alpha::Overlay.new(
title: t(".title"),
visually_hide_title: true,
anchor_side: :outside_bottom,
anchor_align: :start,
size: :medium_portrait,
padding: :none

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no right padding?

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What browser is that? The FilterableTreeViewTreeContainer should itself add some right side padding via the scrollbar-gutter

Bildschirmfoto 2026-06-02 um 08 39 05

)
) do |overlay| %>
<% overlay.with_show_button(
id: "projects-menu",
classes: "op-project-select--trigger-button",
scheme: :invisible,
data: { "test-selector": "op-projects-menu" },
accesskey: "5"
) do |button| %>
<%= trigger_label %>
<% button.with_trailing_visual_icon(icon: :"triangle-down") %>
<% end %>

<% overlay.with_body(
classes: "op-project-select--body", data: { controller: "header-project-select",
test_selector: "op-header-project-select" }
) do %>
<%= helpers.turbo_frame_tag "op-header-project-frame",
src: tree_src,
loading: :lazy,
target: "_top",
class: "op-project-select--frame" %>
<% end %>
<% end %>
59 changes: 59 additions & 0 deletions app/components/header/project_select_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++

module Header
class ProjectSelectComponent < ApplicationComponent
include OpenProject::StaticRouting::UrlHelpers

delegate :logged?, to: :@current_user

def initialize(current_project: nil, current_menu_item: nil, current_user: User.current)
super()
@current_project = current_project
@current_user = current_user
@current_menu_item = current_menu_item
end

def trigger_label
@current_project&.name || t(".all_projects")
end

def tree_src
frame_header_projects_path(
current_project_id: @current_project&.id,
jump: @current_menu_item.presence
)
end

def can_create_projects?
@current_user.allowed_globally?(:add_project)
end
end
end
46 changes: 46 additions & 0 deletions app/components/header/project_select_component.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//-- copyright
// OpenProject is an open source project management software.
// Copyright (C) the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See COPYRIGHT and LICENSE files for more details.
//++

.op-project-select
&--body
display: flex
max-height: 75dvh
overflow: hidden
margin: var(--base-size-16)
margin-right: 0

&--frame
max-height: 100%
flex-basis: 100%

&--trigger-button
min-width: unset
display: block

.Button-label
@include text-shortener
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) the OpenProject GmbH

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.

OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

See COPYRIGHT and LICENSE files for more details.

++#%>

<%= helpers.turbo_frame_tag "op-header-project-frame", class: "op-project-select--frame" do %>
<%= render(
Primer::OpenProject::FilterableTreeView.new(
src: tree_src,
include_sub_items_check_box_arguments: { hidden: true },
filter_mode_control_arguments: logged? ? {} : { hidden: true },
filter_input_arguments: { name: "filter",
label: t(:label_filter),
visually_hide_label: true,
data: { test_selector: "op-header-project-select--search" } },
no_results_node_arguments: { data: { test_selector: "op-header-project-select--no-results" },
label: I18n.t("filterable_tree_view.no_results_text") }
)
) do |tree_view| %>
<% if logged? %>
<% tree_view.with_filter_mode(
name: "all",
label: t("filterable_tree_view.filter_mode.all"),
selected: @filter_mode != "favorited"
) %>
<% tree_view.with_filter_mode(
name: "favorited",
label: t("header.project_select_component.favorites"),
selected: @filter_mode == "favorited"
) %>
<% end %>
<% end %>
<% end %>
52 changes: 52 additions & 0 deletions app/components/header/projects/filterable_tree_view_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++

module Header
module Projects
class FilterableTreeViewComponent < ApplicationComponent
def initialize(current_project_id:, jump:, filter_mode:)
super()
@current_project_id = current_project_id
@jump = jump
@filter_mode = filter_mode
end

private

def tree_src
helpers.header_projects_path(current_project_id: @current_project_id, jump: @jump.presence)
end

def logged?
helpers.current_user.logged?
end
end
end
end
75 changes: 75 additions & 0 deletions app/components/header/projects/node_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) the OpenProject GmbH

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.

OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

See COPYRIGHT and LICENSE files for more details.

++#%>

<% add_icons = ->(tree_node) do
if current?
tree_node.with_trailing_action_button(
icon: :"x-circle",
tag: :a,
href: home_path(jump: @jump),
show_tooltip: false,
aria: { label: t("header.project_select_component.leave_project") },
data: { test_selector: "op-header-project-select--remove-item" }
)
Comment thread
HDinger marked this conversation as resolved.
end
end %>

<% if children.any? %>
<% @component.with_sub_tree(
label:,
select_variant: :none,
current: current?,
expanded: expanded?,
href:,
disabled: !matches_query?,
data: { node_id: project.id, test_selector: "op-header-project-select--item" }
) do |sub| %>
<% add_icons.call(sub) %>
<% children.each do |child_node| %>
<%= render Header::Projects::NodeComponent.new(
component: sub,
node: child_node,
current_project_id: @current_project_id,
favorited_ids: @favorited_ids,
jump: @jump
) %>
<% end %>
<% end %>
<% else %>
<% @component.with_leaf(
label:,
select_variant: :none,
current: current?,
href:,
disabled: !matches_query?,
data: { node_id: project.id, test_selector: "op-header-project-select--item" }
) do |leaf| %>
<% add_icons.call(leaf) %>
<% end %>
<% end %>
Loading
Loading