Skip to content

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

Define restricted comments quoting criteria

Kabiru Mwenjadfa50337997b
diff --git a/app/components/work_packages/activities_tab/index_component.html.erb b/app/components/work_packages/activities_tab/index_component.html.erb
index 08ce9923189..c110777426f 100644
--- a/app/components/work_packages/activities_tab/index_component.html.erb
+++ b/app/components/work_packages/activities_tab/index_component.html.erb
@@ -33,6 +33,7 @@
end
if adding_comment_allowed?
journals_wrapper_container.with_row(
+ id: add_comment_wrapper_key,
classes: "work-packages-activities-tab-index-component--input-container work-packages-activities-tab-index-component--input-container_sort-#{journal_sorting}",
px: 2,
py: 3,
diff --git a/app/components/work_packages/activities_tab/index_component.rb b/app/components/work_packages/activities_tab/index_component.rb
index 3f44c80f57d..b48b8fd2686 100644
--- a/app/components/work_packages/activities_tab/index_component.rb
+++ b/app/components/work_packages/activities_tab/index_component.rb
@@ -45,6 +45,9 @@ module WorkPackages
@deferred = deferred
end
+ def self.add_comment_wrapper_key = "work-packages-activities-tab-add-comment-component"
+ delegate :add_comment_wrapper_key, to: :class
+
private
attr_reader :work_package, :filter, :last_server_timestamp, :deferred
diff --git a/app/components/work_packages/activities_tab/journals/item_component.rb b/app/components/work_packages/activities_tab/journals/item_component.rb
index 008613f9d4f..43d954a92da 100644
--- a/app/components/work_packages/activities_tab/journals/item_component.rb
+++ b/app/components/work_packages/activities_tab/journals/item_component.rb
@@ -150,15 +150,23 @@ module WorkPackages
quote_comments_stimulus_controller("-content-param") => journal.notes,
quote_comments_stimulus_controller("-user-id-param") => journal.user_id,
quote_comments_stimulus_controller("-user-name-param") => journal.user.name,
+ quote_comments_stimulus_controller("-is-restricted-param") => journal.restricted?,
quote_comments_stimulus_controller("-text-wrote-param") => I18n.t(:text_wrote),
- quote_comments_stimulus_controller("-#{index_stimulus_controller}-outlet") => "##{index_stimulus_controller_wrapper_key}", # rubocop:disable Layout/LineLength
+ quote_comments_stimulus_controller("-#{index_stimulus_controller}-outlet") => items_index_selector,
+ quote_comments_stimulus_controller("-#{restricted_comment_stimulus_controller}-outlet") => add_comment_selector,
test_selector: "op-wp-journal-#{journal.id}-quote"
}
end
def quote_comments_stimulus_controller(suffix = nil) = "work-packages--activities-tab--quote-comment#{suffix}"
def index_stimulus_controller(suffix = nil) = "work-packages--activities-tab--index#{suffix}"
- def index_stimulus_controller_wrapper_key = WorkPackages::ActivitiesTab::IndexComponent.wrapper_key
+ def restricted_comment_stimulus_controller(suffix = nil) = "work-packages--activities-tab--restricted-comment#{suffix}"
+
+ def items_index_selector = "##{WorkPackages::ActivitiesTab::IndexComponent.wrapper_key}"
+
+ def add_comment_selector
+ "##{WorkPackages::ActivitiesTab::IndexComponent.add_comment_wrapper_key}"
+ end
end
end
end
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/quote-comment.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/quote-comment.controller.ts
index 5b977905f4d..d516935d742 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/quote-comment.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/quote-comment.controller.ts
@@ -29,21 +29,25 @@
*/
import { Controller } from '@hotwired/stimulus';
+
import type IndexController from './index.controller';
+import type RestrictedCommentController from './restricted-comment.controller';
type QuoteParams = {
userId:string;
userName:string;
textWrote:string;
content:string;
+ isRestricted:boolean;
};
export default class QuoteCommentController extends Controller {
- static outlets = ['work-packages--activities-tab--index'];
+ static outlets = ['work-packages--activities-tab--index', 'work-packages--activities-tab--restricted-comment'];
declare readonly workPackagesActivitiesTabIndexOutlet:IndexController;
+ declare readonly workPackagesActivitiesTabRestrictedCommentOutlet:RestrictedCommentController;
- quote({ params: { userId, userName, textWrote, content } }:{ params:QuoteParams }) {
+ quote({ params: { userId, userName, textWrote, content, isRestricted } }:{ params:QuoteParams }) {
const quotedText = this.quotedText(content, userId, userName, textWrote);
if (this.isFormVisible) {
@@ -51,6 +55,8 @@ export default class QuoteCommentController extends Controller {
} else {
this.openEditorWithInitialData(quotedText);
}
+
+ this.setCommentRestriction(isRestricted);
}
private quotedText(rawComment:string, userId:string, userName:string, textWrote:string) {
@@ -74,6 +80,13 @@ export default class QuoteCommentController extends Controller {
}
}
+ private setCommentRestriction(isRestricted:boolean) {
+ if (isRestricted && !this.workPackagesActivitiesTabRestrictedCommentOutlet.restrictedCheckboxTarget.checked) {
+ this.workPackagesActivitiesTabRestrictedCommentOutlet.restrictedCheckboxTarget.checked = isRestricted;
+ this.workPackagesActivitiesTabRestrictedCommentOutlet.toggleBackgroundColor();
+ }
+ }
+
private openEditorWithInitialData(quotedText:string) {
this.workPackagesActivitiesTabIndexOutlet.openEditorWithInitialData(quotedText);
}
diff --git a/spec/features/activities/work_package/restricted_visibility_comments_spec.rb b/spec/features/activities/work_package/restricted_visibility_comments_spec.rb
index 2be579bc806..dc7e86ef82b 100644
--- a/spec/features/activities/work_package/restricted_visibility_comments_spec.rb
+++ b/spec/features/activities/work_package/restricted_visibility_comments_spec.rb
@@ -148,11 +148,15 @@ RSpec.describe "Work package comments with restricted visibility",
it "allows editing and quoting restricted comments" do
activity_tab.expect_journal_notes(text: "A (restricted) comment by admin")
+ activity_tab.edit_comment(first_comment, text: "A (restricted) comment by admin - EDITED")
+
activity_tab.within_journal_entry(first_comment) do
- page.find_test_selector("op-wp-journal-#{first_comment.id}-action-menu").click
+ activity_tab.expect_journal_notes(text: "A (restricted) comment by admin - EDITED")
+ end
- expect(page).to have_test_selector("op-wp-journal-#{first_comment.id}-edit")
- expect(page).to have_test_selector("op-wp-journal-#{first_comment.id}-quote")
+ activity_tab.quote_comment(first_comment)
+ page.within_test_selector("op-work-package-journal-form-element") do
+ expect(page).to have_checked_field("Restrict visibility")
end
end
end