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
Add first iteration of ShareModalComponent
Henriette Dargeaa55677da865
diff --git a/app/components/work_packages/share/modal_component.html.erb b/app/components/work_packages/share/modal_component.html.erbnew file mode 100644index 00000000000..4e9d3e49da0--- /dev/null+++ b/app/components/work_packages/share/modal_component.html.erb@@ -0,0 +1,70 @@+<%=+ flex_layout(data: { turbo: true }) do |modal_content|+ modal_content.with_row do+ # Todo: Wrap in Form++ flex_layout do |new_user_row|+ new_user_row.with_column(mr: 2) do+ # Todo: Show user autocompleter+ end++ new_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+ end++ new_user_row.with_column do+ render(Primer::Beta::Button.new(scheme: :primary)) { I18n.t('work_package.sharing.invite') }+ end+ end+ end++ if @shared_users.empty?+ # Todo: show empty state?+ else+ modal_content.with_row(mt: 3) do+ render(Primer::Beta::BorderBox.new) do |invited_user_list|+ invited_user_list.with_header(color: :subtle) do+ # Todo: Show actual count+ I18n.t('work_package.sharing.count', count: @shared_users.count)+ end++ @shared_users.each do |user|+ invited_user_list.with_row do+ flex_layout(align_items: :center) do |user_row_container|+ user_row_container.with_column(flex: :auto) do+ render(Users::AvatarComponent.new(user: User.find(user), size: :medium))+ end++ user_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+ end++ user_row_container.with_column(text_align: :right, style: "width: 100px;") do+ render(Primer::Beta::Button.new(scheme: :invisible)) { I18n.t('work_package.sharing.remove') }+ end+ end+ end+ end+ end+ end+ end+ end+%>diff --git a/app/components/work_packages/share/modal_component.rb b/app/components/work_packages/share/modal_component.rbnew file mode 100644index 00000000000..2daae05fd59--- /dev/null+++ b/app/components/work_packages/share/modal_component.rb@@ -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 WorkPackages+ module Share+ class ModalComponent < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers++ def initialize(work_package:)+ super++ @work_package = work_package+ @shared_users = Member.of_work_package(@work_package.id).map(&:user_id)+ end+ end+ end+enddiff --git a/app/controllers/work_packages/shares_controller.rb b/app/controllers/work_packages/shares_controller.rbindex 7a313cda4e6..175cc3c7267 100644--- a/app/controllers/work_packages/shares_controller.rb+++ b/app/controllers/work_packages/shares_controller.rb@@ -28,5 +28,7 @@class WorkPackages::SharesController < ApplicationControllerdef index+ @work_package = WorkPackage.find(params[:id])+ render(WorkPackages::Share::ModalComponent.new(work_package: @work_package))endenddiff --git a/app/models/members/scopes/of.rb b/app/models/members/scopes/of.rbindex 7d3f225d63b..7878cf09dda 100644--- a/app/models/members/scopes/of.rb+++ b/app/models/members/scopes/of.rb@@ -35,6 +35,11 @@ module Members::Scopesdef of(project)where(project_id: project)end++ # Find all users, that are member of a specific Work Package+ def of_work_package(work_package_id)+ where(entity_type: 'WorkPackage', entity_id: work_package_id)+ endendendenddiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 1c5cd3feeb6..f9ac7c9b06e 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -3148,6 +3148,17 @@ en:destroy:info: "Deleting the work package is an irreversible action."title: "Delete the work package"+ sharing:+ count:+ zero: "0 members"+ one: "1 member"+ other: "%{count} members"+ invite: "Invite"+ permissions:+ comment: "Comment"+ edit: "Edit"+ view: "View"+ remove: "Remove"working_days:info: >diff --git a/frontend/src/app/features/work-packages/components/wp-share-modal/wp-share.modal.html b/frontend/src/app/features/work-packages/components/wp-share-modal/wp-share.modal.htmlindex 2ce06769f65..d963fc45c38 100644--- a/frontend/src/app/features/work-packages/components/wp-share-modal/wp-share.modal.html+++ b/frontend/src/app/features/work-packages/components/wp-share-modal/wp-share.modal.html@@ -9,14 +9,4 @@<turbo-frame src="{{this.frameSrc}}"></turbo-frame></div>- <div class="spot-action-bar hidden-for-mobile">- <div class="spot-action-bar--right">- <button- class="button button_no-margin spot-action-bar--action spot-modal--cancel-button"- (click)="closeMe($event)"- >- CLOSE- </button>- </div>- </div></div>diff --git a/frontend/src/app/features/work-packages/routing/wp-full-view/wp-full-view.html b/frontend/src/app/features/work-packages/routing/wp-full-view/wp-full-view.htmlindex d17fa7a81b4..3220c3da56e 100644--- a/frontend/src/app/features/work-packages/routing/wp-full-view/wp-full-view.html+++ b/frontend/src/app/features/work-packages/routing/wp-full-view/wp-full-view.html@@ -26,8 +26,7 @@</wp-create-button></li><li class="toolbar-item">- <wp-share-button [workPackage]="workPackage"- [showText]="false">+ <wp-share-button [workPackage]="workPackage"></wp-share-button></li><li class="toolbar-item hidden-for-tablet" *ngIf="displayTimerButton">