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
Ensure edit state uses restriction
Kabiru Mwenja6fc0c6c73075
diff --git a/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb b/app/components/work_packages/activities_tab/journals/item_component/edit.html.erbindex 34b292dadc0..bb97da905c3 100644--- a/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb+++ b/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb@@ -1,5 +1,5 @@<%=- component_wrapper(class: "work-packages-activities-tab-journals-item-component-edit") do+ component_wrapper(class: "work-packages-activities-tab-journals-item-component-edit", data: wrapper_data_attributes) dorender(Primer::Box.new(my: 3)) doprimer_form_with(id: "work-package-journal-form-element", # required for specsdiff --git a/app/components/work_packages/activities_tab/journals/item_component/edit.rb b/app/components/work_packages/activities_tab/journals/item_component/edit.rbindex bfb45e59d52..628c1cab98e 100644--- a/app/components/work_packages/activities_tab/journals/item_component/edit.rb+++ b/app/components/work_packages/activities_tab/journals/item_component/edit.rb@@ -33,6 +33,7 @@ module WorkPackagesinclude ApplicationHelperinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable+ include WorkPackages::ActivitiesTab::StimulusControllersdef initialize(journal:, filter:)super@@ -49,6 +50,12 @@ module WorkPackagesdef wrapper_uniq_byjournal.idend++ def wrapper_data_attributes+ {+ restricted_comment_stimulus_controller("-is-restricted-value") => journal.restricted?+ }+ endendendenddiff --git a/frontend/src/app/core/path-helper/apiv3-paths.ts b/frontend/src/app/core/path-helper/apiv3-paths.tsindex dfba48f969c..3bf3efbba48 100644--- a/frontend/src/app/core/path-helper/apiv3-paths.ts+++ b/frontend/src/app/core/path-helper/apiv3-paths.ts@@ -46,11 +46,13 @@ export class ApiV3Paths {// that are members of that project:filters.add('member', '=', [(workPackage.project as HalResource).id as string]);} else {- const addCommentElement = document.getElementById('work-packages-activities-tab-add-comment-component');- const isRestricted = addCommentElement?.getAttribute('data-work-packages--activities-tab--restricted-comment-is-restricted-value') === 'true';+ const isRestrictedAttribute = 'data-work-packages--activities-tab--restricted-comment-is-restricted-value';+ const addCommentIsRestricted = document.getElementById('work-packages-activities-tab-add-comment-component')?.getAttribute(isRestrictedAttribute) === 'true';+ const editorIsRestricted = document.querySelector('.work-packages-activities-tab-journals-item-component-edit')?.getAttribute(isRestrictedAttribute) === 'true';+ const isRestricted = addCommentIsRestricted || editorIsRestricted;// that are mentionable on the work package- if (addCommentElement && isRestricted) {+ if (isRestricted) {filters.add('restricted_mentionable_on_work_package', '=', [workPackage.id.toString()]);} else {filters.add('mentionable_on_work_package', '=', [workPackage.id.toString()]);diff --git a/spec/features/activities/work_package/restricted_visibility_comments_spec.rb b/spec/features/activities/work_package/restricted_visibility_comments_spec.rbindex 24002af32db..4a26587bb02 100644--- a/spec/features/activities/work_package/restricted_visibility_comments_spec.rb+++ b/spec/features/activities/work_package/restricted_visibility_comments_spec.rb@@ -39,8 +39,8 @@ RSpec.describe "Work package comments with restricted visibility",shared_let(:viewer_with_commenting_permission) { create_user_with_restricted_comments_view_and_write_permissions }shared_let(:project_admin) { create_user_as_project_admin }- let(:work_package) { create(:work_package, project:, author: admin) }- let(:first_comment) do+ shared_let(:work_package) { create(:work_package, project:, author: admin) }+ shared_let(:first_comment) docreate(:work_package_journal, user: admin, notes: "A (restricted) comment by admin",journable: work_package, version: 2, restricted: true)end@@ -232,6 +232,20 @@ RSpec.describe "Work package comments with restricted visibility",endendend++ context "when editing a restricted comment" do+ it "honors mentionable principals" do+ activity_tab.within_journal_entry(first_comment) do+ page.find_test_selector("op-wp-journal-#{first_comment.id}-action-menu").click+ page.find_test_selector("op-wp-journal-#{first_comment.id}-edit").click++ activity_tab.type_comment(" @")+ end++ expect(page.all(".mention-list-item").map(&:text))+ .to contain_exactly("Project Admin", "Restricted Viewer", "Restricted ViewerCommenter")+ end+ endenddef create_user_without_restricted_comments_view_permissions