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
Extract permission button into own component
Henriette Dargeb4679c3be92e
diff --git a/app/components/work_packages/share/modal_component.html.erb b/app/components/work_packages/share/modal_component.html.erbindex 4e9d3e49da0..4ce5f61e7e3 100644--- a/app/components/work_packages/share/modal_component.html.erb+++ b/app/components/work_packages/share/modal_component.html.erb@@ -9,16 +9,7 @@endnew_user_row.with_column(mr: 2) do- # Todo: Extract into own component- render(Primer::Alpha::ActionMenu.new) do |component|- component.with_show_button(color: :subtle) do |button|- button.with_trailing_action_icon(icon: :"triangle-down")- I18n.t('work_package.sharing.permissions.comment')- end- component.with_item(label: I18n.t('work_package.sharing.permissions.comment'))- component.with_item(label: I18n.t('work_package.sharing.permissions.edit'))- component.with_item(label: I18n.t('work_package.sharing.permissions.view'))- end+ render(WorkPackages::Share::PermissionButtonComponent.new(shown_value: I18n.t('work_package.sharing.permissions.comment')))endnew_user_row.with_column do@@ -33,7 +24,6 @@modal_content.with_row(mt: 3) dorender(Primer::Beta::BorderBox.new) do |invited_user_list|invited_user_list.with_header(color: :subtle) do- # Todo: Show actual countI18n.t('work_package.sharing.count', count: @shared_users.count)end@@ -45,16 +35,8 @@enduser_row_container.with_column(color: :subtle, style: "width: 150px;") do- render(Primer::Alpha::ActionMenu.new) do |component|- component.with_show_button(color: :subtle) do |button|- button.with_trailing_action_icon(icon: :"triangle-down")- # ToDo: real permission- I18n.t('work_package.sharing.permissions.comment')- end- component.with_item(label: I18n.t('work_package.sharing.permissions.comment'))- component.with_item(label: I18n.t('work_package.sharing.permissions.edit'))- component.with_item(label: I18n.t('work_package.sharing.permissions.view'))- end+ # ToDo: real permission+ render(WorkPackages::Share::PermissionButtonComponent.new(shown_value: I18n.t('work_package.sharing.permissions.comment')))enduser_row_container.with_column(text_align: :right, style: "width: 100px;") dodiff --git a/app/components/work_packages/share/permission_button_component.html.erb b/app/components/work_packages/share/permission_button_component.html.erbnew file mode 100644index 00000000000..a42fe12eb13--- /dev/null+++ b/app/components/work_packages/share/permission_button_component.html.erb@@ -0,0 +1,11 @@+<%=+ render(Primer::Alpha::ActionMenu.new) do |menu|+ menu.with_show_button(color: :subtle) do |button|+ button.with_trailing_action_icon(icon: :"triangle-down")+ @shown_value+ end+ options.each do |option|+ menu.with_item(label: option[:label], value: option[:value])+ end+ end+%>diff --git a/app/components/work_packages/share/permission_button_component.rb b/app/components/work_packages/share/permission_button_component.rbnew file mode 100644index 00000000000..053090f6be8--- /dev/null+++ b/app/components/work_packages/share/permission_button_component.rb@@ -0,0 +1,53 @@+#-- 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 WorkPackages+ module Share+ class PermissionButtonComponent < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers++ def initialize(shown_value:)+ super++ @shown_value = shown_value+ end++ private++ def options+ # Todo: Real values+ [+ { label: I18n.t('work_package.sharing.permissions.comment'), value: '' },+ { label: I18n.t('work_package.sharing.permissions.edit'), value: '' },+ { label: I18n.t('work_package.sharing.permissions.view'), value: '' }+ ]+ end+ end+ end+end