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
Fix: Ammend stream actions to enable functional responsiveness behavior
Aaron Contreras1c478e3a5a81
diff --git a/app/components/work_packages/share/modal_body_component.html.erb b/app/components/work_packages/share/modal_body_component.html.erbindex 7a854d61943..d004ee4c338 100644--- a/app/components/work_packages/share/modal_body_component.html.erb+++ b/app/components/work_packages/share/modal_body_component.html.erb@@ -5,7 +5,7 @@render(WorkPackages::Share::InviteUserFormComponent.new(work_package: @work_package))end- if @shares.none?+ if @shares.blank?modal_content.with_row(mt: 3) dorender(Primer::Beta::Blankslate.new(border: true)) do |component|component.with_visual_icon(icon: :people, size: :medium)@@ -98,8 +98,8 @@endend- @shares.each do |principal|- render(WorkPackages::Share::ShareRowComponent.new(share: principal, container: border_box))+ @shares.each do |share|+ render(WorkPackages::Share::ShareRowComponent.new(share: share, container: border_box))endendenddiff --git a/app/controllers/work_packages/shares/bulk_controller.rb b/app/controllers/work_packages/shares/bulk_controller.rbindex bbb20dcdc5b..ea553b7657f 100644--- a/app/controllers/work_packages/shares/bulk_controller.rb+++ b/app/controllers/work_packages/shares/bulk_controller.rb@@ -33,13 +33,13 @@ class WorkPackages::Shares::BulkController < ApplicationControllerinclude MemberHelperbefore_action :find_work_package- before_action :find_shares+ before_action :find_selected_sharesbefore_action :find_role_ids_from_params, only: :updatebefore_action :find_projectbefore_action :authorizedef update- @shares.each do |share|+ @selected_shares.each do |share|WorkPackageMembers::CreateOrUpdateService.new(user: current_user).call(entity: @work_package,@@ -51,7 +51,7 @@ class WorkPackages::Shares::BulkController < ApplicationControllerenddef destroy- @shares.each do |share|+ @selected_shares.each do |share|WorkPackageMembers::DeleteService.new(user: current_user, model: share).call@@ -67,7 +67,7 @@ class WorkPackages::Shares::BulkController < ApplicationControllerprivatedef respond_with_update_permission_buttons- @shares.each do |share|+ @selected_shares.each do |share|replace_via_turbo_stream(component: WorkPackages::Share::PermissionButtonComponent.new(share:,data: { 'test-selector': 'op-share-wp-update-role' })@@ -79,14 +79,14 @@ class WorkPackages::Shares::BulkController < ApplicationControllerdef respond_with_replace_modalreplace_via_turbo_stream(- component: WorkPackages::Share::ModalBodyComponent.new(work_package: @work_package, shares: @shares)+ component: WorkPackages::Share::ModalBodyComponent.new(work_package: @work_package, shares: find_shares))respond_with_turbo_streamsenddef respond_with_remove_shares- @shares.each do |share|+ @selected_shares.each do |share|remove_via_turbo_stream(component: WorkPackages::Share::ShareRowComponent.new(share:))@@ -108,9 +108,16 @@ class WorkPackages::Shares::BulkController < ApplicationControllerenddef find_shares- @shares = Member.includes(:principal)+ @shares = Member.includes(:principal, :member_roles)+ .references(:member_roles).of_work_package(@work_package)- .where(id: params[:share_ids])+ .merge(MemberRole.only_non_inherited)+ end++ def find_selected_shares+ @selected_shares = Member.includes(:principal)+ .of_work_package(@work_package)+ .where(id: params[:share_ids])enddef find_role_ids_from_paramsdiff --git a/app/controllers/work_packages/shares_controller.rb b/app/controllers/work_packages/shares_controller.rbindex 7d7e342b11b..9b54db9928d 100644--- a/app/controllers/work_packages/shares_controller.rb+++ b/app/controllers/work_packages/shares_controller.rb@@ -57,17 +57,15 @@ class WorkPackages::SharesController < ApplicationControlleruser_id: member_params[:user_id],role_ids: find_role_ids(params[:member][:role_id]))- @share = service_call.result-overall_result.push(service_call)end- @shares = overall_result.map(&:result).reverse+ @new_shares = overall_result.map(&:result).reverseif overall_result.present?# In case the number of newly added shares is equal to the whole number of shares,# we have to render the whole modal again to get rid of the blankslate- if current_visible_member_count > 1 && @shares.size < current_visible_member_count+ if current_visible_member_count > 1 && @new_shares.size < current_visible_member_countrespond_with_prepend_shareselserespond_with_replace_modal@@ -99,7 +97,7 @@ class WorkPackages::SharesController < ApplicationControllerdef respond_with_replace_modalreplace_via_turbo_stream(- component: WorkPackages::Share::ModalBodyComponent.new(work_package: @work_package, shares: @shares)+ component: WorkPackages::Share::ModalBodyComponent.new(work_package: @work_package, shares: @new_shares || find_shares))respond_with_turbo_streams@@ -114,10 +112,10 @@ class WorkPackages::SharesController < ApplicationControllercomponent: WorkPackages::Share::CounterComponent.new(work_package: @work_package, count: current_visible_member_count))- @shares.each do |share|+ @new_shares.each do |share|prepend_via_turbo_stream(component: WorkPackages::Share::ShareRowComponent.new(share:),- target_component: WorkPackages::Share::ModalBodyComponent.new(work_package: @work_package, shares: @shares)+ target_component: WorkPackages::Share::ModalBodyComponent.new(work_package: @work_package, shares: find_shares))end@@ -154,6 +152,13 @@ class WorkPackages::SharesController < ApplicationController@work_package = @share.entityend+ def find_shares+ @shares = Member.includes(:roles)+ .references(:member_roles)+ .of_work_package(@work_package)+ .merge(MemberRole.only_non_inherited)+ end+def find_project@project = @work_package.projectend