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
[#47011] Replace OAuth::TableCell by ViewComponent
Dombi Attila22e3a43eefa3
diff --git a/app/cells/oauth/applications/row_cell.rb b/app/cells/oauth/applications/row_cell.rbdeleted file mode 100644index c5866d2955d..00000000000--- a/app/cells/oauth/applications/row_cell.rb+++ /dev/null@@ -1,54 +0,0 @@-module OAuth- module Applications- class RowCell < ::RowCell- include ::IconsHelper- include ::OAuthHelper- include ::OpenProject::ObjectLinking-- def application- model- end-- def name- link_to application.name, oauth_application_path(application)- end-- def owner- link_to application.owner.name, user_path(application.owner)- end-- def confidential- if application.confidential?- op_icon 'icon icon-checkmark'- end- end-- def redirect_uri- urls = application.redirect_uri.split("\n")- safe_join urls, '<br/>'.html_safe- end-- def client_credentials- if user_id = application.client_credentials_user_id- link_to_user User.find(user_id)- else- '-'- end- end-- delegate :confidential, to: :application-- def edit_link- link_to(- I18n.t(:button_edit),- edit_oauth_application_path(application),- class: "oauth-application--edit-link icon icon-edit"- )- end-- def button_links- [edit_link, delete_link(oauth_application_path(application))]- end- end- end-enddiff --git a/app/cells/oauth/applications/table_cell.rb b/app/cells/oauth/applications/table_cell.rbdeleted file mode 100644index 48637206a10..00000000000--- a/app/cells/oauth/applications/table_cell.rb+++ /dev/null@@ -1,46 +0,0 @@-module OAuth- module Applications- class TableCell < ::TableCell- class << self- def row_class- ::OAuth::Applications::RowCell- end- end-- def initial_sort- %i[id asc]- end-- def sortable?- false- end-- def columns- headers.map(&:first)- end-- def inline_create_link- link_to new_oauth_application_path,- aria: { label: t('oauth.application.new') },- class: 'wp-inline-create--add-link',- title: t('oauth.application.new') do- op_icon('icon icon-add')- end- end-- def empty_row_message- I18n.t :no_results_title_text- end-- def headers- [- ['name', { caption: ::Doorkeeper::Application.human_attribute_name(:name) }],- ['owner', { caption: ::Doorkeeper::Application.human_attribute_name(:owner) }],- ['client_credentials', { caption: I18n.t('oauth.client_credentials') }],- ['redirect_uri', { caption: ::Doorkeeper::Application.human_attribute_name(:redirect_uri) }],- ['confidential', { caption: ::Doorkeeper::Application.human_attribute_name(:confidential) }]- ]- end- end- end-enddiff --git a/app/components/oauth/applications/row_component.rb b/app/components/oauth/applications/row_component.rbnew file mode 100644index 00000000000..375a6d5db4c--- /dev/null+++ b/app/components/oauth/applications/row_component.rb@@ -0,0 +1,84 @@+# 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 OAuth+ module Applications+ class RowComponent < ::RowComponent+ include ::IconsHelper+ include ::OAuthHelper+ include ::OpenProject::ObjectLinking++ def application+ model+ end++ def name+ link_to application.name, oauth_application_path(application)+ end++ def owner+ link_to application.owner.name, user_path(application.owner)+ end++ def confidential+ if application.confidential?+ op_icon 'icon icon-checkmark'+ end+ end++ def redirect_uri+ urls = application.redirect_uri.split("\n")+ safe_join urls, '<br/>'.html_safe+ end++ def client_credentials+ if user_id = application.client_credentials_user_id+ link_to_user User.find(user_id)+ else+ '-'+ end+ end++ delegate :confidential, to: :application++ def edit_link+ link_to(+ I18n.t(:button_edit),+ edit_oauth_application_path(application),+ class: "oauth-application--edit-link icon icon-edit"+ )+ end++ def button_links+ [edit_link, delete_link(oauth_application_path(application))]+ end+ end+ end+enddiff --git a/app/components/oauth/applications/table_component.rb b/app/components/oauth/applications/table_component.rbnew file mode 100644index 00000000000..3c26d7f2d4e--- /dev/null+++ b/app/components/oauth/applications/table_component.rb@@ -0,0 +1,76 @@+# 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 OAuth+ module Applications+ class TableComponent < ::TableComponent+ class << self+ def row_class+ ::OAuth::Applications::RowComponent+ end+ end++ def initial_sort+ %i[id asc]+ end++ def sortable?+ false+ end++ def columns+ headers.map(&:first)+ end++ def inline_create_link+ link_to new_oauth_application_path,+ aria: { label: t('oauth.application.new') },+ class: 'wp-inline-create--add-link',+ title: t('oauth.application.new') do+ op_icon('icon icon-add')+ end+ end++ def empty_row_message+ I18n.t :no_results_title_text+ end++ def headers+ [+ ['name', { caption: ::Doorkeeper::Application.human_attribute_name(:name) }],+ ['owner', { caption: ::Doorkeeper::Application.human_attribute_name(:owner) }],+ ['client_credentials', { caption: I18n.t('oauth.client_credentials') }],+ ['redirect_uri', { caption: ::Doorkeeper::Application.human_attribute_name(:redirect_uri) }],+ ['confidential', { caption: ::Doorkeeper::Application.human_attribute_name(:confidential) }]+ ]+ end+ end+ end+enddiff --git a/app/views/oauth/applications/index.html.erb b/app/views/oauth/applications/index.html.erbindex 379a81eba9b..460ddc99362 100644--- a/app/views/oauth/applications/index.html.erb+++ b/app/views/oauth/applications/index.html.erb@@ -39,4 +39,4 @@ See COPYRIGHT and LICENSE files for more details.</li><% end %>-<%= rails_cell ::OAuth::Applications::TableCell, @applications, current_user: current_user %>+<%= render ::OAuth::Applications::TableComponent.new(rows: @applications) %>