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#50212]: Add Automatically managed form view
Kabiru Mwenja9e6b084ed4b8
diff --git a/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.html.erb b/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.html.erbnew file mode 100644index 00000000000..14f1a7e4db5--- /dev/null+++ b/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.html.erb@@ -0,0 +1,34 @@+<%=+ primer_form_with(+ model: storage,+ url: admin_settings_storage_automatically_managed_project_folders_path(storage),+ method: :patch,+ data: {+ controller: "storages--automatically-managed-project-folders-form",+ 'application-target': "dynamic",+ 'storages--automatically-managed-project-folders-form-is-automatically-managed-value': storage.automatically_managed?,+ }+ ) do |form|+ flex_layout do |project_folders_form|+ project_folders_form.with_row(mb: 3) do+ render(Primer::Beta::Text.new(font_weight: :semibold)) { I18n.t(:'storages.label_managed_project_folders.automatically_managed_folders') }+ end++ project_folders_form.with_row(mb: 3) do+ render(Primer::Beta::Text.new(font_weight: :light)) { I18n.t("storages.page_titles.managed_project_folders.subtitle") }+ end++ project_folders_form.with_row(mb: 3) do+ render(Storages::Admin::ManagedProjectFolders::AutomaticallyManagedCheckbox.new(form, storage:))+ end++ project_folders_form.with_row(mb: 3, data: { 'storages--automatically-managed-project-folders-form-target': "applicationPasswordInput" }) do+ render(Storages::Admin::ManagedProjectFolders::ApplicationPasswordInput.new(form, storage:))+ end++ project_folders_form.with_row do+ render(Storages::Admin::SaveOrCancelForm.new(form, storage:, submit_label: I18n.t("storages.buttons.done_complete_setup")))+ end+ end+ end+%>diff --git a/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.rb b/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.rbnew file mode 100644index 00000000000..f962f4819aa--- /dev/null+++ b/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.rb@@ -0,0 +1,52 @@+# frozen_string_literal: true++#-- 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::Admin::Forms+ class AutomaticallyManagedProjectFoldersFormComponent < ApplicationComponent+ include OpPrimer::ComponentHelpers+ alias_method :storage, :model++ private++ def storage_provider_credentials_copy_instructions+ "#{I18n.t('storages.instructions.copy_from')}: #{provider_credentials_instructions_link}".html_safe+ end++ def provider_credentials_instructions_link+ render(+ Primer::Beta::Link.new(+ href: Storages::Peripherals::StorageInteraction::Nextcloud::Util.join_uri_path(storage.host,+ 'settings/admin/openproject'),+ target: '_blank'+ )+ ) { I18n.t("storages.instructions.#{storage.short_provider_type}.integration") }+ end+ end+enddiff --git a/modules/storages/app/components/storages/admin/storage_view_component.html.erb b/modules/storages/app/components/storages/admin/storage_view_component.html.erbindex 5d106ac6cc6..33ced4462e9 100644--- a/modules/storages/app/components/storages/admin/storage_view_component.html.erb+++ b/modules/storages/app/components/storages/admin/storage_view_component.html.erb@@ -130,18 +130,33 @@endcomponent.with_row(scheme: :default) do- grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|- grid.with_area(:item, tag: :div, mr: 3) do- concat(render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1)) { I18n.t('storages.file_storage_view.automatically_managed_folders') })- concat(automatically_managed_project_folders_status_label)- end+ render(OpTurbo::FrameComponent.new(storage, context: :automatically_managed_project_folders)) do+ grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|+ grid.with_area(:item, tag: :div, mr: 3) do+ concat(render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1)) { I18n.t('storages.file_storage_view.automatically_managed_folders') })+ concat(automatically_managed_project_folders_status_label)+ end- grid.with_area(:description, tag: :div, color: :subtle, test_selector: 'storage-oauth-client-id-description') do- render(Primer::Beta::Truncate.new(font_weight: :light)) { I18n.t('storages.page_titles.managed_project_folders.subtitle_short') }- end+ grid.with_area(:description, tag: :div, color: :subtle, test_selector: 'storage-automatically-managed-project-folders-description') do+ render(Primer::Beta::Truncate.new(font_weight: :light)) { I18n.t('storages.page_titles.managed_project_folders.subtitle_short') }+ end- grid.with_area(:"icon-button", tag: :div, color: :subtle, mr: 3, justify_self: :end) do- render(Primer::Beta::IconButton.new(icon: :pencil, scheme: :invisible, aria: { label: I18n.t('storages.label_edit_storage') } , test_selector: 'storage-edit-button'))+ grid.with_area(:"icon-button", tag: :div, color: :subtle) do+ flex_layout(justify_content: :flex_end) do |icons_container|+ icons_container.with_column do+ render(+ Primer::Beta::IconButton.new(+ icon: :pencil,+ tag: :a,+ href: new_admin_settings_storage_automatically_managed_project_folders_path(storage),+ scheme: :invisible,+ aria: { label: I18n.t('storages.label_edit_storage_automatically_managed_folders') },+ test_selector: 'storage-edit-automatically-managed-project-folders-button'+ )+ )+ end+ end+ endendendenddiff --git a/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb b/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rbindex 1964038f6a8..efe5436ea7e 100644--- a/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb+++ b/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb@@ -87,6 +87,7 @@ class Storages::Admin::AutomaticallyManagedProjectFoldersController < Applicatioredirect_to edit_admin_settings_storage_path(@storage)else@errors = service_result.errors+ @storage = ServiceResultErrorsPresenter.new(service_result)render '/storages/admin/storages/automatically_managed_project_folders/edit'endenddiff --git a/modules/storages/app/forms/storages/admin/managed_project_folders/application_password_input.rb b/modules/storages/app/forms/storages/admin/managed_project_folders/application_password_input.rbnew file mode 100644index 00000000000..0e0bde9dd14--- /dev/null+++ b/modules/storages/app/forms/storages/admin/managed_project_folders/application_password_input.rb@@ -0,0 +1,62 @@+#-- 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::Admin::ManagedProjectFolders+ class ApplicationPasswordInput < ApplicationForm+ form do |application_password_form|+ application_password_form.text_field(+ name: :password,+ label: I18n.t(:'storages.label_managed_project_folders.application_password'),+ required: true,+ caption: application_password_caption+ )+ end++ def initialize(storage:)+ super()+ @storage = storage+ end++ private++ def application_password_caption+ I18n.t(:'storages.instructions.managed_project_folders_application_password_caption',+ provider_type_link:).html_safe+ end++ def provider_type_link+ render(+ Primer::Beta::Link.new(+ href: Storages::Peripherals::StorageInteraction::Nextcloud::Util.join_uri_path(@storage.host,+ 'settings/admin/openproject'),+ target: '_blank'+ )+ ) { I18n.t("storages.instructions.#{@storage.short_provider_type}.integration") }+ end+ end+enddiff --git a/modules/storages/app/forms/storages/admin/managed_project_folders/automatically_managed_checkbox.rb b/modules/storages/app/forms/storages/admin/managed_project_folders/automatically_managed_checkbox.rbnew file mode 100644index 00000000000..fb59553273b--- /dev/null+++ b/modules/storages/app/forms/storages/admin/managed_project_folders/automatically_managed_checkbox.rb@@ -0,0 +1,48 @@+#-- 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::Admin::ManagedProjectFolders+ class AutomaticallyManagedCheckbox < ApplicationForm+ form do |automatically_managed_form|+ automatically_managed_form.check_box(+ name: :automatically_managed,+ label: I18n.t(:'storages.label_managed_project_folders.automatically_managed_folders'),+ checked: @storage.automatically_managed?,+ required: true,+ data: {+ action: 'change->storages--automatically-managed-project-folders-form#updateDisplay'+ }+ )+ end++ def initialize(storage:)+ super()+ @storage = storage+ end+ end+enddiff --git a/modules/storages/app/forms/storages/admin/save_or_cancel_form.rb b/modules/storages/app/forms/storages/admin/save_or_cancel_form.rbindex b05c731219f..47d724deffc 100644--- a/modules/storages/app/forms/storages/admin/save_or_cancel_form.rb+++ b/modules/storages/app/forms/storages/admin/save_or_cancel_form.rb@@ -32,7 +32,7 @@ module Storages::Adminbuttons.group(layout: :horizontal) do |button_group|button_group.submit(name: :submit,scheme: :primary,- label: I18n.t('storages.buttons.save_and_continue'))+ label: @submit_label)button_group.button(name: :cancel,scheme: :default,tag: :a,@@ -41,9 +41,10 @@ module Storages::Adminendend- def initialize(storage:)+ def initialize(storage:, submit_label: I18n.t('storages.buttons.save_and_continue'))super()@storage = storage+ @submit_label = submit_labelendendenddiff --git a/modules/storages/app/views/storages/admin/storages/automatically_managed_project_folders/edit.html.erb b/modules/storages/app/views/storages/admin/storages/automatically_managed_project_folders/edit.html.erbindex 3872626d2a1..df31a43e2e7 100644--- a/modules/storages/app/views/storages/admin/storages/automatically_managed_project_folders/edit.html.erb+++ b/modules/storages/app/views/storages/admin/storages/automatically_managed_project_folders/edit.html.erb@@ -28,79 +28,88 @@ See COPYRIGHT and LICENSE files for more details.++#%><% html_title t(:label_administration), t("project_module_storages"), @storage.name, t("storages.page_titles.managed_project_folders.title") %>-<% local_assigns[:additional_breadcrumb] = [- link_to(@storage.name, edit_admin_settings_storage_path(@storage)),- t("storages.label_managed_project_folders_breadcrumb")-] %>-<%= toolbar title: t("storages.page_titles.managed_project_folders.title"),- subtitle: t("storages.page_titles.managed_project_folders.subtitle")-%>-<%= error_messages_for_contract @storage, @errors %>+<% if OpenProject::FeatureDecisions.storage_primer_design_active? %>+ <%=+ render(OpTurbo::FrameComponent.new(@storage, context: :automatically_managed_project_folders)) do+ render(Storages::Admin::Forms::AutomaticallyManagedProjectFoldersFormComponent.new(@storage))+ end+ %>+<% else %>+ <% local_assigns[:additional_breadcrumb] = [+ link_to(@storage.name, edit_admin_settings_storage_path(@storage)),+ t("storages.label_managed_project_folders_breadcrumb")+ ] %>+ <%= toolbar title: t("storages.page_titles.managed_project_folders.title"),+ subtitle: t("storages.page_titles.managed_project_folders.subtitle")+ %>-<%= labelled_tabular_form_for @storage, url: admin_settings_storage_automatically_managed_project_folders_path(@storage),- method: :patch,- data: {- controller: "storages--automatically-managed-project-folders-form",- 'application-target': "dynamic",- 'storages--automatically-managed-project-folders-form-is-automatically-managed-value': @storage.automatically_managed?,- } do |f| -%>- <div class="form--field -required">- <%= styled_label_tag :automatically_managed, class: "-bold -flex" do %>- <%= t(:"storages.label_managed_project_folders.automatically_managed_folders") %>- <% end %>+ <%= error_messages_for_contract @storage, @errors %>- <div class="form--field-container -horizontal">- <label class="form--field-inline-buttons-container">- <%= angular_component_tag 'spot-switch',- inputs: {- id: "storages_#{@storage.short_provider_type}_storage_automatically_managed",- name: "storages_#{@storage.short_provider_type}_storage[automatically_managed]",- checked: @storage.automatically_managed?,- },- data: {- action: 'change->storages--automatically-managed-project-folders-form#updateDisplay',- }- %>- </label>+ <%= labelled_tabular_form_for @storage, url: admin_settings_storage_automatically_managed_project_folders_path(@storage),+ method: :patch,+ data: {+ controller: "storages--automatically-managed-project-folders-form",+ 'application-target': "dynamic",+ 'storages--automatically-managed-project-folders-form-is-automatically-managed-value': @storage.automatically_managed?,+ } do |f| -%>+ <div class="form--field -required">+ <%= styled_label_tag :automatically_managed, class: "-bold -flex" do %>+ <%= t(:"storages.label_managed_project_folders.automatically_managed_folders") %>+ <% end %>++ <div class="form--field-container -horizontal">+ <label class="form--field-inline-buttons-container">+ <%= angular_component_tag 'spot-switch',+ inputs: {+ id: "storages_#{@storage.short_provider_type}_storage_automatically_managed",+ name: "storages_#{@storage.short_provider_type}_storage[automatically_managed]",+ checked: @storage.automatically_managed?,+ },+ data: {+ action: 'change->storages--automatically-managed-project-folders-form#updateDisplay',+ }+ %>+ </label>+ </div></div>- </div>- <div class="form--field -required"- data-storages--automatically-managed-project-folders-form-target="applicationPasswordInput">- <label class="form--label -bold"> <%= t(:"storages.label_managed_project_folders.application_password") %> </label>- <div class="form--field-container -horizontal">- <%= f.text_field :password,- container_class: "-middle",- no_label: true,- value: nil, # IMPORTANT: We don't want to show the password in the form- placeholder: @storage.password.present? ? "●●●●●●●●●●●●●●●●" : nil- %>+ <div class="form--field -required"+ data-storages--automatically-managed-project-folders-form-target="applicationPasswordInput">+ <label class="form--label -bold"> <%= t(:"storages.label_managed_project_folders.application_password") %> </label>+ <div class="form--field-container -horizontal">+ <%= f.text_field :password,+ container_class: "-middle",+ no_label: true,+ value: nil, # IMPORTANT: We don't want to show the password in the form+ placeholder: @storage.password.present? ? "●●●●●●●●●●●●●●●●" : nil+ %>+ </div>+ <p class="form--field-instructions -xwide">+ <%= t(:"storages.instructions.managed_project_folders_application_password") %>+ <a+ href="<%= Storages::Peripherals::StorageInteraction::Nextcloud::Util+ .join_uri_path(@storage.oauth_application.integration.host, 'settings/admin/openproject') %>"+ target="_blank"+ class="spot-link"+ >+ <span><%= t("storages.instructions.#{@storage.short_provider_type}.integration") %></span>+ </a>+ </p></div>- <p class="form--field-instructions -xwide">- <%= t(:"storages.instructions.managed_project_folders_application_password") %>- <a- href="<%= Storages::Peripherals::StorageInteraction::Nextcloud::Util- .join_uri_path(@storage.oauth_application.integration.host, 'settings/admin/openproject') %>"- target="_blank"- class="spot-link"- >- <span><%= t("storages.instructions.#{@storage.short_provider_type}.integration") %></span>- </a>- </p>- </div>- <div class="form--field">- <% case action_name %>- <% when 'new' %>- <%= styled_button_tag t("storages.buttons.done_complete_setup"), class: "-highlight -with-icon icon-checkmark" %>- <% else %>- <%= styled_button_tag t("storages.buttons.save"), class: "-highlight -with-icon icon-checkmark" %>- <% end %>+ <div class="form--field">+ <% case action_name %>+ <% when 'new' %>+ <%= styled_button_tag t("storages.buttons.done_complete_setup"), class: "-highlight -with-icon icon-checkmark" %>+ <% else %>+ <%= styled_button_tag t("storages.buttons.save"), class: "-highlight -with-icon icon-checkmark" %>+ <% end %>- <%= link_to edit_admin_settings_storage_path(@storage), class: 'button' do %>- <%= spot_icon('cancel') %>- <%= content_tag :span, t(:button_cancel) %>- <% end %>- </div>+ <%= link_to edit_admin_settings_storage_path(@storage), class: 'button' do %>+ <%= spot_icon('cancel') %>+ <%= content_tag :span, t(:button_cancel) %>+ <% end %>+ </div>+ <% end %><% end %>diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlindex f85cd80a4ba..53c38815bff 100644--- a/modules/storages/config/locales/en.yml+++ b/modules/storages/config/locales/en.yml@@ -115,6 +115,7 @@ en:host: "Please add the host address of your storage including the https://. It should not be longer than 255 characters."managed_project_folders_application_password: >Copy this value from:+ managed_project_folders_application_password_caption: "Enable automatic managed folders by copying this value from: %{provider_type_link}."no_storage_set_up: "There are no file storages set up yet."no_specific_folder: "By default, each user will start at their own home folder when they upload a file."automatic_folder: "This will automatically create a root folder for this project and manage the access permissions for each project member."@@ -195,6 +196,7 @@ en:label_edit_storage: "Edit storage"label_edit_storage_host: "Edit storage host"label_edit_storage_oauth_client: "Edit storage OAuth client"+ label_edit_storage_automatically_managed_folders: "Edit storage automatically managed folders"label_existing_manual_folder: "Existing folder with manually managed permissions"label_no_specific_folder: "No specific folder"label_automatic_folder: "New folder with automatically managed permissions"