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[#47147] Allow writeable project folder on manual mode selection
Kabiru Mwenjadcbd62dfb309
diff --git a/modules/storages/app/controllers/storages/admin/projects_storages_controller.rb b/modules/storages/app/controllers/storages/admin/projects_storages_controller.rbindex aaef473acb8..a4f32a18f07 100644--- a/modules/storages/app/controllers/storages/admin/projects_storages_controller.rb+++ b/modules/storages/app/controllers/storages/admin/projects_storages_controller.rb@@ -154,7 +154,7 @@ class Storages::Admin::ProjectsStoragesController < Projects::SettingsController# "params" is an instance of ActionController::Parametersparams.require(:storages_project_storage)- .permit('storage_id', 'project_folder_mode')+ .permit('storage_id', 'project_folder_mode', 'project_folder_id').to_h.reverse_merge(project_id: @project.id)enddiff --git a/modules/storages/app/views/storages/project_settings/_form.html.erb b/modules/storages/app/views/storages/project_settings/_form.html.erbindex 42921e3655a..7ba7290c073 100644--- a/modules/storages/app/views/storages/project_settings/_form.html.erb+++ b/modules/storages/app/views/storages/project_settings/_form.html.erb@@ -35,4 +35,32 @@</p></div>-<%= styled_button_tag t(:button_add), class: "-highlight -with-icon icon-checkmark" %>+<div style="display:none;" id="storages_manual_folder_selection" class="form--field -required">+ <label class="form--label -bold"> <%= t(:"storages.label_existing_manual_folder_selection") %> </label>+ <div class="form--field-container -horizontal">+ <%= f.text_field :project_folder_id,+ placeholder: t(:"storages.placeholder_existing_folder_selection"),+ container_class: "-middle",+ no_label: true+ %>+ </div>+</div>++<div class="form--field">+ <%= styled_button_tag t(:button_add), class: "-highlight -with-icon icon-checkmark" %>+</div>++<%= nonced_javascript_tag do -%>+ jQuery(function($) {+ <%# Show manual folder selection on reload when checked %>+ $("#storages_project_storage_project_folder_mode_manual").is(':checked') && $("#storages_manual_folder_selection").show();++ $("input[type='radio']").change(function() {+ if ($(this).val() == 'manual') {+ $("#storages_manual_folder_selection").show();+ } else {+ $("#storages_manual_folder_selection").hide();+ }+ })+ });+<% end -%>diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlindex ff66df59803..7a237657ef8 100644--- a/modules/storages/config/locales/en.yml+++ b/modules/storages/config/locales/en.yml@@ -79,6 +79,7 @@ en:project_storage: >Are you sure you want to remove this file storage from this project? This will alsoremove all links to files stored in this storage for this project.+ placeholder_existing_folder_selection: "Select a folder"label_creator: "Creator"label_file_link: "File link"label_file_links: "File links"@@ -92,6 +93,7 @@ en:label_provider_type: "Provider type"label_new_storage: "New storage"label_existing_manual_folder: "Existing folder with manually managed permissions"+ label_existing_manual_folder_selection: "Existing folder selection"label_no_specific_folder: "No specific folder"label_storage: "Storage"label_storages: "Storages"diff --git a/modules/storages/spec/features/manage_project_storage_spec.rb b/modules/storages/spec/features/manage_project_storage_spec.rbindex 57d6e141b9e..636f13186bd 100644--- a/modules/storages/spec/features/manage_project_storage_spec.rb+++ b/modules/storages/spec/features/manage_project_storage_spec.rb@@ -54,7 +54,7 @@ describe 'Activation of storages in projects', js: true dologin_as userend- it 'adds and removes storages to projects' do+ it 'adds, edits and removes storages to projects' do# Go to Projects -> Settings -> File Storagesvisit project_settings_general_path(project)page.find('.settings-projects-storages-menu-item').click@@ -69,6 +69,7 @@ describe 'Activation of storages in projects', js: true doexpect(page).to have_current_path new_project_settings_projects_storage_path(project_id: project)expect(page).to have_text('Add a file storage')page.find_by_id('storages_project_storage_project_folder_mode_manual').click+ page.find_by_id('storages_project_storage_project_folder_id').set('Project#1')page.click_button('Add')# The list of enabled file storages should now contain Storage 1@@ -82,9 +83,12 @@ describe 'Activation of storages in projects', js: true doexpect(page).to have_text('Edit the file storage to this project')# The project folder mode should be manualexpect(page).to have_checked_field('storages_project_storage_project_folder_mode_manual')+ expect(page).to have_field('storages_project_storage_project_folder_id', with: 'Project#1')- # Change the project folder mode to inactive+ # Change the project folder mode to inactive, project folder is hidden but retainedpage.find_by_id('storages_project_storage_project_folder_mode_inactive').click+ expect(page).not_to have_field('storages_project_storage_project_folder_id', with: 'Project#1')+ expect(page).to have_css('#storages_project_storage_project_folder_id', visible: :hidden)page.click_button('Add')# The list of enabled file storages should still contain Storage 1