OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#47019] Replace LdapGroups cells by ViewComponent
Dombi Attila9c5ce904fc8d
diff --git a/modules/ldap_groups/app/cells/ldap_groups/memberships/row_cell.rb b/modules/ldap_groups/app/cells/ldap_groups/memberships/row_cell.rbdeleted file mode 100644index 390740142cd..00000000000--- a/modules/ldap_groups/app/cells/ldap_groups/memberships/row_cell.rb+++ /dev/null@@ -1,19 +0,0 @@-module LdapGroups- module Memberships- class RowCell < ::RowCell- include ::OpenProject::ObjectLinking-- def membership- model- end-- def user- link_to_user(membership.user)- end-- def added- format_date(membership.updated_at)- end- end- end-enddiff --git a/modules/ldap_groups/app/cells/ldap_groups/memberships/table_cell.rb b/modules/ldap_groups/app/cells/ldap_groups/memberships/table_cell.rbdeleted file mode 100644index a14022ecef5..00000000000--- a/modules/ldap_groups/app/cells/ldap_groups/memberships/table_cell.rb+++ /dev/null@@ -1,26 +0,0 @@-module LdapGroups- module Memberships- class TableCell < ::TableCell- columns :user, :added-- def initial_sort- %i[created_at asc]- end-- def sortable?- false- end-- def empty_row_message- I18n.t 'ldap_groups.synchronized_groups.no_members'- end-- def headers- [- ['user', { caption: ::LdapGroups::Membership.human_attribute_name('user') }],- ['added', { caption: ::LdapGroups::Membership.human_attribute_name('created_at') }]- ]- end- end- end-enddiff --git a/modules/ldap_groups/app/cells/ldap_groups/synchronized_filters/row_cell.rb b/modules/ldap_groups/app/cells/ldap_groups/synchronized_filters/row_cell.rbdeleted file mode 100644index 425442470b6..00000000000--- a/modules/ldap_groups/app/cells/ldap_groups/synchronized_filters/row_cell.rb+++ /dev/null@@ -1,51 +0,0 @@-module LdapGroups- module SynchronizedFilters- class RowCell < ::RowCell- include ::IconsHelper- include ::PasswordHelper-- def synchronized_filter- model- end-- def name- link_to synchronized_filter.name, ldap_groups_synchronized_filter_path(synchronized_filter)- end-- def auth_source- link_to synchronized_filter.auth_source.name, edit_ldap_auth_source_path(synchronized_filter.auth_source)- end-- delegate :base_dn, to: :synchronized_filter-- def groups- synchronized_filter.groups.count- end-- def sync_users- checked_image synchronized_filter.sync_users- end-- def button_links- [- edit_link,- delete_link- ]- end-- def edit_link- link_to I18n.t(:button_edit),- { controller: table.target_controller, ldap_filter_id: model.id, action: :edit },- class: 'icon icon-edit',- title: t(:button_edit)- end-- def delete_link- link_to I18n.t(:button_delete),- { controller: table.target_controller, ldap_filter_id: model.id, action: :destroy_info },- class: 'icon icon-delete',- title: t(:button_delete)- end- end- end-enddiff --git a/modules/ldap_groups/app/cells/ldap_groups/synchronized_filters/table_cell.rb b/modules/ldap_groups/app/cells/ldap_groups/synchronized_filters/table_cell.rbdeleted file mode 100644index a014d20babf..00000000000--- a/modules/ldap_groups/app/cells/ldap_groups/synchronized_filters/table_cell.rb+++ /dev/null@@ -1,36 +0,0 @@-module LdapGroups- module SynchronizedFilters- class TableCell < ::TableCell- columns :name, :auth_source, :groups, :sync_users-- def initial_sort- %i[id asc]- end-- def target_controller- 'ldap_groups/synchronized_filters'- end-- def sortable?- false- end-- def inline_create_link- link_to({ controller: target_controller, action: :new },- class: 'budget-add-row wp-inline-create--add-link',- title: I18n.t('ldap_groups.synchronized_filters.add_new')) do- op_icon('icon icon-add')- end- end-- def headers- [- ['name', { caption: ::LdapGroups::SynchronizedFilter.human_attribute_name('name') }],- ['auth_source', { caption: ::LdapGroups::SynchronizedFilter.human_attribute_name('auth_source') }],- ['groups', { caption: I18n.t('ldap_groups.synchronized_groups.plural') }],- ['sync_users', { caption: ::LdapGroups::SynchronizedFilter.human_attribute_name('sync_users') }]- ]- end- end- end-enddiff --git a/modules/ldap_groups/app/cells/ldap_groups/synchronized_groups/row_cell.rb b/modules/ldap_groups/app/cells/ldap_groups/synchronized_groups/row_cell.rbdeleted file mode 100644index 6880c539625..00000000000--- a/modules/ldap_groups/app/cells/ldap_groups/synchronized_groups/row_cell.rb+++ /dev/null@@ -1,45 +0,0 @@-module LdapGroups- module SynchronizedGroups- class RowCell < ::RowCell- include ::IconsHelper- include ::PasswordHelper-- def synchronized_group- model- end-- def dn- link_to synchronized_group.dn, ldap_groups_synchronized_group_path(synchronized_group)- end-- def auth_source- link_to synchronized_group.auth_source.name, edit_ldap_auth_source_path(synchronized_group.auth_source)- end-- def group- link_to synchronized_group.group.name, edit_group_path(synchronized_group.group)- end-- def sync_users- checked_image synchronized_group.sync_users- end-- def users- synchronized_group.users.size- end-- def button_links- [delete_link].compact- end-- def delete_link- return if table.options[:deletable] == false-- link_to I18n.t(:button_delete),- { controller: table.target_controller, ldap_group_id: model.id, action: :destroy_info },- class: 'icon icon-delete',- title: t(:button_delete)- end- end- end-enddiff --git a/modules/ldap_groups/app/cells/ldap_groups/synchronized_groups/table_cell.rb b/modules/ldap_groups/app/cells/ldap_groups/synchronized_groups/table_cell.rbdeleted file mode 100644index 75cfe3847d9..00000000000--- a/modules/ldap_groups/app/cells/ldap_groups/synchronized_groups/table_cell.rb+++ /dev/null@@ -1,45 +0,0 @@-module LdapGroups- module SynchronizedGroups- class TableCell < ::TableCell- columns :dn, :auth_source, :group, :users, :sync_users-- def initial_sort- %i[id asc]- end-- def target_controller- 'ldap_groups/synchronized_groups'- end-- def sortable?- true- end-- def sortable_column?(_column)- false- end-- def inline_create_link- link_to({ controller: target_controller, action: :new },- class: 'budget-add-row wp-inline-create--add-link',- title: I18n.t('ldap_groups.synchronized_groups.add_new')) do- op_icon('icon icon-add')- end- end-- def empty_row_message- I18n.t 'ldap_groups.synchronized_groups.no_results'- end-- def headers- [- ['dn', { caption: ::LdapGroups::SynchronizedGroup.human_attribute_name('dn') }],- ['auth_source', { caption: ::LdapGroups::SynchronizedGroup.human_attribute_name('auth_source') }],- ['group', { caption: I18n.t(:label_group) }],- ['users', { caption: I18n.t(:label_user_plural) }],- ['sync_users', { caption: ::LdapGroups::SynchronizedFilter.human_attribute_name('sync_users') }]- ]- end- end- end-enddiff --git a/modules/ldap_groups/app/components/ldap_groups/memberships/row_component.rb b/modules/ldap_groups/app/components/ldap_groups/memberships/row_component.rbnew file mode 100644index 00000000000..34b16c0f32d--- /dev/null+++ b/modules/ldap_groups/app/components/ldap_groups/memberships/row_component.rb@@ -0,0 +1,49 @@+# frozen_string_literal: true++#-- 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 LdapGroups+ module Memberships+ class RowComponent < ::RowComponent+ include ::OpenProject::ObjectLinking++ def membership+ model+ end++ def user+ link_to_user(membership.user)+ end++ def added+ format_date(membership.updated_at)+ end+ end+ end+enddiff --git a/modules/ldap_groups/app/components/ldap_groups/memberships/table_component.rb b/modules/ldap_groups/app/components/ldap_groups/memberships/table_component.rbnew file mode 100644index 00000000000..cc5c1a87a0a--- /dev/null+++ b/modules/ldap_groups/app/components/ldap_groups/memberships/table_component.rb@@ -0,0 +1,56 @@+# frozen_string_literal: true++#-- 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 LdapGroups+ module Memberships+ class TableComponent < ::TableComponent+ columns :user, :added++ def initial_sort+ %i[created_at asc]+ end++ def sortable?+ false+ end++ def empty_row_message+ I18n.t 'ldap_groups.synchronized_groups.no_members'+ end++ def headers+ [+ ['user', { caption: ::LdapGroups::Membership.human_attribute_name('user') }],+ ['added', { caption: ::LdapGroups::Membership.human_attribute_name('created_at') }]+ ]+ end+ end+ end+enddiff --git a/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/row_component.rb b/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/row_component.rbnew file mode 100644index 00000000000..6bc1b250095--- /dev/null+++ b/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/row_component.rb@@ -0,0 +1,81 @@+# frozen_string_literal: true++#-- 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 LdapGroups+ module SynchronizedFilters+ class RowComponent < ::RowComponent+ include ::IconsHelper+ include ::PasswordHelper++ def synchronized_filter+ model+ end++ def name+ link_to synchronized_filter.name, ldap_groups_synchronized_filter_path(synchronized_filter)+ end++ def auth_source+ link_to synchronized_filter.auth_source.name, edit_ldap_auth_source_path(synchronized_filter.auth_source)+ end++ delegate :base_dn, to: :synchronized_filter++ def groups+ synchronized_filter.groups.count+ end++ def sync_users+ checked_image synchronized_filter.sync_users+ end++ def button_links+ [+ edit_link,+ delete_link+ ]+ end++ def edit_link+ link_to I18n.t(:button_edit),+ { controller: table.target_controller, ldap_filter_id: model.id, action: :edit },+ class: 'icon icon-edit',+ title: t(:button_edit)+ end++ def delete_link+ link_to I18n.t(:button_delete),+ { controller: table.target_controller, ldap_filter_id: model.id, action: :destroy_info },+ class: 'icon icon-delete',+ title: t(:button_delete)+ end+ end+ end+enddiff --git a/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/table_component.rb b/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/table_component.rbnew file mode 100644index 00000000000..6589f0679d8--- /dev/null+++ b/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/table_component.rb@@ -0,0 +1,66 @@+# frozen_string_literal: true++#-- 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 LdapGroups+ module SynchronizedFilters+ class TableComponent < ::TableComponent+ columns :name, :auth_source, :groups, :sync_users++ def initial_sort+ %i[id asc]+ end++ def target_controller+ 'ldap_groups/synchronized_filters'+ end++ def sortable?+ false+ end++ def inline_create_link+ link_to({ controller: target_controller, action: :new },+ class: 'budget-add-row wp-inline-create--add-link',+ title: I18n.t('ldap_groups.synchronized_filters.add_new')) do+ op_icon('icon icon-add')+ end+ end++ def headers+ [+ ['name', { caption: ::LdapGroups::SynchronizedFilter.human_attribute_name('name') }],+ ['auth_source', { caption: ::LdapGroups::SynchronizedFilter.human_attribute_name('auth_source') }],+ ['groups', { caption: I18n.t('ldap_groups.synchronized_groups.plural') }],+ ['sync_users', { caption: ::LdapGroups::SynchronizedFilter.human_attribute_name('sync_users') }]+ ]+ end+ end+ end+enddiff --git a/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/row_component.rb b/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/row_component.rbnew file mode 100644index 00000000000..b35088ec175--- /dev/null+++ b/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/row_component.rb@@ -0,0 +1,75 @@+# frozen_string_literal: true++#-- 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 LdapGroups+ module SynchronizedGroups+ class RowComponent < ::RowComponent+ include ::IconsHelper+ include ::PasswordHelper++ def synchronized_group+ model+ end++ def dn+ link_to synchronized_group.dn, ldap_groups_synchronized_group_path(synchronized_group)+ end++ def auth_source+ link_to synchronized_group.auth_source.name, edit_ldap_auth_source_path(synchronized_group.auth_source)+ end++ def group+ link_to synchronized_group.group.name, edit_group_path(synchronized_group.group)+ end++ def sync_users+ checked_image synchronized_group.sync_users+ end++ def users+ synchronized_group.users.size+ end++ def button_links+ [delete_link].compact+ end++ def delete_link+ return if table.options[:deletable] == false++ link_to I18n.t(:button_delete),+ { controller: table.target_controller, ldap_group_id: model.id, action: :destroy_info },+ class: 'icon icon-delete',+ title: t(:button_delete)+ end+ end+ end+enddiff --git a/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/table_component.rb b/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/table_component.rbnew file mode 100644index 00000000000..7b8a78e4540--- /dev/null+++ b/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/table_component.rb@@ -0,0 +1,75 @@+# frozen_string_literal: true++#-- 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 LdapGroups+ module SynchronizedGroups+ class TableComponent < ::TableComponent+ columns :dn, :auth_source, :group, :users, :sync_users++ def initial_sort+ %i[id asc]+ end++ def target_controller+ 'ldap_groups/synchronized_groups'+ end++ def sortable?+ true+ end++ def sortable_column?(_column)+ false+ end++ def inline_create_link+ link_to({ controller: target_controller, action: :new },+ class: 'budget-add-row wp-inline-create--add-link',+ title: I18n.t('ldap_groups.synchronized_groups.add_new')) do+ op_icon('icon icon-add')+ end+ end++ def empty_row_message+ I18n.t 'ldap_groups.synchronized_groups.no_results'+ end++ def headers+ [+ ['dn', { caption: ::LdapGroups::SynchronizedGroup.human_attribute_name('dn') }],+ ['auth_source', { caption: ::LdapGroups::SynchronizedGroup.human_attribute_name('auth_source') }],+ ['group', { caption: I18n.t(:label_group) }],+ ['users', { caption: I18n.t(:label_user_plural) }],+ ['sync_users', { caption: ::LdapGroups::SynchronizedFilter.human_attribute_name('sync_users') }]+ ]+ end+ end+ end+enddiff --git a/modules/ldap_groups/app/views/ldap_groups/synchronized_filters/show.html.erb b/modules/ldap_groups/app/views/ldap_groups/synchronized_filters/show.html.erbindex b4a78bb0dd7..8502e55d4de 100644--- a/modules/ldap_groups/app/views/ldap_groups/synchronized_filters/show.html.erb+++ b/modules/ldap_groups/app/views/ldap_groups/synchronized_filters/show.html.erb@@ -73,6 +73,6 @@<% end %></li><% end %>- <%= rails_cell ::LdapGroups::SynchronizedGroups::TableCell, @filter.groups, show_inline_create: false, deletable: false %>+ <%= render ::LdapGroups::SynchronizedGroups::TableComponent.new(rows: @filter.groups, show_inline_create: false, deletable: false) %></section>diff --git a/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/index.html.erb b/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/index.html.erbindex b770c40d4e5..cfc3727d02e 100644--- a/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/index.html.erb+++ b/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/index.html.erb@@ -31,11 +31,11 @@<section class="admin--edit-section"><h3 class="form--section-title"><%= t('ldap_groups.synchronized_filters.plural') %></h3>- <%= rails_cell ::LdapGroups::SynchronizedFilters::TableCell, @filters %>+ <%= render ::LdapGroups::SynchronizedFilters::TableComponent.new(rows: @filters) %></section><section class="admin--edit-section"><h3 class="form--section-title"><%= t('ldap_groups.synchronized_groups.plural') %></h3>- <%= rails_cell ::LdapGroups::SynchronizedGroups::TableCell, @groups %>+ <%= render ::LdapGroups::SynchronizedGroups::TableComponent.new(rows: @groups) %></section>diff --git a/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/show.html.erb b/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/show.html.erbindex 9d7934c4036..d45c93202da 100644--- a/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/show.html.erb+++ b/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/show.html.erb@@ -38,6 +38,6 @@<section class="admin--edit-section"><h2><%= t :label_user_plural %></h2>- <%= rails_cell ::LdapGroups::Memberships::TableCell, @group.users %>+ <%= render ::LdapGroups::Memberships::TableComponent.new(rows: @group.users) %></section>