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
[#49760] Amend create storage form
Eric Schubertbd1ca550af0f
diff --git a/app/contracts/oauth_clients/create_contract.rb b/app/contracts/oauth_clients/create_contract.rbindex 72646e3a087..858ea2d6d47 100644--- a/app/contracts/oauth_clients/create_contract.rb+++ b/app/contracts/oauth_clients/create_contract.rb@@ -34,7 +34,7 @@ module OAuthClientsvalidates :client_id, presence: true, length: { maximum: 255 }attribute :client_secret, writable: true- validates :client_secret, presence: true, length: { maximum: 255 }+ validates :client_secret, length: { maximum: 255 }attribute :integration_type, writable: truevalidates :integration_type, presence: truediff --git a/frontend/src/stimulus/controllers/dynamic/storages/oauth-client-form.controller.ts b/frontend/src/stimulus/controllers/dynamic/storages/oauth-client-form.controller.tsnew file mode 100644index 00000000000..3bd33490763--- /dev/null+++ b/frontend/src/stimulus/controllers/dynamic/storages/oauth-client-form.controller.ts@@ -0,0 +1,63 @@+/*+ * -- 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 StorageFormController extends Controller {+ static targets = [+ 'clientId',+ 'redirectUri',+ ];++ static values = {+ clientIdMissing: String,+ };++ declare readonly clientIdTarget:HTMLInputElement;+ declare readonly redirectUriTarget:HTMLInputElement;++ declare readonly clientIdMissingValue:string;++ connect():void {+ this.clientIdTarget.addEventListener('input', () => {+ this.redirectUriTarget.value = this.redirectUri();+ });++ this.redirectUriTarget.value = this.redirectUri();+ }++ private redirectUri():string {+ if (this.clientIdTarget.value === '') {+ return this.clientIdMissingValue;+ }++ return `${window.location.origin}/oauth_clients/${this.clientIdTarget.value}/callback`;+ }+}diff --git a/frontend/src/stimulus/controllers/dynamic/storages/storage-form.controller.ts b/frontend/src/stimulus/controllers/dynamic/storages/storage-form.controller.tsnew file mode 100644index 00000000000..5c4aa5d2c1e--- /dev/null+++ b/frontend/src/stimulus/controllers/dynamic/storages/storage-form.controller.ts@@ -0,0 +1,81 @@+/*+ * -- 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 StorageFormController extends Controller {+ static targets = [+ 'selectProviderType',+ 'storageName',+ 'storageUrl',+ 'fieldset',+ ];++ static values = {+ oneDrivePlaceholder: String,+ nextcloudPlaceholder: String,+ };++ declare readonly selectProviderTypeTarget:HTMLSelectElement;+ declare readonly storageNameTarget:HTMLInputElement;+ declare readonly storageUrlTarget:HTMLElement;+ declare readonly fieldsetTarget:HTMLFieldSetElement;++ declare readonly nextcloudPlaceholderValue:string;+ declare readonly oneDrivePlaceholderValue:string;++ private urlFormField:HTMLElement;++ connect() {+ this.selectProviderTypeTarget.addEventListener('change', () => {+ this.updateForm();+ });++ this.urlFormField = this.storageUrlTarget;+ this.updateForm();+ }++ private updateForm() {+ const option = this.selectProviderTypeTarget.options[this.selectProviderTypeTarget.selectedIndex];++ switch (option.value) {+ case 'Storages::NextcloudStorage':+ this.storageNameTarget.placeholder = this.nextcloudPlaceholderValue;+ this.fieldsetTarget.append(this.urlFormField);+ break;+ case 'Storages::OneDriveStorage':+ this.storageNameTarget.placeholder = this.oneDrivePlaceholderValue;+ this.storageUrlTarget.remove();+ break;+ default:+ throw new Error(`unknown provider type ${option.value}`);+ }+ }+}diff --git a/modules/storages/app/constants/storages/admin.rb b/modules/storages/app/constants/storages/admin.rbindex f2058a8dbcf..f56daeaf547 100644--- a/modules/storages/app/constants/storages/admin.rb+++ b/modules/storages/app/constants/storages/admin.rb@@ -30,5 +30,6 @@ module Storagesmodule AdminLABEL_OAUTH_CLIENT_ID = 'OAuth Client ID'.freezeLABEL_OAUTH_CLIENT_SECRET = 'OAuth Client Secret'.freeze+ LABEL_OAUTH_REDIRECT_URI = 'OAuth Redirect URI'.freezeendenddiff --git a/modules/storages/app/contracts/storages/storages/base_contract.rb b/modules/storages/app/contracts/storages/storages/base_contract.rbindex f76c92c6652..83bd0bc1d5c 100644--- a/modules/storages/app/contracts/storages/storages/base_contract.rb+++ b/modules/storages/app/contracts/storages/storages/base_contract.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) 2012-2023 the OpenProject GmbH#@@ -46,46 +48,6 @@ module Storages::Storagesattribute :provider_typevalidates :provider_type, inclusion: { in: Storages::Storage::PROVIDER_TYPES }- attribute :host- validates :host, url: { message: I18n.t('activerecord.errors.messages.invalid_url') }, length: { maximum: 255 }- # Check that a host actually is a storage server.- # But only do so if the validations above for URL were successful.- validates :host, secure_context_uri: true, nextcloud_compatible_host: true, unless: -> { errors.include?(:host) }-attribute :provider_fields- attribute :automatically_managed-- attribute :username- validates :username, presence: true, if: :nextcloud_storage_automatically_managed?- validates :username, absence: true,- unless: -> { nextcloud_storage_automatically_managed? || nextcloud_default_storage_username? }-- attribute :password- validates :password, presence: true, if: :nextcloud_storage_automatically_managed?- validates :password, absence: true, unless: :nextcloud_storage_automatically_managed?-- validate do- if nextcloud_storage_automatically_managed? && errors.exclude?(:password)- NextcloudApplicationCredentialsValidator.new(self).call- end- end-- private-- def nextcloud_storage_automatically_managed?- return false unless nextcloud_storage?-- @model.automatically_managed?- end-- def nextcloud_default_storage_username?- return false unless nextcloud_storage?-- @model.username == @model.provider_fields_defaults[:username]- end-- def nextcloud_storage?- @model.is_a?(Storages::NextcloudStorage)- endendenddiff --git a/modules/storages/app/contracts/storages/storages/nextcloud_base_contract.rb b/modules/storages/app/contracts/storages/storages/nextcloud_base_contract.rbnew file mode 100644index 00000000000..b090fd076a4--- /dev/null+++ b/modules/storages/app/contracts/storages/storages/nextcloud_base_contract.rb@@ -0,0 +1,75 @@+# 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::Storages+ class NextcloudBaseContract < BaseContract+ attribute :host+ validates :host, url: { message: I18n.t('activerecord.errors.messages.invalid_url') }, length: { maximum: 255 }+ # Check that a host actually is a storage server.+ # But only do so if the validations above for URL were successful.+ validates :host, secure_context_uri: true, nextcloud_compatible_host: true, unless: -> { errors.include?(:host) }++ attribute :automatically_managed++ attribute :username+ validates :username, presence: true, if: :nextcloud_storage_automatically_managed?+ validates :username,+ absence: true,+ unless: -> { nextcloud_storage_automatically_managed? || nextcloud_default_storage_username? }++ attribute :password+ validates :password, presence: true, if: :nextcloud_storage_automatically_managed?+ validates :password, absence: true, unless: :nextcloud_storage_automatically_managed?++ validate do+ if nextcloud_storage_automatically_managed? && errors.exclude?(:password)+ NextcloudApplicationCredentialsValidator.new(self).call+ end+ end++ private++ def nextcloud_storage_automatically_managed?+ return false unless nextcloud_storage?++ @model.automatically_managed?+ end++ def nextcloud_default_storage_username?+ return false unless nextcloud_storage?++ @model.username == @model.provider_fields_defaults[:username]+ end++ def nextcloud_storage?+ @model.is_a?(Storages::NextcloudStorage)+ end+ end+enddiff --git a/modules/storages/app/contracts/storages/storages/create_contract.rb b/modules/storages/app/contracts/storages/storages/nextcloud_create_contract.rbsimilarity index 76%rename from modules/storages/app/contracts/storages/storages/create_contract.rbrename to modules/storages/app/contracts/storages/storages/nextcloud_create_contract.rbindex 9045a8eb976..2b27889d1ce 100644--- a/modules/storages/app/contracts/storages/storages/create_contract.rb+++ b/modules/storages/app/contracts/storages/storages/nextcloud_create_contract.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) 2012-2023 the OpenProject GmbH#@@ -26,13 +28,8 @@# See COPYRIGHT and LICENSE files for more details.#++-# See also: base_contract.rb for commentsmodule Storages::Storages- # We create the empty class here, so that other pieces of code that looks for the contract in its default place will- # find it. So, the CreateService for Storages will expect its contract to be here.- #- # We inherit from a BaseContract as the BaseContract here is sharing a lot in common with the UpdateContract.- class CreateContract < ::Storages::Storages::BaseContract+ class NextcloudCreateContract < ::Storages::Storages::NextcloudBaseContractattribute :creatorvalidate :creator_must_be_userdiff --git a/modules/storages/app/contracts/storages/storages/nextcloud_update_contract.rb b/modules/storages/app/contracts/storages/storages/nextcloud_update_contract.rbnew file mode 100644index 00000000000..2c79c4988c2--- /dev/null+++ b/modules/storages/app/contracts/storages/storages/nextcloud_update_contract.rb@@ -0,0 +1,34 @@+# 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::Storages+ class NextcloudUpdateContract < ::Storages::Storages::NextcloudBaseContract+ end+enddiff --git a/modules/storages/app/contracts/storages/storages/one_drive_base_contract.rb b/modules/storages/app/contracts/storages/storages/one_drive_base_contract.rbnew file mode 100644index 00000000000..df73a8adb8f--- /dev/null+++ b/modules/storages/app/contracts/storages/storages/one_drive_base_contract.rb@@ -0,0 +1,36 @@+# 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::Storages+ class OneDriveBaseContract < BaseContract+ attribute :host+ validates :host, absence: true+ end+enddiff --git a/modules/storages/app/contracts/storages/storages/one_drive_create_contract.rb b/modules/storages/app/contracts/storages/storages/one_drive_create_contract.rbnew file mode 100644index 00000000000..49f491cf073--- /dev/null+++ b/modules/storages/app/contracts/storages/storages/one_drive_create_contract.rb@@ -0,0 +1,44 @@+# 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::Storages+ class OneDriveCreateContract < ::Storages::Storages::OneDriveBaseContract+ attribute :creator+ validate :creator_must_be_user++ private++ def creator_must_be_user+ unless creator == user+ errors.add(:creator, :invalid)+ end+ end+ end+enddiff --git a/modules/storages/app/contracts/storages/storages/update_contract.rb b/modules/storages/app/contracts/storages/storages/one_drive_update_contract.rbsimilarity index 91%rename from modules/storages/app/contracts/storages/storages/update_contract.rbrename to modules/storages/app/contracts/storages/storages/one_drive_update_contract.rbindex 9867aae10ae..3864ce425c8 100644--- a/modules/storages/app/contracts/storages/storages/update_contract.rb+++ b/modules/storages/app/contracts/storages/storages/one_drive_update_contract.rb@@ -1,4 +1,6 @@-#-- copyright+# frozen_string_literal: true++# -- copyright# OpenProject is an open source project management software.# Copyright (C) 2012-2023 the OpenProject GmbH#@@ -26,8 +28,7 @@# See COPYRIGHT and LICENSE files for more details.#++-# See also: base_contract.rb for commentsmodule Storages::Storages- class UpdateContract < ::Storages::Storages::BaseContract+ class OneDriveUpdateContract < ::Storages::Storages::OneDriveBaseContractendenddiff --git a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rbindex d4a823d0011..8de424d6b22 100644--- a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb+++ b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb@@ -59,18 +59,23 @@ class Storages::Admin::OAuthClientsController < ApplicationController# Called by: Global app/config/routes.rb to serve Web pagedef create # rubocop:disable Metrics/AbcSizeservice_result = ::OAuthClients::CreateService.new(user: User.current)- .call(permitted_oauth_client_params.merge(integration: @storage))+ .call(oauth_client_params.merge(integration: @storage))@oauth_client = service_result.result- if service_result.success?++ service_result.on_failure do+ @errors = service_result.errors+ render '/storages/admin/storages/new_oauth_client'+ end++ service_result.on_success doflash[:notice] = I18n.t(:notice_successful_create)- if @storage.automatic_management_unspecified?++ if @storage.provider_type == ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD &&+ @storage.automatic_management_unspecified?redirect_to new_admin_settings_storage_automatically_managed_project_folders_path(@storage)elseredirect_to edit_admin_settings_storage_path(@storage)end- else- @errors = service_result.errors- render '/storages/admin/storages/new_oauth_client'endend@@ -91,7 +96,7 @@ class Storages::Admin::OAuthClientsController < ApplicationController# Called by create and update above in order to check if the# update parameters are correctly set.- def permitted_oauth_client_params+ def oauth_client_paramsparams.require(:oauth_client).permit('client_id', 'client_secret')diff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rbindex 199be318528..9949badeffa 100644--- a/modules/storages/app/controllers/storages/admin/storages_controller.rb+++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb@@ -64,7 +64,7 @@ class Storages::Admin::StoragesController < ApplicationController# Set default parameters using a "service".# See also: storages/services/storages/storages/set_attributes_services.rb# That service inherits from ::BaseServices::SetAttributes- @object = ::Storages::Storages::SetAttributesService+ @storage = ::Storages::Storages::SetAttributesService.new(user: current_user,model: Storages::NextcloudStorage.new,contract_class: EmptyContract)@@ -72,25 +72,46 @@ class Storages::Admin::StoragesController < ApplicationController.resultend- # Actually create a Storage object.- # Overwrite the creator_id with the current_user. Is this this pattern always used?- # Use service pattern to create a new Storage- # See also: storages/services/storages/storages/create_service.rb- # Called by: Global app/config/routes.rb to serve Web page+ # rubocop:disable Metrics/AbcSizedef create- service_result = Storages::Storages::CreateService.new(user: current_user).call(permitted_storage_params)- @object = service_result.result- @oauth_application = oauth_application(service_result)-- if service_result.success? && @oauth_application- flash[:notice] = I18n.t(:notice_successful_create)- render :show_oauth_application- else+ storage_params = permitted_storage_params+ contract_class = case storage_params['provider_type']+ when ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD+ ::Storages::Storages::NextcloudCreateContract+ when ::Storages::Storage::PROVIDER_TYPE_ONE_DRIVE+ ::Storages::Storages::OneDriveCreateContract+ else+ raise "Unknown provider type: #{storage_params['provider_type']}"+ end++ service_result = Storages::Storages::CreateService.new(user: current_user, contract_class:).call(storage_params)++ service_result.on_failure do@errors = service_result.errorsrender :newend++ @storage = service_result.result+ @oauth_application = oauth_application(service_result)++ service_result.on_success do+ case @storage.provider_type+ when ::Storages::Storage::PROVIDER_TYPE_ONE_DRIVE+ flash[:notice] = I18n.t(:notice_successful_create)+ redirect_to new_admin_settings_storage_oauth_client_path(@storage)+ when ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD+ if @oauth_application.present?+ flash.now[:notice] = I18n.t(:notice_successful_create)+ render :show_oauth_application+ end+ else+ raise "Unknown provider type: #{storage_params['provider_type']}"+ end+ endend+ # rubocop:enable Metrics/AbcSize+# Edit page is very similar to new page, except that we don't need to set# default attribute values because the object already exists# Called by: Global app/config/routes.rb to serve Web page@@ -100,23 +121,31 @@ class Storages::Admin::StoragesController < ApplicationController# See also: create above# Called by: Global app/config/routes.rb to serve Web pagedef update+ contract_class = case @storage.provider_type+ when ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD+ ::Storages::Storages::NextcloudUpdateContract+ when ::Storages::Storage::PROVIDER_TYPE_ONE_DRIVE+ ::Storages::Storages::OneDriveUpdateContract+ end+service_result = ::Storages::Storages::UpdateService.new(user: current_user,- model: @object)+ model: @storage,+ contract_class:).call(permitted_storage_params)if service_result.success?flash[:notice] = I18n.t(:notice_successful_update)- redirect_to edit_admin_settings_storage_path(@object)+ redirect_to edit_admin_settings_storage_path(@storage)else- @errors = service_result.errors+ @storage = service_result.errorsrender :editendenddef destroyStorages::Storages::DeleteService- .new(user: User.current, model: @object)+ .new(user: User.current, model: @storage).call.match(# rubocop:disable Rails/ActionControllerFlashBeforeRender@@ -129,8 +158,8 @@ class Storages::Admin::StoragesController < ApplicationControllerenddef replace_oauth_application- @object.oauth_application.destroy- service_result = ::Storages::OAuthApplications::CreateService.new(storage: @object, user: current_user).call+ @storage.oauth_application.destroy+ service_result = ::Storages::OAuthApplications::CreateService.new(storage: @storage, user: current_user).callif service_result.success?flash[:notice] = I18n.t('storages.notice_oauth_application_replaced')diff --git a/modules/storages/app/models/storages/storage.rb b/modules/storages/app/models/storages/storage.rbindex d0a73998c48..02e7608f698 100644--- a/modules/storages/app/models/storages/storage.rb+++ b/modules/storages/app/models/storages/storage.rb@@ -61,7 +61,8 @@ class Storages::Storage < ApplicationRecordhas_one :oauth_application, class_name: '::Doorkeeper::Application', as: :integration, dependent: :destroyPROVIDER_TYPES = [- PROVIDER_TYPE_NEXTCLOUD = 'Storages::NextcloudStorage'.freeze+ PROVIDER_TYPE_NEXTCLOUD = 'Storages::NextcloudStorage'.freeze,+ PROVIDER_TYPE_ONE_DRIVE = 'Storages::OneDriveStorage'.freeze].freeze# Uniqueness - no two storages should have the same host.@@ -104,4 +105,8 @@ class Storages::Storage < ApplicationRecorddef provider_type_nextcloud?provider_type == ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUDend++ def provider_type_one_drive?+ provider_type == ::Storages::Storage::PROVIDER_TYPE_ONE_DRIVE+ endenddiff --git a/modules/storages/app/services/storages/storages/create_service.rb b/modules/storages/app/services/storages/storages/create_service.rbindex 0263f26a1e8..b8da1c25add 100644--- a/modules/storages/app/services/storages/storages/create_service.rb+++ b/modules/storages/app/services/storages/storages/create_service.rb@@ -34,6 +34,11 @@# The comments here are also valid for the other *_service.rb filesmodule Storages::Storagesclass CreateService < ::BaseServices::Create+ # def initialize(user:)+ # binding.pry+ # super(user:, contract_class: nil, contract_options: {})+ # end+protecteddef after_perform(service_call)diff --git a/modules/storages/app/services/storages/storages/set_attributes_service.rb b/modules/storages/app/services/storages/storages/set_attributes_service.rbindex 3ff6736b489..a251e60fa04 100644--- a/modules/storages/app/services/storages/storages/set_attributes_service.rb+++ b/modules/storages/app/services/storages/storages/set_attributes_service.rb@@ -62,7 +62,7 @@ module Storages::Storagesenddef derive_default_storage_name- prefix = I18n.t("storages.provider_types.#{storage.short_provider_type}.default_name")+ prefix = I18n.t("storages.default_name")last_id = Storages::Storage.where("name like ?", "#{prefix}%").maximum(:id)return prefix if last_id.nil?diff --git a/modules/storages/app/views/storages/admin/storages/_form.html.erb b/modules/storages/app/views/storages/admin/storages/_form.html.erbindex 1b58c21413c..138bbc0e72d 100644--- a/modules/storages/app/views/storages/admin/storages/_form.html.erb+++ b/modules/storages/app/views/storages/admin/storages/_form.html.erb@@ -27,10 +27,16 @@ See COPYRIGHT and LICENSE files for more details.++#%>+<% content_controller 'storages--storage-form',+ dynamic: true,+ 'storages--storage-form-one-drive-placeholder-value': t(:"storages.provider_types.onedrive.name_placeholder"),+ 'storages--storage-form-nextcloud-placeholder-value': t(:"storages.provider_types.nextcloud.name_placeholder")+%>+<!-- Included form for create and edit operations, please see the controller for comments -->-<%= error_messages_for_contract @object, @errors %>+<%= error_messages_for_contract @storage, @errors %>-<fieldset class="form--fieldset">+<fieldset class="form--fieldset" data-storages--storage-form-target="fieldset"><legend class="form--fieldset-legend"><%= I18n.t(:label_general) %></legend><div class="form--field -required"><% if action_name == 'new' || action_name == 'create' %>@@ -40,6 +46,9 @@ See COPYRIGHT and LICENSE files for more details.{selected: ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD,container_class: '-slim'+ },+ data: {+ 'storages--storage-form-target': 'selectProviderType'}%><span class="form--field-instructions"><%= t('storages.instructions.type') %> <%= t('storages.instructions.type_link_text') %></span>@@ -48,24 +57,28 @@ See COPYRIGHT and LICENSE files for more details.<%= t(:"storages.label_provider_type") %><% end %><div class="form--field-container -horizontal">- <span><%= @object.name %></span>+ <span><%= I18n.t("storages.provider_types.#{@storage.short_provider_type}.name") %></span></div><% end %></div><div class="form--field -required"><%= f.text_field :name,required: true,- placeholder: I18n.t("storages.provider_types.#{@object.short_provider_type}.name_placeholder"),- container_class: '-slim' %>+ placeholder: I18n.t("storages.provider_types.#{@storage.short_provider_type}.name_placeholder"),+ container_class: '-slim',+ data: {+ 'storages--storage-form-target': 'storageName'+ } %><span class="form--field-instructions"><%= t('storages.instructions.name') %></span></div>- <div class="form--field -required">+ <div class="form--field -required" data-storages--storage-form-target="storageUrl"><%= f.text_field :host,label: t('storages.label_host'),type: :url,required: true,pattern: ".{1,255}",- placeholder: "https://my-file-storage.com", container_class: '-wide' %>+ placeholder: "https://my-file-storage.com",+ container_class: '-wide' %><span class="form--field-instructions"><%= t('storages.instructions.host') %></span></div></fieldset>diff --git a/modules/storages/app/views/storages/admin/storages/edit.html.erb b/modules/storages/app/views/storages/admin/storages/edit.html.erbindex 3961fc19069..b63f25036da 100644--- a/modules/storages/app/views/storages/admin/storages/edit.html.erb+++ b/modules/storages/app/views/storages/admin/storages/edit.html.erb@@ -2,27 +2,27 @@<!-- We want to hide client_secret from the user while allowing the user to edit the other attributes --><% html_title t(:label_administration), t("project_module_storages"), t('label_edit_x', x: @object.name) %>-<% local_assigns[:additional_breadcrumb] = @object.name %>+<% local_assigns[:additional_breadcrumb] = @storage.name %><%= toolbar title: t('label_edit_x', x: @object.name) %>-<%= render(::Storages::Admin::ConfigurationChecksComponent.new(storage: @object)) %>+<%= render(::Storages::Admin::ConfigurationChecksComponent.new(storage: @storage)) %>-<%= labelled_tabular_form_for @object, url: admin_settings_storage_path(@object), as: :storages_storage do |f| -%>+<%= labelled_tabular_form_for @storage, url: admin_settings_storage_path(@storage), as: :storages_storage do |f| -%><%= render partial: 'form', locals: { f: f } %><%= styled_button_tag t(:button_save), class: "-highlight -with-icon icon-checkmark" %><% end %>-<% if @object.oauth_application %>+<% if @storage.oauth_application %><%= render(AttributeGroups::AttributeGroupComponent.new) do |component| %><% component.with_header(title: "OpenProject #{t(:'storages.label_oauth_application_details')}") %><% component.with_attributes([- { key: "OpenProject #{Storages::Admin::LABEL_OAUTH_CLIENT_ID}", value: @object.oauth_application.uid },- { key: "OpenProject #{Storages::Admin::LABEL_OAUTH_CLIENT_SECRET}", value: "●●●●●●●●●●●●●●●●" },- ]) %>+ { key: "OpenProject #{Storages::Admin::LABEL_OAUTH_CLIENT_ID}", value: @storage.oauth_application.uid },+ { key: "OpenProject #{Storages::Admin::LABEL_OAUTH_CLIENT_SECRET}", value: "●●●●●●●●●●●●●●●●" },+ ]) %><%= link_to(t("storages.buttons.replace_openproject_oauth"),- replace_oauth_application_admin_settings_storage_path(@object),+ replace_oauth_application_admin_settings_storage_path(@storage),method: :delete,data: { confirm: t(:'storages.confirm_replace_oauth_application') },class: 'button -with-icon icon-reload') %>@@ -30,47 +30,47 @@<% end %><%= render(AttributeGroups::AttributeGroupComponent.new) do |component| %>- <% component.with_header(title: "#{t("storages.provider_types.#{@object.short_provider_type}.name")} #{t(:'storages.label_oauth_client_details')}") %>+ <% component.with_header(title: "#{t("storages.provider_types.#{@storage.short_provider_type}.name")} #{t(:'storages.label_oauth_client_details')}") %>- <% if @object.oauth_client %>+ <% if @storage.oauth_client %><% component.with_attributes([- { key: "#{t("storages.provider_types.#{@object.short_provider_type}.name")} #{Storages::Admin::LABEL_OAUTH_CLIENT_ID}",- value: @object.oauth_client.client_id },- { key: "#{t("storages.provider_types.#{@object.short_provider_type}.name")} #{Storages::Admin::LABEL_OAUTH_CLIENT_SECRET}",- value: short_secret(@object.oauth_client.client_secret) },- ]) %>+ { key: "#{t("storages.provider_types.#{@storage.short_provider_type}.name")} #{Storages::Admin::LABEL_OAUTH_CLIENT_ID}",+ value: @storage.oauth_client.client_id },+ { key: "#{t("storages.provider_types.#{@storage.short_provider_type}.name")} #{Storages::Admin::LABEL_OAUTH_CLIENT_SECRET}",+ value: short_secret(@storage.oauth_client.client_secret) },+ ]) %>- <%= link_to(t("storages.buttons.replace_provider_type_oauth", provider_type: t("storages.provider_types.#{@object.short_provider_type}.name")),- new_admin_settings_storage_oauth_client_path(@object),+ <%= link_to(t("storages.buttons.replace_provider_type_oauth", provider_type: t("storages.provider_types.#{@storage.short_provider_type}.name")),+ new_admin_settings_storage_oauth_client_path(@storage),data: { confirm: t(:'storages.confirm_replace_oauth_client') },class: 'button -with-icon icon-reload') %><% else %>- <%= link_to(t("js.label_create"), new_admin_settings_storage_oauth_client_path(@object), class: 'button -with-icon icon-add') %>+ <%= link_to(t("js.label_create"), new_admin_settings_storage_oauth_client_path(@storage), class: 'button -with-icon icon-add') %><% end %><% end %>+<% if @storage.provider_type == Storages::Storage::PROVIDER_TYPE_NEXTCLOUD %>+ <%= render(AttributeGroups::AttributeGroupComponent.new) do |component| %>+ <% component.with_header(title: t("storages.page_titles.managed_project_folders.title")) %>-<%= render(AttributeGroups::AttributeGroupComponent.new) do |component| %>- <% component.with_header(title: t("storages.page_titles.managed_project_folders.title")) %>+ <% if @storage.automatic_management_unspecified? %>+ <%= link_to(t("storages.buttons.configure"), new_admin_settings_storage_automatically_managed_project_folders_path(@storage), class: 'button -with-icon icon-add') %>+ <% else %>+ <% component.with_attribute(+ key: t(:"storages.label_managed_project_folders.automatically_managed_folders"),+ value: @storage.automatically_managed? ? t(:"storages.label_active") : t(:"storages.label_inactive")+ ) %>- <% if @object.automatic_management_unspecified? %>- <%= link_to(t("storages.buttons.configure"), new_admin_settings_storage_automatically_managed_project_folders_path(@object), class: 'button -with-icon icon-add') %>- <% else %>- <% component.with_attribute(- key: t(:"storages.label_managed_project_folders.automatically_managed_folders"),- value: @object.automatically_managed? ? t(:"storages.label_active") : t(:"storages.label_inactive")- ) %>+ <% if @storage.automatically_managed? %>+ <% component.with_attribute(+ key: t(:"storages.label_managed_project_folders.application_password"),+ value: "●●●●●●●●●●●●●●●●"+ ) %>+ <% end %>- <% if @object.automatically_managed? %>- <% component.with_attribute(- key: t(:"storages.label_managed_project_folders.application_password"),- value: "●●●●●●●●●●●●●●●●"- ) %>+ <%= link_to(t("storages.buttons.edit_automatically_managed_project_folders"),+ edit_admin_settings_storage_automatically_managed_project_folders_path(@storage),+ class: 'button -with-icon icon-edit') %><% end %>-- <%= link_to(t("storages.buttons.edit_automatically_managed_project_folders"),- edit_admin_settings_storage_automatically_managed_project_folders_path(@object),- class: 'button -with-icon icon-edit') %><% 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.erbindex 067b742f24a..ebf85cb8874 100644--- a/modules/storages/app/views/storages/admin/storages/new.html.erb+++ b/modules/storages/app/views/storages/admin/storages/new.html.erb@@ -3,9 +3,9 @@<% local_assigns[:additional_breadcrumb] = t('storages.label_new_storage') %><%= toolbar title: t("storages.label_new_storage") %>-<%= labelled_tabular_form_for @object, url: admin_settings_storages_path(@object), as: :storages_storage do |f| -%>+<%= labelled_tabular_form_for @storage, url: admin_settings_storages_path(@storage), as: :storages_storage do |f| -%><%= render partial: 'form', locals: { f: f } %>- <% if @object.oauth_client %>+ <% if @storage.oauth_client %><%= styled_button_tag t(:button_save), class: "-highlight -with-icon icon-checkmark" %><% else %><%= styled_button_tag t("storages.buttons.save_and_continue_setup"), class: "-highlight -with-icon icon-checkmark" %>diff --git a/modules/storages/app/views/storages/admin/storages/new_oauth_client.html.erb b/modules/storages/app/views/storages/admin/storages/new_oauth_client.html.erbindex b7300bce212..a21241a3d06 100644--- a/modules/storages/app/views/storages/admin/storages/new_oauth_client.html.erb+++ b/modules/storages/app/views/storages/admin/storages/new_oauth_client.html.erb@@ -1,4 +1,32 @@-<!-- Standard Ruby view, please see the controller for comments -->+<%#-- 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.++++#%>+<% html_title t(:label_administration), t("project_module_storages"), @storage.name, "#{t("storages.provider_types.#{@storage.short_provider_type}.name")} #{t("storages.label_oauth_client_details")}" %><% local_assigns[:additional_breadcrumb] = [link_to(@storage.name, edit_admin_settings_storage_path(@storage)),@@ -7,40 +35,10 @@<%= toolbar title: "#{t("storages.provider_types.#{@storage.short_provider_type}.name")} #{t("storages.label_oauth_client_details")}" %><%= labelled_tabular_form_for @oauth_client, url: admin_settings_storage_oauth_client_path do |f| -%>- <fieldset class="form--fieldset">- <div class="form--field -required">- <%= f.text_field :client_id,- label: Storages::Admin::LABEL_OAUTH_CLIENT_ID,- required: true,- size: 40,- container_class: '-wide' %>- <span class="form--field-instructions">- <%= "#{t("storages.instructions.copy_from")}: " %>- <%= link_to "#{t("storages.instructions.#{@storage.short_provider_type}.integration")}",- File.join(@storage.host, "settings/admin/openproject").to_s,- target: "_blank" %>- </span>- </div>- <div class="form--field -required">- <%= f.text_field :client_secret,- label: Storages::Admin::LABEL_OAUTH_CLIENT_SECRET,- required: true,- size: 40,- container_class: '-wide' %>- <span class="form--field-instructions">- <%= "#{t("storages.instructions.copy_from")}: " %>- <%= link_to "#{t("storages.instructions.#{@storage.short_provider_type}.integration")}",- File.join(@storage.host, "settings/admin/openproject").to_s,- target: "blank" %>- </span>- </div>- </fieldset>-- <% if @storage.oauth_client %>- <%= styled_button_tag t(:button_replace), class: "-highlight -with-icon icon-checkmark" %>+ <% if @storage.provider_type_nextcloud? %>+ <%= render partial: 'storages/admin/storages/nextcloud/oauth_client', locals: { f: f } %><% else %>- <% label_action = @storage.automatic_management_unspecified? ? 'continue' : 'complete' %>- <%= styled_button_tag t("storages.buttons.save_and_#{label_action}_setup"), class: "-highlight -with-icon icon-checkmark" %>+ <%= render partial: 'storages/admin/storages/one_drive/oauth_client', locals: { f: f } %><% end %><% end %>diff --git a/modules/storages/app/views/storages/admin/storages/nextcloud/_oauth_client.html.erb b/modules/storages/app/views/storages/admin/storages/nextcloud/_oauth_client.html.erbnew file mode 100644index 00000000000..3534e749dc5--- /dev/null+++ b/modules/storages/app/views/storages/admin/storages/nextcloud/_oauth_client.html.erb@@ -0,0 +1,65 @@+<%#-- 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.+++#%>++<fieldset class="form--fieldset">+ <div class="form--field -required">+ <%= f.text_field :client_id,+ label: Storages::Admin::LABEL_OAUTH_CLIENT_ID,+ required: true,+ size: 40,+ container_class: '-wide' %>+ <span class="form--field-instructions">+ <%= "#{t("storages.instructions.copy_from")}: " %>+ <%= link_to "#{t("storages.instructions.#{@storage.short_provider_type}.integration")}",+ File.join(@storage.host, "settings/admin/openproject").to_s,+ target: "_blank" %>+ </span>+ </div>++ <div class="form--field -required">+ <%= f.text_field :client_secret,+ label: Storages::Admin::LABEL_OAUTH_CLIENT_SECRET,+ required: true,+ size: 40,+ container_class: '-wide' %>+ <span class="form--field-instructions">+ <%= "#{t("storages.instructions.copy_from")}: " %>+ <%= link_to "#{t("storages.instructions.#{@storage.short_provider_type}.integration")}",+ File.join(@storage.host, "settings/admin/openproject").to_s,+ target: "blank" %>+ </span>+ </div>+</fieldset>++<% if @storage.oauth_client %>+ <%= styled_button_tag t(:button_replace), class: "-highlight -with-icon icon-checkmark" %>+<% else %>+ <% is_last_step = @storage.provider_type_nextcloud? && @storage.automatic_management_unspecified? %>+ <% label_action = is_last_step ? 'complete' : 'continue' %>+ <%= styled_button_tag t("storages.buttons.save_and_#{label_action}_setup"), class: "-highlight -with-icon icon-checkmark" %>+<% end %>diff --git a/modules/storages/app/views/storages/admin/storages/one_drive/_oauth_client.html.erb b/modules/storages/app/views/storages/admin/storages/one_drive/_oauth_client.html.erbnew file mode 100644index 00000000000..fe606dd8fec--- /dev/null+++ b/modules/storages/app/views/storages/admin/storages/one_drive/_oauth_client.html.erb@@ -0,0 +1,89 @@+<%#-- 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.+++#%>++<% content_controller 'storages--oauth-client-form',+ dynamic: true,+ 'storages--oauth-client-form-client-id-missing-value': t(:"storages.instructions.#{@storage.short_provider_type}.missing_client_id_for_redirect_uri")+%>++<fieldset class="form--fieldset">+ <div class="form--field -required">+ <%= f.text_field :client_id,+ label: Storages::Admin::LABEL_OAUTH_CLIENT_ID,+ required: true,+ size: 40,+ container_class: '-wide',+ data: {+ 'storages--oauth-client-form-target': "clientId"+ } %>+ <span class="form--field-instructions">+ <%= t("storages.instructions.#{@storage.short_provider_type}.oauth_client_id") %>+ </span>+ </div>++ <div class="form--field">+ <%= f.text_field :client_secret,+ label: Storages::Admin::LABEL_OAUTH_CLIENT_SECRET,+ required: false,+ size: 40,+ container_class: '-wide' %>+ <span class="form--field-instructions">+ <%= t("storages.instructions.#{@storage.short_provider_type}.oauth_client_secret") %>+ </span>+ </div>++ <div class="form--field">+ <label class="form--label" for="oauth-client-redirect-uri"><%= Storages::Admin::LABEL_OAUTH_REDIRECT_URI %></label>+ <div class="form--field-container">+ <div class="form--text-field-container -wide">+ <input id="oauth-client-redirect-uri"+ type="text"+ class="form--text-field"+ readonly+ data-storages--oauth-client-form-target="redirectUri">+ </div>+ <div class="form--field-affix">+ <% csp_onclick('this.focus(); this.select();', '#secret') %>+ <copy-to-clipboard click-target=".callback-copy-button"+ clipboard-target="#oauth-client-redirect-uri">+ </copy-to-clipboard>+ <button class="callback-copy-button button -without-button-styling"+ title="<%= t(:button_copy_to_clipboard) %>">+ <%= op_icon('icon-copy') %>+ <span class="hidden-for-sighted"><%= t(:button_copy_to_clipboard) %></span>+ </button>+ </div>+ </div>+ </div>+</fieldset>++<% if @storage.oauth_client %>+ <%= styled_button_tag t(:button_replace), class: "-highlight -with-icon icon-checkmark" %>+<% else %>+ <%= styled_button_tag t("storages.buttons.save_and_complete_setup"), class: "-highlight -with-icon icon-checkmark" %>+<% end %>diff --git a/modules/storages/app/views/storages/admin/storages/show_oauth_application.html.erb b/modules/storages/app/views/storages/admin/storages/show_oauth_application.html.erbindex 487b9e52c6e..c8c66f15027 100644--- a/modules/storages/app/views/storages/admin/storages/show_oauth_application.html.erb+++ b/modules/storages/app/views/storages/admin/storages/show_oauth_application.html.erb@@ -1,7 +1,7 @@<!-- Standard Ruby view, please see the controller for comments -->-<% html_title t(:label_administration), t("project_module_storages"), @object.name, "#{t("storages.provider_types.#{@object.short_provider_type}.name")} #{t("storages.label_oauth_application_details")}" %>+<% html_title t(:label_administration), t("project_module_storages"), @storage.name, "#{t("storages.provider_types.#{@storage.short_provider_type}.name")} #{t("storages.label_oauth_application_details")}" %><% local_assigns[:additional_breadcrumb] = [- link_to(@object.name, edit_admin_settings_storage_path(@object)),+ link_to(@storage.name, edit_admin_settings_storage_path(@storage)),t("storages.label_oauth_breadcrumb.openproject")] %><%= toolbar title: "OpenProject #{t("storages.label_oauth_application_details")}" %>diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlindex b13234a89d4..ec22a66372f 100644--- a/modules/storages/config/locales/en.yml+++ b/modules/storages/config/locales/en.yml@@ -58,6 +58,7 @@ en:too_many_elements_created_at_once: "Too many elements created at once. Expected %{max} at most, got %{actual}."storages:+ default_name: "My storage"unknown_storage: "Unknown storage"buttons:done_continue_setup: "Done. Continue setup"@@ -106,6 +107,13 @@ en:copy_from: "Copy this value from"nextcloud:integration: "Nextcloud Administration / OpenProject"+ onedrive:+ integration: "OneDrive/Sharepoint"+ oauth_client_id: >+ Copy the client id from the Azure portal.+ oauth_client_secret: >+ Adding a secret is optional. If the OAuth2 application is confidential, copy the value from the Azure portal.+ missing_client_id_for_redirect_uri: "Client ID missing to provide redirect URI."help_texts:project_folder: >The project folder is the default folder for file uploads for this project.@@ -137,6 +145,7 @@ en:label_oauth_breadcrumb:openproject: "OpenProject OAuth"nextcloud: "Nextcloud OAuth"+ onedrive: "OneDrive OAuth"label_oauth_application_details: "OAuth application details"label_oauth_client_details: "OAuth client details"label_provider_type: "Provider type"@@ -161,7 +170,9 @@ en:nextcloud:name: "Nextcloud"name_placeholder: "e.g. Nextcloud"- default_name: "My Nextcloud"+ onedrive:+ name: "OneDrive/Sharepoint"+ name_placeholder: "e.g. OneDrive"confirm_replace_oauth_application: "Are you sure? All users will have to authorize again against OpenProject."confirm_replace_oauth_client: "Are you sure? All users will have to authorize again against the storage."oauth_client_details_missing: "To complete the setup, please add OAuth client credentials from your storage."diff --git a/modules/storages/db/migrate/20230824130730_remove_not_null_constraint_for_storage_host.rb b/modules/storages/db/migrate/20230824130730_remove_not_null_constraint_for_storage_host.rbnew file mode 100644index 00000000000..85028fe07b9--- /dev/null+++ b/modules/storages/db/migrate/20230824130730_remove_not_null_constraint_for_storage_host.rb@@ -0,0 +1,14 @@+class RemoveNotNullConstraintForStorageHost < ActiveRecord::Migration[7.0]+ def up+ change_column :storages, :host, :string, null: true+ change_column :oauth_clients, :client_secret, :string, null: true+ end++ def down+ ::Storages::Storage.where(host: nil).delete_all+ change_column :storages, :host, :string, null: false++ ::OAuthClient.where(client_secret: nil).delete_all+ change_column :oauth_clients, :client_secret, :string, null: false+ end+end