Skip to content

Commit

Permalink
Merge pull request #13725 from opf/meeting-agendas-merge
Browse files Browse the repository at this point in the history
Meeting agendas merge
  • Loading branch information
oliverguenther authored Sep 20, 2023
2 parents ccb4b9e + fbee3b0 commit 5d5b5f9
Show file tree
Hide file tree
Showing 127 changed files with 5,702 additions and 97 deletions.
9 changes: 5 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ gem 'view_component'
# Lookbook
gem 'lookbook', '~> 2.0.5'

# Require factory_bot for usage with openproject plugins testing
gem 'factory_bot', '~> 6.2.0', require: false
# require factory_bot_rails for convenience in core development
gem 'factory_bot_rails', '~> 6.2.0', require: false

gem 'turbo-rails', "~> 1.1"

group :test do
Expand Down Expand Up @@ -288,10 +293,6 @@ end

group :development, :test do
gem 'dotenv-rails'
# Require factory_bot for usage with openproject plugins testing
gem 'factory_bot', '~> 6.2.0'
# require factory_bot_rails for convenience in core development
gem 'factory_bot_rails', '~> 6.2.0'

# Tracing and profiling gems
gem 'flamegraph', require: false
Expand Down
124 changes: 124 additions & 0 deletions app/components/concerns/op_turbo/streamable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 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 OpTurbo
module Streamable
extend ActiveSupport::Concern

class_methods do
def wrapper_key
name.underscore.gsub("/", "-").gsub("_", "-")
end
end

included do
def render_as_turbo_stream(view_context:, action: :update)
case action
when :update
@inner_html_only = true
template = render_in(view_context)
when :replace
template = render_in(view_context)
when :remove
template = nil
else
raise "Unsupported action #{action}"
end

unless @component_wrapper_used
raise "You need to wrap your component in a `component_wrapper` block in order to use the turbo-stream methods"
end

OpTurbo::StreamWrapperComponent.new(
action:,
target: wrapper_key,
template:
).render_in(view_context)
end

def insert_as_turbo_stream(component:, view_context:, action: :append)
template = component.render_in(view_context)

unless @component_wrapper_used
raise "You need to wrap your component in a `component_wrapper` block in order to use the turbo-stream methods"
end

OpTurbo::StreamWrapperComponent.new(
action:,
target: insert_target_modified? ? insert_target_modifier_id : wrapper_key,
template:
).render_in(view_context)
end

def component_wrapper(tag: "div", class: nil, data: nil, style: nil, &block)
@component_wrapper_used = true
if inner_html_only?
capture(&block)
else
content_tag(tag, id: wrapper_key, class:, data:, style:, &block)
end
end

def inner_html_only?
@inner_html_only == true
end

def wrapper_key
if wrapper_uniq_by.nil?
self.class.wrapper_key
else
"#{self.class.wrapper_key}-#{wrapper_uniq_by}"
end
end

def wrapper_uniq_by
# optionally implemented in subclass in order to make the wrapper key unique
end

def insert_target_modified?
# optionally overriden (returning true) in subclass in order to indicate thate the insert target
# is modified and should not be the root inner html element
# insert_target_container needs to be present on component's erb template then
false
end

def insert_target_container(tag: "div", class: nil, data: nil, style: nil, &block)
unless insert_target_modified?
raise "`insert_target_modified?` needs to be implemented and return true if `insert_target_container` is " \
"used in this component"
end

content_tag(tag, id: insert_target_modifier_id, class:, data:, style:, &block)
end

def insert_target_modifier_id
"#{wrapper_key}-insert-target-modifier"
end
end
end
end
4 changes: 1 addition & 3 deletions app/components/members/row_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def row_css_class
end

def name
icon = helpers.avatar principal, size: :mini

icon + principal_link
render Users::AvatarComponent.new(user: principal, size: :mini, link: true, show_name: true)
end

def mail
Expand Down
33 changes: 33 additions & 0 deletions app/components/op_primer/box_collection_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 2012-2023 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.
++#%>
<% if boxes.any? %>
<% boxes.each do |box| %>
<%= box %>
<% end %>
<% end %>
41 changes: 41 additions & 0 deletions app/components/op_primer/box_collection_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 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 OpPrimer
class BoxCollectionComponent < Primer::Component
def initialize(**)
super

@system_arguments = deny_tag_argument(**) || {}
end

renders_many :boxes, lambda { |**system_arguments|
Primer::Box.new(**system_arguments || {})
}
end
end
33 changes: 33 additions & 0 deletions app/components/op_primer/component_collection_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 2012-2023 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.
++#%>
<% if components.any? %>
<% components.each do |component| %>
<%= component %>
<% end %>
<% end %>
41 changes: 41 additions & 0 deletions app/components/op_primer/component_collection_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 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 OpPrimer
class ComponentCollectionComponent < Primer::Component
def initialize(**)
super

@system_arguments = deny_tag_argument(**) || {}
end

renders_many :components, lambda { |component_instance|
component_instance
}
end
end
43 changes: 43 additions & 0 deletions app/components/op_primer/component_helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 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 OpPrimer
module ComponentHelpers
def flex_layout(**, &)
render(OpPrimer::FlexLayoutComponent.new(**), &)
end

def box_collection(**, &)
render(OpPrimer::BoxCollectionComponent.new(**), &)
end

def component_collection(**, &)
render(OpPrimer::ComponentCollectionComponent.new(**), &)
end
end
end
Loading

0 comments on commit 5d5b5f9

Please sign in to comment.