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

Draft out restricted comment box

Kabiru Mwenja30c0351d5670
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 49576538487..fadb3d149aa 100644
--- a/app/components/work_packages/activities_tab/index_component.html.erb
+++ b/app/components/work_packages/activities_tab/index_component.html.erb
@@ -36,7 +36,8 @@
classes: "work-packages-activities-tab-index-component--input-container work-packages-activities-tab-index-component--input-container_sort-#{journal_sorting}",
px: 2,
py: 3,
- bg: :subtle
+ bg: :subtle,
+ data: new_comment_wrapper_data_attributes
) do
render(
WorkPackages::ActivitiesTab::Journals::NewComponent.new(work_package:)
diff --git a/app/components/work_packages/activities_tab/index_component.rb b/app/components/work_packages/activities_tab/index_component.rb
index 6efc7f98e21..b833932a8d5 100644
--- a/app/components/work_packages/activities_tab/index_component.rb
+++ b/app/components/work_packages/activities_tab/index_component.rb
@@ -50,21 +50,29 @@ module WorkPackages
attr_reader :work_package, :filter, :last_server_timestamp, :deferred
def wrapper_data_attributes
- stimulus_controller = "work-packages--activities-tab--index"
+ index_stimulus_controller = "work-packages--activities-tab--index"
+ restricted_comments_stimulus_controller = "work-packages--activities-tab--restricted-comment"
{
test_selector: "op-wp-activity-tab",
- controller: stimulus_controller,
+ controller: [index_stimulus_controller, restricted_comments_stimulus_controller].join(" "),
"application-target": "dynamic",
- "#{stimulus_controller}-update-streams-path-value": update_streams_work_package_activities_path(work_package),
- "#{stimulus_controller}-sorting-value": journal_sorting,
- "#{stimulus_controller}-filter-value": filter,
- "#{stimulus_controller}-user-id-value": User.current.id,
- "#{stimulus_controller}-work-package-id-value": work_package.id,
- "#{stimulus_controller}-polling-interval-in-ms-value": polling_interval,
- "#{stimulus_controller}-notification-center-path-name-value": notifications_path,
- "#{stimulus_controller}-show-conflict-flash-message-url-value": show_conflict_flash_message_work_packages_path,
- "#{stimulus_controller}-last-server-timestamp-value": last_server_timestamp
+ "#{index_stimulus_controller}-update-streams-path-value": update_streams_work_package_activities_path(work_package),
+ "#{index_stimulus_controller}-sorting-value": journal_sorting,
+ "#{index_stimulus_controller}-filter-value": filter,
+ "#{index_stimulus_controller}-user-id-value": User.current.id,
+ "#{index_stimulus_controller}-work-package-id-value": work_package.id,
+ "#{index_stimulus_controller}-polling-interval-in-ms-value": polling_interval,
+ "#{index_stimulus_controller}-notification-center-path-name-value": notifications_path,
+ "#{index_stimulus_controller}-show-conflict-flash-message-url-value": show_conflict_flash_message_work_packages_path,
+ "#{index_stimulus_controller}-last-server-timestamp-value": last_server_timestamp
+ }
+ end
+
+ def new_comment_wrapper_data_attributes
+ {
+ test_selector: "op-work-package-journal--new-comment-component",
+ "work-packages--activities-tab--restricted-comment-target": "formContainer"
}
end
diff --git a/app/components/work_packages/activities_tab/journals/new_component.html.erb b/app/components/work_packages/activities_tab/journals/new_component.html.erb
index 0651e66aa34..eb22c58b1d8 100644
--- a/app/components/work_packages/activities_tab/journals/new_component.html.erb
+++ b/app/components/work_packages/activities_tab/journals/new_component.html.erb
@@ -53,28 +53,42 @@
},
url: work_package_activities_path(work_package_id: work_package.id)
) do |f|
- flex_layout(justify_content: :space_between, align_items: :flex_end) do |form_container|
- form_container.with_column(
- classes: "work-packages-activities-tab-journals-new-component--ck-editor-column",
- mr: 2
- ) do
- render(WorkPackages::ActivitiesTab::Journals::NotesForm.new(f))
- end
- form_container.with_column do
- render(
- Primer::Beta::IconButton.new(
- scheme: :default,
- icon: :"paper-airplane",
- "aria-label": t("activities.work_packages.activity_tab.label_submit_comment"),
- type: :submit,
- data: {
- test_selector: "op-submit-work-package-journal-form",
- "work-packages--activities-tab--index-target": "formSubmitButton"
- }
+ if adding_restricted_comment_allowed?
+ concat(
+ flex_layout do |flex|
+ flex.with_row(mb: 3) do
+ render(WorkPackages::ActivitiesTab::Journals::RestrictedNoteForm.new(f))
+ end
+ end
+ )
+ end
+
+ concat(
+ flex_layout(justify_content: :space_between, align_items: :flex_end) do |form_container|
+ form_container.with_column(
+ classes: "work-packages-activities-tab-journals-new-component--ck-editor-column",
+ mr: 2
+ ) do
+ render(WorkPackages::ActivitiesTab::Journals::NotesForm.new(f))
+ end
+
+ form_container.with_column do
+ render(
+ Primer::Beta::IconButton.new(
+ scheme: :default,
+ icon: :"paper-airplane",
+ "aria-label": t("activities.work_packages.activity_tab.label_submit_comment"),
+ type: :submit,
+ data: {
+ test_selector: "op-submit-work-package-journal-form",
+ "work-packages--activities-tab--index-target": "formSubmitButton"
+ }
+ )
)
- )
+ end
end
- end
+ )
+
end
end
end
diff --git a/app/components/work_packages/activities_tab/journals/new_component.rb b/app/components/work_packages/activities_tab/journals/new_component.rb
index a718c6d8dd0..1ab04e2cd4a 100644
--- a/app/components/work_packages/activities_tab/journals/new_component.rb
+++ b/app/components/work_packages/activities_tab/journals/new_component.rb
@@ -57,6 +57,11 @@ module WorkPackages
def form_row_display_value
form_hidden_initially ? :none : :block
end
+
+ def adding_restricted_comment_allowed?
+ # TODO: change to use permissions
+ true
+ end
end
end
end
diff --git a/app/components/work_packages/activities_tab/journals/new_component.sass b/app/components/work_packages/activities_tab/journals/new_component.sass
index b3ab7ddeaed..00e6dc543ea 100644
--- a/app/components/work_packages/activities_tab/journals/new_component.sass
+++ b/app/components/work_packages/activities_tab/journals/new_component.sass
@@ -28,3 +28,5 @@
max-height: 10vh
.ck-editor__preview
max-height: 30vh
+ &__journal-notes-body--restricted-comment
+ background-color: #ffe7d1 !important // base-color-orange-0 not defined in design tokens
diff --git a/app/controllers/work_packages/activities_tab_controller.rb b/app/controllers/work_packages/activities_tab_controller.rb
index d78ca3f2ead..27a8ff299ad 100644
--- a/app/controllers/work_packages/activities_tab_controller.rb
+++ b/app/controllers/work_packages/activities_tab_controller.rb
@@ -222,7 +222,7 @@ class WorkPackages::ActivitiesTabController < ApplicationController
end
def journal_params
- params.require(:journal).permit(:notes)
+ params.require(:journal).permit(:notes, :restricted)
end
def handle_successful_create_call(call)
diff --git a/app/forms/work_packages/activities_tab/journals/restricted_note_form.rb b/app/forms/work_packages/activities_tab/journals/restricted_note_form.rb
new file mode 100644
index 00000000000..d7b99228848
--- /dev/null
+++ b/app/forms/work_packages/activities_tab/journals/restricted_note_form.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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::ActivitiesTab::Journals
+ class RestrictedNoteForm < ApplicationForm
+ form do |notes_form|
+ notes_form.check_box(
+ name: :restricted,
+ label: I18n.t("activities.work_packages.activity_tab.restricted_visibility"),
+ checked: false,
+ label_arguments: { class: "no-wrap" },
+ data: {
+ "work-packages--activities-tab--restricted-comment-target": "checkbox",
+ action: "input->work-packages--activities-tab--restricted-comment#onCheckboxChange"
+ }
+ )
+ end
+ end
+end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index aeadc1833b9..192295d3609 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -48,6 +48,7 @@ en:
changed: "changed"
created: "created"
commented: "commented"
+ restricted_visibility: Restricted visibility
restricted_journal: Only visible to a limited group of members.
admin:
diff --git a/frontend/src/app/shared/components/editor/components/ckeditor/op-ckeditor.component.ts b/frontend/src/app/shared/components/editor/components/ckeditor/op-ckeditor.component.ts
index 51843b2f83b..bab8b818cf1 100644
--- a/frontend/src/app/shared/components/editor/components/ckeditor/op-ckeditor.component.ts
+++ b/frontend/src/app/shared/components/editor/components/ckeditor/op-ckeditor.component.ts
@@ -303,8 +303,10 @@ export class OpCkeditorComponent extends UntilDestroyedMixin implements OnInit,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (!editor.ui.focusTracker.isFocused) {
this.editorBlur.emit();
+ debugLog('CKEditor blurred');
} else {
this.editorFocus.emit();
+ debugLog('CKEditor focused');
}
}, 0);
},
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
index c023a802e77..0ce1e598434 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
@@ -1,3 +1,33 @@
+/*
+ * -- copyright
+ * OpenProject is an open source project management software.
+ * Copyright (C) 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.
+ * ++
+ */
+
import { Controller } from '@hotwired/stimulus';
import {
ICKEditorInstance,
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/restricted-comment.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/restricted-comment.controller.ts
new file mode 100644
index 00000000000..90b6b3cd30a
--- /dev/null
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/restricted-comment.controller.ts
@@ -0,0 +1,53 @@
+/*
+ * -- copyright
+ * OpenProject is an open source project management software.
+ * Copyright (C) 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.
+ * ++
+ */
+
+import { Controller } from '@hotwired/stimulus';
+
+export default class RestrictedCommentController extends Controller {
+ static targets = ['checkbox', 'formContainer'];
+
+ declare readonly checkboxTarget:HTMLInputElement;
+ declare readonly formContainerTarget:HTMLElement;
+
+ onCheckboxChange():void {
+ const restrictedCommentBgColorClass = 'work-packages-activities-tab-journals-new-component__journal-notes-body--restricted-comment';
+ // FIXME: This is not ideal as primer can change class names. Awaiting redesign of the form...
+ // This should NOT make it to production.
+ const primerBgColorClass = 'color-bg-subtle';
+
+ if (this.checkboxTarget.checked) {
+ this.formContainerTarget.classList.remove(primerBgColorClass);
+ this.formContainerTarget.classList.add(restrictedCommentBgColorClass);
+ } else {
+ this.formContainerTarget.classList.remove(restrictedCommentBgColorClass);
+ this.formContainerTarget.classList.add(primerBgColorClass);
+ }
+ }
+}