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
feat[OP#55966]: define add project dialog UI blueprint
Kabiru Mwenja6543ec730d49
diff --git a/config/locales/en.yml b/config/locales/en.ymlindex d0bd5484dd9..774ab1d0a81 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -2161,6 +2161,7 @@ en:label_inactive: "Inactive"label_incoming_emails: "Incoming emails"label_includes: "includes"+ label_include_sub_projects: Include sub-projectslabel_index_by_date: "Index by date"label_index_by_title: "Index by title"label_information: "Information"diff --git a/modules/storages/app/components/storages/admin/storages/add_projects_form_modal_component.html.erb b/modules/storages/app/components/storages/admin/storages/add_projects_form_modal_component.html.erbnew file mode 100644index 00000000000..58a556c658e--- /dev/null+++ b/modules/storages/app/components/storages/admin/storages/add_projects_form_modal_component.html.erb@@ -0,0 +1,54 @@+<%#-- 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.++++#%>++<%=+ component_wrapper do+ primer_form_with(+ class: "op-new-project-storage-form",+ model: @project_storage,+ url: admin_settings_storage_project_storages_path(@storage),+ data: { turbo: true },+ method: :post+ ) do |form|+ concat(render(Primer::Alpha::Dialog::Body.new(+ id: dialog_body_id,+ test_selector: dialog_body_id,+ aria: { label: title },+ style: "min-height: 300px"+ )) do+ render(Storages::Admin::Storages::AddProjectsForm.new(form, project_storage: @project_storage))+ end)++ concat(render(Primer::Alpha::Dialog::Footer.new(show_divider: false)) do+ concat(render(Primer::ButtonComponent.new(data: { 'close-dialog-id': dialog_id })) { cancel_button_text })+ concat(render(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) { submit_button_text })+ end)+ end+ end+%>diff --git a/modules/storages/app/components/storages/admin/storages/add_projects_form_modal_component.rb b/modules/storages/app/components/storages/admin/storages/add_projects_form_modal_component.rbnew file mode 100644index 00000000000..3c9b08e4ec5--- /dev/null+++ b/modules/storages/app/components/storages/admin/storages/add_projects_form_modal_component.rb@@ -0,0 +1,60 @@+#-- 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 Storages+ module Admin+ module Storages+ class AddProjectsFormModalComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent+ include OpTurbo::Streamable++ def initialize(project_storage:, **)+ @project_storage = project_storage+ @storage = project_storage.storage+ super(@project_storage, **)+ end++ private++ def dialog_id = Storages::AddProjectsModalComponent::DIALOG_ID+ def dialog_body_id = Storages::AddProjectsModalComponent::DIALOG_BODY_ID++ def title+ I18n.t(:label_add_projects)+ end++ def cancel_button_text+ I18n.t("button_cancel")+ end++ def submit_button_text+ I18n.t("button_add")+ end+ end+ end+ end+enddiff --git a/modules/storages/app/components/storages/admin/storages/add_projects_modal_component.html.erb b/modules/storages/app/components/storages/admin/storages/add_projects_modal_component.html.erbnew file mode 100644index 00000000000..ec3965fe51e--- /dev/null+++ b/modules/storages/app/components/storages/admin/storages/add_projects_modal_component.html.erb@@ -0,0 +1,18 @@+<%=+ render(+ Primer::Alpha::Dialog.new(+ id: dialog_id,+ title:,+ test_selector: dialog_id,+ size: :large+ )+ ) do |dialog|+ dialog.with_header(+ show_divider: false,+ visually_hide_title: false,+ variant: :large+ )++ render(::Storages::Admin::Storages::AddProjectsFormModalComponent.new(project_storage:))+ end+%>diff --git a/modules/storages/app/components/storages/admin/storages/add_projects_modal_component.rb b/modules/storages/app/components/storages/admin/storages/add_projects_modal_component.rbnew file mode 100644index 00000000000..31e79b898d8--- /dev/null+++ b/modules/storages/app/components/storages/admin/storages/add_projects_modal_component.rb@@ -0,0 +1,57 @@+#-- 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 Storages+ module Admin+ module Storages+ class AddProjectsModalComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent+ include OpTurbo::Streamable++ DIALOG_ID = "storages--add-projects-modal".freeze+ DIALOG_BODY_ID = "storages--add-projects-modal-body".freeze++ def initialize(project_storage:, **)+ @project_storage = project_storage+ @storage = project_storage.storage+ super(@project_storage, **)+ end++ private++ def dialog_id = DIALOG_ID+ def dialog_body_id = DIALOG_BODY_ID++ attr_reader :project_storage, :storage++ def title+ I18n.t(:label_add_projects)+ end+ end+ end+ end+enddiff --git a/modules/storages/app/controllers/storages/admin/storages/project_storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages/project_storages_controller.rbindex 17dbf108e05..81daaddc4e9 100644--- a/modules/storages/app/controllers/storages/admin/storages/project_storages_controller.rb+++ b/modules/storages/app/controllers/storages/admin/storages/project_storages_controller.rb@@ -30,6 +30,7 @@class Storages::Admin::Storages::ProjectStoragesController < ApplicationControllerinclude OpTurbo::ComponentStream+ include OpTurbo::DialogStreamHelperlayout "admin"@@ -56,7 +57,11 @@ class Storages::Admin::Storages::ProjectStoragesController < ApplicationControll.to_hend- def new; end+ def new+ @project_storage = ::Storages::ProjectStorage.new(storage: @storage)+ respond_with_dialog Storages::Admin::Storages::AddProjectsModalComponent.new(project_storage: @project_storage)+ end+def create; enddef destroy; enddiff --git a/modules/storages/app/forms/storages/admin/storages/add_projects_form.rb b/modules/storages/app/forms/storages/admin/storages/add_projects_form.rbnew file mode 100644index 00000000000..389b498865c--- /dev/null+++ b/modules/storages/app/forms/storages/admin/storages/add_projects_form.rb@@ -0,0 +1,85 @@+#-- 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 Storages+ module Admin+ module Storages+ class AddProjectsForm < ApplicationForm+ include OpPrimer::ComponentHelpers++ form do |form|+ form.group(layout: :vertical) do |group|+ group.project_autocompleter(+ name: :id,+ label: Project.model_name.human,+ visually_hide_label: true,+ validation_message: project_ids_error_message,+ autocomplete_options: {+ openDirectly: false,+ focusDirectly: false,+ multiple: true,+ dropdownPosition: "bottom",+ disabledProjects: projects_with_storage_mapping,+ inputName: "project_storage[project_ids]"+ }+ )++ group.check_box(+ name: :include_sub_projects,+ label: I18n.t(:label_include_sub_projects),+ checked: false,+ label_arguments: { class: "no-wrap" }+ )+ end+ end++ def initialize(project_storage:)+ super()+ @project_storage = project_storage+ end++ private++ def project_ids_error_message+ @project_storage+ .errors+ .messages_for(:project_ids)+ .to_sentence+ .presence+ end++ def projects_with_storage_mapping+ ::Storages::ProjectStorage+ .where(storage_id: @project_storage.storage.id)+ .pluck(:project_id)+ .to_h { |id| [id, id] }+ end+ end+ end+ end+end