diff --git a/Gemfile.lock b/Gemfile.lock index 86488c755d02..67827b4a54cc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1056,7 +1056,7 @@ GEM crass (~> 1.0.2) nokogiri (>= 1.12.0) secure_headers (6.5.0) - selenium-devtools (0.128.0) + selenium-devtools (0.129.0) selenium-webdriver (~> 4.2) selenium-webdriver (4.25.0) base64 (~> 0.2) @@ -1172,7 +1172,7 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - webrick (1.8.1) + webrick (1.8.2) websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) diff --git a/docker/prod/artifacthub-repo.yml b/docker/prod/artifacthub-repo.yml index 838eea3382e3..96ec962adbd1 100644 --- a/docker/prod/artifacthub-repo.yml +++ b/docker/prod/artifacthub-repo.yml @@ -9,7 +9,7 @@ # when the hash of the last commit in the branch you set up changes. This does # NOT apply to ownership claim operations, which are processed immediately. # -repositoryID: openproject +repositoryID: 25516830-632d-470a-8eb8-6a5da9b48192 owners: - name: oliverguenther email: o.guenther@openproject.com diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 4fbd9e928233..e11ffd6769e6 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -8304,9 +8304,9 @@ } }, "node_modules/codemirror": { - "version": "5.65.17", - "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.65.17.tgz", - "integrity": "sha512-1zOsUx3lzAOu/gnMAZkQ9kpIHcPYOc9y1Fbm2UVk5UBPkdq380nhkelG0qUwm1f7wPvTbndu9ZYlug35EwAZRQ==" + "version": "5.65.18", + "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.65.18.tgz", + "integrity": "sha512-Gaz4gHnkbHMGgahNt3CA5HBk5lLQBqmD/pBgeB4kQU6OedZmqMBjlRF0LSrp2tJ4wlLNPm2FfaUd1pDy0mdlpA==" }, "node_modules/collection-visit": { "version": "1.0.0", @@ -28028,9 +28028,9 @@ } }, "codemirror": { - "version": "5.65.17", - "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.65.17.tgz", - "integrity": "sha512-1zOsUx3lzAOu/gnMAZkQ9kpIHcPYOc9y1Fbm2UVk5UBPkdq380nhkelG0qUwm1f7wPvTbndu9ZYlug35EwAZRQ==" + "version": "5.65.18", + "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.65.18.tgz", + "integrity": "sha512-Gaz4gHnkbHMGgahNt3CA5HBk5lLQBqmD/pBgeB4kQU6OedZmqMBjlRF0LSrp2tJ4wlLNPm2FfaUd1pDy0mdlpA==" }, "collection-visit": { "version": "1.0.0", diff --git a/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb b/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb index 5c64da713a48..371d24b18ccf 100644 --- a/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb +++ b/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb @@ -69,13 +69,13 @@ def has_ampf_configuration_error? def capabilities @capabilities ||= Peripherals::Registry - .resolve("#{@storage.short_provider_type}.queries.capabilities") + .resolve("#{@storage}.queries.capabilities") .call(storage: @storage, auth_strategy: noop) end def files @files ||= Peripherals::Registry - .resolve("#{@storage.short_provider_type}.queries.files") + .resolve("#{@storage}.queries.files") .call(storage: @storage, auth_strategy: userless, folder: ParentFolder.new(@storage.group_folder)) end diff --git a/modules/storages/app/common/storages/peripherals/one_drive_connection_validator.rb b/modules/storages/app/common/storages/peripherals/one_drive_connection_validator.rb index 478ca840985c..911f8280f51c 100644 --- a/modules/storages/app/common/storages/peripherals/one_drive_connection_validator.rb +++ b/modules/storages/app/common/storages/peripherals/one_drive_connection_validator.rb @@ -57,7 +57,7 @@ def validate def query @query ||= Peripherals::Registry - .resolve("#{@storage.short_provider_type}.queries.files") + .resolve("#{@storage}.queries.files") .call(storage: @storage, auth_strategy:, folder: root_folder) end @@ -173,7 +173,7 @@ def root_folder end def auth_strategy - Peripherals::Registry.resolve("#{@storage.short_provider_type}.authentication.userless") + Peripherals::Registry.resolve("#{@storage}.authentication.userless") .call .with_cache(false) end diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/authentication.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication.rb index 364f52427046..28617553f9c2 100644 --- a/modules/storages/app/common/storages/peripherals/storage_interaction/authentication.rb +++ b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication.rb @@ -58,7 +58,7 @@ def self.authorization_state(storage:, user:) auth_strategy = AuthenticationStrategies::OAuthUserToken.strategy.with_user(user) Registry - .resolve("#{storage.short_provider_type}.queries.auth_check") + .resolve("#{storage}.queries.auth_check") .call(storage:, auth_strategy:) .match( on_success: ->(*) { :connected }, diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/inputs/upload_data.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/inputs/upload_data.rb index c08f2e47d57f..80ed8c417e0a 100644 --- a/modules/storages/app/common/storages/peripherals/storage_interaction/inputs/upload_data.rb +++ b/modules/storages/app/common/storages/peripherals/storage_interaction/inputs/upload_data.rb @@ -36,9 +36,9 @@ module Inputs private_class_method :new def self.build(folder_id:, file_name:, contract: UploadDataContract.new) - contract.call(folder_id:, file_name:).to_monad.fmap do |result| - new(file_name: result[:file_name], folder_id: ParentFolder.new(result[:folder_id])) - end + contract.call(folder_id:, file_name:) + .to_monad + .fmap { |result| new(file_name: result[:file_name], folder_id: result[:folder_id]) } end end end diff --git a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb index 0f8d107db56c..500628a42f38 100644 --- a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb +++ b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb @@ -8,7 +8,7 @@ ) do |form| flex_layout do |oauth_client_row| oauth_client_row.with_row(mb: 3) do - render(Primer::Beta::Text.new(font_weight: :bold)) { I18n.t("storages.file_storage_view.#{storage.short_provider_type}_oauth") } + render(Primer::Beta::Text.new(font_weight: :bold)) { I18n.t("storages.file_storage_view.#{storage}_oauth") } end oauth_client_row.with_row(mb: 3) do diff --git a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.rb b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.rb index db9ee4cf6d34..d2fda9355e96 100644 --- a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.rb +++ b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.rb @@ -52,8 +52,8 @@ def cancel_button_path end def storage_provider_credentials_instructions - I18n.t("storages.instructions.#{storage.short_provider_type}.oauth_configuration", - application_link_text: send(:"#{storage.short_provider_type}_integration_link")).html_safe + I18n.t("storages.instructions.#{storage}.oauth_configuration", + application_link_text: send(:"#{storage}_integration_link")).html_safe end private diff --git a/modules/storages/app/components/storages/admin/oauth_client_info_component.html.erb b/modules/storages/app/components/storages/admin/oauth_client_info_component.html.erb index d6c7f7493413..04c67a9394bb 100644 --- a/modules/storages/app/components/storages/admin/oauth_client_info_component.html.erb +++ b/modules/storages/app/components/storages/admin/oauth_client_info_component.html.erb @@ -5,7 +5,7 @@ concat( render( Primer::Beta::Text.new(font_weight: :bold, mr: 1, test_selector: 'storage-oauth-client-label') - ) { I18n.t("storages.file_storage_view.#{storage.short_provider_type}_oauth") } + ) { I18n.t("storages.file_storage_view.#{storage}_oauth") } ) concat(configuration_check_label_for(:storage_oauth_client_configured)) end diff --git a/modules/storages/app/components/storages/admin/oauth_client_info_component.rb b/modules/storages/app/components/storages/admin/oauth_client_info_component.rb index 71e3bbc37596..b4379d32cf89 100644 --- a/modules/storages/app/components/storages/admin/oauth_client_info_component.rb +++ b/modules/storages/app/components/storages/admin/oauth_client_info_component.rb @@ -46,7 +46,7 @@ def self.wrapper_key = :storage_oauth_client_section def edit_icon_button_options label = I18n.t("storages.buttons.replace_oauth_client", - provider_type: I18n.t("storages.provider_types.#{storage.short_provider_type}.name")) + provider_type: I18n.t("storages.provider_types.#{storage}.name")) { icon: oauth_client_configured? ? :sync : :pencil, @@ -64,7 +64,7 @@ def edit_icon_button_options def edit_icon_button_data_options {}.tap do |data_h| if oauth_client_configured? - provider_type = I18n.t("storages.provider_types.#{storage.short_provider_type}.name") + provider_type = I18n.t("storages.provider_types.#{storage}.name") data_h[:turbo_confirm] = I18n.t("storages.confirm_replace_oauth_client", provider_type:) end data_h[:turbo_stream] = true diff --git a/modules/storages/app/components/storages/admin/storage_row_component.html.erb b/modules/storages/app/components/storages/admin/storage_row_component.html.erb index ce9eaea2a5b6..d44b4819eb27 100644 --- a/modules/storages/app/components/storages/admin/storage_row_component.html.erb +++ b/modules/storages/app/components/storages/admin/storage_row_component.html.erb @@ -21,7 +21,7 @@ end grid.with_area(:provider, tag: :div, color: :subtle, mr: 3, hide: :sm, data: { 'test-selector': 'storage-provider' }) do - render(Primer::Beta::Truncate.new(font_weight: :light)) { I18n.t("storages.provider_types.#{storage.short_provider_type}.name") } + render(Primer::Beta::Truncate.new(font_weight: :light)) { I18n.t("storages.provider_types.#{storage}.name") } end grid.with_area(:time, tag: :div, color: :subtle) do diff --git a/modules/storages/app/components/storages/admin/storage_view_information.rb b/modules/storages/app/components/storages/admin/storage_view_information.rb index baf91d6b529e..d019b95d3835 100644 --- a/modules/storages/app/components/storages/admin/storage_view_information.rb +++ b/modules/storages/app/components/storages/admin/storage_view_information.rb @@ -1,5 +1,33 @@ # frozen_string_literal: true +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 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 module StorageViewInformation private @@ -9,7 +37,7 @@ def editable_storage? end def storage_description - [I18n.t("storages.provider_types.#{storage.short_provider_type}.name"), + [I18n.t("storages.provider_types.#{storage}.name"), storage.name, storage.host].compact.join(" - ") end @@ -62,7 +90,7 @@ def provider_oauth_client_description if storage.oauth_client "#{I18n.t('storages.label_oauth_client_id')}: #{storage.oauth_client.client_id}" else - I18n.t("storages.configuration_checks.oauth_client_incomplete.#{storage.short_provider_type}") + I18n.t("storages.configuration_checks.oauth_client_incomplete.#{storage}") end end @@ -70,7 +98,7 @@ def provider_redirect_uri_description if storage.oauth_client "#{I18n.t('storages.label_uri')}: #{storage.oauth_client.redirect_uri}" else - I18n.t("storages.configuration_checks.redirect_uri_incomplete.#{storage.short_provider_type}") + I18n.t("storages.configuration_checks.redirect_uri_incomplete.#{storage}") end end end diff --git a/modules/storages/app/components/storages/admin/storages/oauth_access_grant_nudge_modal_component.rb b/modules/storages/app/components/storages/admin/storages/oauth_access_grant_nudge_modal_component.rb index f879ab909b11..23cc88b340d1 100644 --- a/modules/storages/app/components/storages/admin/storages/oauth_access_grant_nudge_modal_component.rb +++ b/modules/storages/app/components/storages/admin/storages/oauth_access_grant_nudge_modal_component.rb @@ -57,7 +57,7 @@ def heading_text = I18n.t("storages.oauth_grant_nudge_modal.heading", provider_t def waiting_title = I18n.t("storages.oauth_grant_nudge_modal.requesting_access_to", storage: storage.name) def cancel_button_text = I18n.t(:button_close) def body_text = I18n.t("storages.oauth_grant_nudge_modal.storage_admin.description", provider_type:) - def provider_type = I18n.t("storages.provider_types.#{storage.short_provider_type}.name") + def provider_type = I18n.t("storages.provider_types.#{storage}.name") def login_button_aria_label I18n.t("storages.oauth_grant_nudge_modal.login_button_aria_label", storage: storage.name) diff --git a/modules/storages/app/components/storages/open_project_storage_modal_component.rb b/modules/storages/app/components/storages/open_project_storage_modal_component.rb index 9ad4d22c8981..7af3c0811d76 100644 --- a/modules/storages/app/components/storages/open_project_storage_modal_component.rb +++ b/modules/storages/app/components/storages/open_project_storage_modal_component.rb @@ -1,3 +1,7 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # # This program is free software; you can redistribute it and/or diff --git a/modules/storages/app/components/storages/open_project_storage_modal_component/body.rb b/modules/storages/app/components/storages/open_project_storage_modal_component/body.rb index 583760190f1e..880848165a17 100644 --- a/modules/storages/app/components/storages/open_project_storage_modal_component/body.rb +++ b/modules/storages/app/components/storages/open_project_storage_modal_component/body.rb @@ -1,3 +1,7 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # # This program is free software; you can redistribute it and/or @@ -24,7 +28,7 @@ # See COPYRIGHT and LICENSE files for more details. #++ -class Storages::OpenProjectStorageModalComponent::Body < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent +class Storages::OpenProjectStorageModalComponent::Body < ApplicationComponent options success_title: I18n.t("storages.open_project_storage_modal.success.title"), success_subtitle: I18n.t("storages.open_project_storage_modal.success.subtitle"), waiting_title: I18n.t("storages.open_project_storage_modal.waiting.title"), diff --git a/modules/storages/app/contracts/storages/storages/base_contract.rb b/modules/storages/app/contracts/storages/storages/base_contract.rb index 24180cddf275..9ba945989d20 100644 --- a/modules/storages/app/contracts/storages/storages/base_contract.rb +++ b/modules/storages/app/contracts/storages/storages/base_contract.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# -- copyright +#-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # diff --git a/modules/storages/app/contracts/storages/storages/create_contract.rb b/modules/storages/app/contracts/storages/storages/create_contract.rb index d387a435fcb0..f884f3e90442 100644 --- a/modules/storages/app/contracts/storages/storages/create_contract.rb +++ b/modules/storages/app/contracts/storages/storages/create_contract.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# -- copyright +#-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # diff --git a/modules/storages/app/contracts/storages/storages/nextcloud_contract.rb b/modules/storages/app/contracts/storages/storages/nextcloud_contract.rb index 88f9089d3e08..7f718f7e9d5e 100644 --- a/modules/storages/app/contracts/storages/storages/nextcloud_contract.rb +++ b/modules/storages/app/contracts/storages/storages/nextcloud_contract.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# -- copyright +#-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # diff --git a/modules/storages/app/contracts/storages/storages/one_drive_contract.rb b/modules/storages/app/contracts/storages/storages/one_drive_contract.rb index 76fd7a62b0b7..b23554409441 100644 --- a/modules/storages/app/contracts/storages/storages/one_drive_contract.rb +++ b/modules/storages/app/contracts/storages/storages/one_drive_contract.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# -- copyright +#-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # diff --git a/modules/storages/app/contracts/storages/storages/update_contract.rb b/modules/storages/app/contracts/storages/storages/update_contract.rb index e78ff523ff6f..1345ed147a6a 100644 --- a/modules/storages/app/contracts/storages/storages/update_contract.rb +++ b/modules/storages/app/contracts/storages/storages/update_contract.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# -- copyright +#-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # diff --git a/modules/storages/app/controllers/storages/project_storages_controller.rb b/modules/storages/app/controllers/storages/project_storages_controller.rb index 36aab106ef62..cb3b738e4d37 100644 --- a/modules/storages/app/controllers/storages/project_storages_controller.rb +++ b/modules/storages/app/controllers/storages/project_storages_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -45,7 +47,7 @@ def open # check if user "see" project_folder if @object.project_folder_id.present? ::Storages::Peripherals::Registry - .resolve("#{@storage.short_provider_type}.queries.file_info") + .resolve("#{@storage}.queries.file_info") .call(storage: @storage, auth_strategy:, file_id: @object.project_folder_id) .match( on_success: user_can_read_project_folder, diff --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.rb index 429342b5800d..4e2609a2fc06 100644 --- 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.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -58,7 +60,7 @@ def provider_type_link href: Storages::UrlBuilder.url(@storage.uri, "settings/admin/openproject"), target: "_blank" ) - ) { I18n.t("storages.instructions.#{@storage.short_provider_type}.integration") } + ) { I18n.t("storages.instructions.#{@storage}.integration") } end end end diff --git a/modules/storages/app/forms/storages/admin/oauth_client_form.rb b/modules/storages/app/forms/storages/admin/oauth_client_form.rb index 35a61299b595..58ce31a07e3d 100644 --- a/modules/storages/app/forms/storages/admin/oauth_client_form.rb +++ b/modules/storages/app/forms/storages/admin/oauth_client_form.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -69,11 +71,11 @@ def provider_default_client_secret_input_options end def label_client_id - I18n.t("storages.provider_types.#{@storage.short_provider_type}.label_oauth_client_id") + I18n.t("storages.provider_types.#{@storage}.label_oauth_client_id") end def label_client_secret - I18n.t("storages.provider_types.#{@storage.short_provider_type}.label_oauth_client_secret") + I18n.t("storages.provider_types.#{@storage}.label_oauth_client_secret") end end end diff --git a/modules/storages/app/models/queries/storages/projects/filter/storages_filter.rb b/modules/storages/app/models/queries/storages/projects/filter/storages_filter.rb index 8b6d563d43e4..b1c620aad78f 100644 --- a/modules/storages/app/models/queries/storages/projects/filter/storages_filter.rb +++ b/modules/storages/app/models/queries/storages/projects/filter/storages_filter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# -- copyright +#-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH # @@ -26,7 +26,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # See COPYRIGHT and LICENSE files for more details. -# ++ +#++ # # This filter is used to find projects (including archived projects) that use one diff --git a/modules/storages/app/models/storages/project_storage.rb b/modules/storages/app/models/storages/project_storage.rb index 72ff63a3f5ff..5eee6413f308 100644 --- a/modules/storages/app/models/storages/project_storage.rb +++ b/modules/storages/app/models/storages/project_storage.rb @@ -88,11 +88,11 @@ def open(user) if project_folder_not_accessible?(user) Peripherals::Registry - .resolve("#{storage.short_provider_type}.queries.open_storage") + .resolve("#{storage}.queries.open_storage") .call(storage:, auth_strategy:) else Peripherals::Registry - .resolve("#{storage.short_provider_type}.queries.open_file_link") + .resolve("#{storage}.queries.open_file_link") .call(storage:, auth_strategy:, file_id: project_folder_id) end end @@ -118,7 +118,7 @@ def open_with_connection_ensured def managed_folder_identifier @managed_folder_identifier ||= - Peripherals::Registry.resolve("#{storage.short_provider_type}.models.managed_folder_identifier").new(self) + Peripherals::Registry.resolve("#{storage}.models.managed_folder_identifier").new(self) end def project_folder_not_accessible?(user) diff --git a/modules/storages/app/services/storages/oauth_applications/create_service.rb b/modules/storages/app/services/storages/oauth_applications/create_service.rb index 76120a879a87..e8c19d757ce8 100644 --- a/modules/storages/app/services/storages/oauth_applications/create_service.rb +++ b/modules/storages/app/services/storages/oauth_applications/create_service.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -45,7 +47,7 @@ def call ::OAuth::Applications::CreateService .new(user:) .call( - name: "#{storage.name} (#{I18n.t("storages.provider_types.#{storage.short_provider_type}.name")})", + name: "#{storage.name} (#{I18n.t("storages.provider_types.#{storage}.name")})", redirect_uri: File.join(storage.host, "index.php/apps/integration_openproject/oauth-redirect"), scopes: "api_v3", confidential: true, diff --git a/modules/storages/app/services/storages/project_storages/copy_project_folders_service.rb b/modules/storages/app/services/storages/project_storages/copy_project_folders_service.rb index de5059ca198f..3b3e4caae62e 100644 --- a/modules/storages/app/services/storages/project_storages/copy_project_folders_service.rb +++ b/modules/storages/app/services/storages/project_storages/copy_project_folders_service.rb @@ -74,7 +74,7 @@ def manually_managed_source?(source) def initiate_copy(storage, source_path, destination_path) Peripherals::Registry - .resolve("#{storage.short_provider_type}.commands.copy_template_folder") + .resolve("#{storage}.commands.copy_template_folder") .call(auth_strategy: auth_strategy(storage.short_provider_type), storage:, source_path:, diff --git a/modules/storages/app/services/storages/storage_file_service.rb b/modules/storages/app/services/storages/storage_file_service.rb new file mode 100644 index 000000000000..6b664d92f1a5 --- /dev/null +++ b/modules/storages/app/services/storages/storage_file_service.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 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 + class StorageFileService < BaseService + def self.call(storage:, user:, file_id:) + new.call(storage:, user:, file_id:) + end + + def call(user:, storage:, file_id:) + auth_strategy = strategy(storage, user) + + info "Requesting file #{file_id} information on #{storage.name}" + Peripherals::Registry.resolve("#{storage}.queries.file_info").call(storage:, auth_strategy:, file_id:) + end + + private + + def strategy(storage, user) + Peripherals::Registry.resolve("#{storage}.authentication.user_bound").call(user:) + end + end +end diff --git a/modules/storages/app/services/storages/storage_files_service.rb b/modules/storages/app/services/storages/storage_files_service.rb new file mode 100644 index 000000000000..ce4ab8f9a4bc --- /dev/null +++ b/modules/storages/app/services/storages/storage_files_service.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 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 + class StorageFilesService < BaseService + def self.call(storage:, user:, folder:) + new.call(storage:, user:, folder:) + end + + def call(user:, storage:, folder:) + auth_strategy = strategy(storage, user) + + info "Requesting all the files under folder #{folder} for #{storage.name}" + Peripherals::Registry.resolve("#{storage}.queries.files").call(storage:, auth_strategy:, folder:) + end + + private + + def strategy(storage, user) + Peripherals::Registry.resolve("#{storage}.authentication.user_bound").call(user:) + end + end +end diff --git a/modules/storages/app/services/storages/storages/update_service.rb b/modules/storages/app/services/storages/storages/update_service.rb index efa30027ebbd..7f50b94f2ddd 100644 --- a/modules/storages/app/services/storages/storages/update_service.rb +++ b/modules/storages/app/services/storages/storages/update_service.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + #-- copyright # OpenProject is an open source project management software. # Copyright (C) the OpenProject GmbH @@ -32,7 +34,7 @@ class UpdateService < ::BaseServices::Update protected def after_perform(service_call) - super(service_call) + super storage = service_call.result if storage.provider_type_nextcloud? @@ -40,7 +42,7 @@ def after_perform(service_call) persist_service_result = ::OAuth::Applications::UpdateService .new(model: application, user:) .call( - name: "#{storage.name} (#{I18n.t("storages.provider_types.#{storage.short_provider_type}.name")})", + name: "#{storage.name} (#{I18n.t("storages.provider_types.#{storage}.name")})", redirect_uri: File.join(storage.host, "index.php/apps/integration_openproject/oauth-redirect") ) service_call.add_dependent!(persist_service_result) diff --git a/modules/storages/app/services/storages/upload_link_service.rb b/modules/storages/app/services/storages/upload_link_service.rb index 95040b50f205..dfc4b7017e3f 100644 --- a/modules/storages/app/services/storages/upload_link_service.rb +++ b/modules/storages/app/services/storages/upload_link_service.rb @@ -56,10 +56,9 @@ def call(user:, upload_data:) private def request_upload_link(auth_strategy, upload_data) - Peripherals::Registry - .resolve("#{@storage.short_provider_type}.queries.upload_link") - .call(storage: @storage, auth_strategy:, upload_data:) - .on_failure do |error| + Peripherals::Registry.resolve("#{@storage}.queries.upload_link") + .call(storage: @storage, auth_strategy:, upload_data:) + .on_failure do |error| add_error(:base, error.errors, options: { storage_name: @storage.name, folder: upload_data.folder_id }) log_storage_error(error.errors) @result.success = false @@ -75,7 +74,7 @@ def validate_input(...) end def auth_strategy(user) - Peripherals::Registry.resolve("#{@storage.short_provider_type}.authentication.user_bound").call(user:) + Peripherals::Registry.resolve("#{@storage}.authentication.user_bound").call(user:) end end end diff --git a/modules/storages/app/views/storages/admin/storages/_new.html.erb b/modules/storages/app/views/storages/admin/storages/_new.html.erb index 37eabdfb3c99..3c315c263f29 100644 --- a/modules/storages/app/views/storages/admin/storages/_new.html.erb +++ b/modules/storages/app/views/storages/admin/storages/_new.html.erb @@ -55,7 +55,7 @@ See COPYRIGHT and LICENSE files for more details.