Skip to content

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

[51372] Extracted redirect URI input to separate row

Andreas Pfohl76ddc82162b2
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 a828a4c4c1c..2d213d99052 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
@@ -27,8 +27,8 @@
client_id_input_options: {
data: {
'storages--oauth-client-form-target': 'clientId',
- action: 'input->storages--oauth-client-form#toggleSubmitButtonDisabled '\
- 'input->storages--oauth-client-form#setRedirectUriValue'
+ action: 'input->storages--oauth-client-form#toggleSubmitButtonDisabled ' \
+ 'input->storages--oauth-client-form#setRedirectUriValue'
}
},
client_secret_input_options: {
@@ -41,36 +41,6 @@
)
end
- if storage.provider_type_one_drive?
- oauth_client_row.with_row(mb: 3) do
- concat(render(Primer::OpenProject::InputGroup.new(input_width: :large)) do |input_group|
- input_group.with_text_input(name: :oauth_client_redirect_uri,
- label: I18n.t('storages.label_redirect_uri'),
- visually_hide_label: false,
- value: redirect_uri_or_instructions,
- required: true,
- data: {
- 'storages--oauth-client-form-target': 'redirectUri'
- })
- input_group.with_trailing_action_clipboard_copy_button(
- value: redirect_uri_or_instructions,
- aria: {
- label: I18n.t('button_copy_to_clipboard')
- },
- data: {
- 'storages--oauth-client-form-target': 'redirectUri'
- })
- end)
-
- # NOTE: Hardcoded `FormControl-caption` class is used to align the text with the input field.
- # This is a workaround until Primer::OpenProject::InputGroup supports a caption.
- # See https://community.openproject.org/wp/51376
- concat(render(Primer::Beta::Text.new(classes: 'FormControl-caption')) do
- I18n.t('storages.instructions.one_drive.oauth_client_redirect_uri')
- end)
- end
- end
-
oauth_client_row.with_row do
render(
Storages::Admin::SubmitOrCancelForm.new(
@@ -80,7 +50,7 @@
disabled: submit_button_disabled?,
data: {
'storages--oauth-client-form-target': 'submitButton',
- }.merge(submit_button_data_options),
+ },
test_selector: 'storage-oauth-client-submit-button'
},
cancel_button_options: {
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 1a5e0db536d..e38599d1151 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,21 +52,6 @@ module Storages::Admin::Forms
!oauth_client_configured?
end
- def submit_button_data_options
- {}.tap do |data|
- # For One Drive create action, break from Turbo Frame and follow full page redirect
- data[:turbo] = false if one_drive_first_time_configuration?
- end
- end
-
- def redirect_uri_or_instructions
- if oauth_client_configured?
- oauth_client.redirect_uri
- else
- I18n.t("storages.instructions.one_drive.missing_client_id_for_redirect_uri")
- end
- 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
@@ -85,10 +70,6 @@ module Storages::Admin::Forms
render(Primer::Beta::Link.new(href:, target:)) { I18n.t('storages.instructions.nextcloud.integration') }
end
- def one_drive_first_time_configuration?
- storage.provider_type_one_drive? && first_time_configuration?
- end
-
def first_time_configuration?
storage.oauth_client.blank? || storage.oauth_client.new_record?
end
diff --git a/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.html.erb b/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.html.erb
new file mode 100644
index 00000000000..231d77444ef
--- /dev/null
+++ b/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.html.erb
@@ -0,0 +1,67 @@
+<%=
+ render(Primer::Beta::Text.new(tag: :div, test_selector: 'storage-oauth-client-form')) do
+ primer_form_with(
+ model: oauth_client,
+ url: finish_setup_admin_settings_storage_oauth_client_path(storage),
+ method: :post,
+ data: {
+ controller: 'storages--oauth-client-form',
+ application_target: 'dynamic',
+ 'storages--oauth-client-form-client-id-missing-value': t(:"storages.instructions.one_drive.missing_client_id_for_redirect_uri")
+ }
+ ) do |form|
+ flex_layout do |oauth_client_row|
+ oauth_client_row.with_row(mb: 3) do
+ concat(render(Primer::OpenProject::InputGroup.new(input_width: :large)) do |input_group|
+ input_group.with_text_input(
+ name: :oauth_client_redirect_uri,
+ label: I18n.t('storages.label_redirect_uri'),
+ visually_hide_label: false,
+ value: redirect_uri_or_instructions,
+ required: true,
+ data: {
+ 'storages--oauth-client-form-target': 'redirectUri'
+ }
+ )
+
+ input_group.with_trailing_action_clipboard_copy_button(
+ value: redirect_uri_or_instructions,
+ aria: {
+ label: I18n.t('button_copy_to_clipboard')
+ },
+ data: {
+ 'storages--oauth-client-form-target': 'redirectUri'
+ }
+ )
+ end)
+
+ # NOTE: Hardcoded `FormControl-caption` class is used to align the text with the input field.
+ # This is a workaround until Primer::OpenProject::InputGroup supports a caption.
+ # See https://community.openproject.org/wp/51376
+ concat(render(Primer::Beta::Text.new(classes: 'FormControl-caption')) do
+ I18n.t('storages.instructions.one_drive.oauth_client_redirect_uri')
+ end)
+ end
+
+ oauth_client_row.with_row do
+ render(Storages::Admin::SubmitOrCancelForm.new(
+ form,
+ storage:,
+ submit_button_options: {
+ disabled: submit_button_disabled?,
+ label: I18n.t('storages.buttons.done_complete_setup'),
+ data: {
+ 'storages--oauth-client-form-target': 'submitButton',
+ turbo: false
+ },
+ test_selector: 'storage-oauth-client-submit-button'
+ },
+ cancel_button_options: {
+ href: cancel_button_path
+ }
+ ))
+ end
+ end
+ end
+ end
+%>
diff --git a/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.rb b/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.rb
new file mode 100644
index 00000000000..67d1e446335
--- /dev/null
+++ b/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.rb
@@ -0,0 +1,65 @@
+# 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 RedirectUriFormComponent < ApplicationComponent
+ include OpPrimer::ComponentHelpers
+
+ attr_reader :storage
+ alias_method :oauth_client, :model
+
+ def initialize(oauth_client:, storage:, **options)
+ super(oauth_client, **options)
+ @storage = storage
+ end
+
+ def cancel_button_path
+ storage.persisted? ? edit_admin_settings_storage_path(storage) : admin_settings_storages_path
+ end
+
+ def submit_button_disabled?
+ !oauth_client_configured?
+ end
+
+ def redirect_uri_or_instructions
+ if oauth_client_configured?
+ oauth_client.redirect_uri
+ else
+ I18n.t("storages.instructions.one_drive.missing_client_id_for_redirect_uri")
+ end
+ end
+
+ private
+
+ def oauth_client_configured?
+ oauth_client.present? && oauth_client.client_id.present? && oauth_client.client_secret.present?
+ end
+ end
+end
diff --git a/modules/storages/app/components/storages/admin/redirect_uri_component.html.erb b/modules/storages/app/components/storages/admin/redirect_uri_component.html.erb
new file mode 100644
index 00000000000..86298e0812d
--- /dev/null
+++ b/modules/storages/app/components/storages/admin/redirect_uri_component.html.erb
@@ -0,0 +1,26 @@
+<%=
+ 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: :bold, mr: 1, test_selector: 'storage-redirect-uri-label')
+ ) { I18n.t("storages.file_storage_view.redirect_uri") }
+ )
+ concat(configuration_check_label_for(:storage_oauth_client_configured))
+ end
+
+ grid.with_area(:description, tag: :div, color: :subtle, test_selector: 'storage-redirect-uri-description') do
+ render(Primer::Beta::Text.new) { provider_redirect_uri_description }
+ end
+
+ if editable_storage?
+ grid.with_area(:"icon-button", tag: :div, color: :muted) do
+ flex_layout(justify_content: :flex_end) do |icons_container|
+ icons_container.with_column do
+ render(Primer::Beta::IconButton.new(**edit_icon_button_options))
+ end
+ end
+ end
+ end
+ end
+%>
diff --git a/modules/storages/app/components/storages/admin/redirect_uri_component.rb b/modules/storages/app/components/storages/admin/redirect_uri_component.rb
new file mode 100644
index 00000000000..23e942f0ea2
--- /dev/null
+++ b/modules/storages/app/components/storages/admin/redirect_uri_component.rb
@@ -0,0 +1,61 @@
+# 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
+ class RedirectUriComponent < ApplicationComponent
+ include OpPrimer::ComponentHelpers
+ include StorageViewInformation
+
+ attr_reader :storage
+ alias_method :oauth_client, :model
+
+ def initialize(oauth_client:, storage:, **options)
+ super(oauth_client, **options)
+ @storage = storage
+ end
+
+ def edit_icon_button_options
+ {
+ icon: oauth_client_configured? ? :eye : :pencil,
+ tag: :a,
+ href: Rails.application.routes.url_helpers.show_redirect_uri_admin_settings_storage_oauth_client_path(storage),
+ scheme: :invisible,
+ aria: { label: I18n.t("storages.label_show_storage_redirect_uri") },
+ test_selector: 'storage-edit-oauth-client-button'
+ }
+ end
+
+ private
+
+ def oauth_client_configured?
+ storage.configuration_checks[:storage_oauth_client_configured]
+ end
+ end
+end
diff --git a/modules/storages/app/components/storages/admin/storage_view_component.html.erb b/modules/storages/app/components/storages/admin/storage_view_component.html.erb
index 2219a21e074..737aa594758 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
@@ -45,7 +45,7 @@
end
end
- component.with_row(scheme: :neutral, color: :muted) do
+ component.with_row(scheme: :neutral, color: :muted) do
grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|
grid.with_area(:item, tag: :div) do
render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1)) { I18n.t('storages.file_storage_view.project_folders') }
@@ -65,7 +65,7 @@
end
if storage.provider_type_one_drive?
- component.with_row(scheme: :neutral, color: :muted) do
+ component.with_row(scheme: :neutral, color: :muted) do
grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|
grid.with_area(:item, tag: :div, mr: 3) do
render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1)) { I18n.t('storages.file_storage_view.oauth_applications') }
@@ -78,6 +78,12 @@
render(Storages::Admin::OAuthClientInfoComponent.new(oauth_client: storage.oauth_client, storage:))
end
end
+
+ component.with_row(scheme: :default) do
+ render(OpTurbo::FrameComponent.new(id: :storage_redirect_url_section)) do
+ render(Storages::Admin::RedirectUriComponent.new(oauth_client: storage.oauth_client, storage:))
+ end
+ end
end
end
%>
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 6ac746b2f60..ccb00e32851 100644
--- a/modules/storages/app/components/storages/admin/storage_view_information.rb
+++ b/modules/storages/app/components/storages/admin/storage_view_information.rb
@@ -65,5 +65,13 @@ module Storages::Admin
I18n.t("storages.configuration_checks.oauth_client_incomplete.#{storage.short_provider_type}")
end
end
+
+ 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}")
+ end
+ end
end
end
diff --git a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb
index bdb512f3597..925f4eec2fe 100644
--- a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb
@@ -54,7 +54,7 @@ class Storages::Admin::OAuthClientsController < ApplicationController
.result
respond_to do |format|
- format.html { render '/storages/admin/storages/new_oauth_client' }
+ format.html
format.turbo_stream
end
end
@@ -66,21 +66,27 @@ class Storages::Admin::OAuthClientsController < ApplicationController
call_oauth_clients_create_service
service_result.on_failure do
- render '/storages/admin/storages/new_oauth_client'
+ respond_to do |format|
+ format.html { render :new }
+ end
end
service_result.on_success do
if @storage.provider_type_nextcloud?
prepare_storage_for_automatic_management_form
- respond_to do |format|
- format.turbo_stream { render :create }
- end
- elsif @storage.provider_type_one_drive?
- flash[:primer_banner] = { message: I18n.t(:'storages.notice_successful_storage_connection'), scheme: :success }
- redirect_to admin_settings_storages_path
- else
- raise "Unsupported provider type: #{@storage.short_provider_type}"
+ # respond_to do |format|
+ # format.turbo_stream { render :create }
+ # end
+ # elsif @storage.provider_type_one_drive?
+ # flash[:primer_banner] = { message: I18n.t(:'storages.notice_successful_storage_connection'), scheme: :success }
+ # redirect_to admin_settings_storages_path
+ # else
+ # raise "Unsupported provider type: #{@storage.short_provider_type}"
+ end
+
+ respond_to do |format|
+ format.turbo_stream
end
end
end
@@ -96,7 +102,7 @@ class Storages::Admin::OAuthClientsController < ApplicationController
service_result.on_success do
respond_to do |format|
- format.turbo_stream { render :update }
+ format.turbo_stream
end
end
end
@@ -114,14 +120,25 @@ class Storages::Admin::OAuthClientsController < ApplicationController
true
end
+ def show_redirect_uri
+ respond_to do |format|
+ format.html { render layout: false }
+ end
+ end
+
+ def finish_setup
+ flash[:primer_banner] = { message: I18n.t(:'storages.notice_successful_storage_connection'), scheme: :success }
+ redirect_to admin_settings_storages_path
+ end
+
private
attr_reader :service_result
def call_oauth_clients_create_service
@service_result = ::OAuthClients::CreateService
- .new(user: User.current)
- .call(oauth_client_params.merge(integration: @storage))
+ .new(user: User.current)
+ .call(oauth_client_params.merge(integration: @storage))
@oauth_client = service_result.result
@storage = @storage.reload
end
@@ -130,9 +147,9 @@ class Storages::Admin::OAuthClientsController < ApplicationController
return unless @storage.automatic_management_unspecified?
@storage = ::Storages::Storages::SetNextcloudProviderFieldsAttributesService
- .new(user: current_user, model: @storage, contract_class: EmptyContract)
- .call
- .result
+ .new(user: current_user, model: @storage, contract_class: EmptyContract)
+ .call
+ .result
end
# Called by create and update above in order to check if the
diff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rb
index 20e8e9af2ba..f845ac9b540 100644
--- a/modules/storages/app/controllers/storages/admin/storages_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb
@@ -86,10 +86,10 @@ class Storages::Admin::StoragesController < ApplicationController
def select_provider
@object = Storages::Storage.new(provider_type: @provider_type)
service_result = ::Storages::Storages::SetAttributesService
- .new(user: current_user,
- model: @object,
- contract_class: EmptyContract)
- .call
+ .new(user: current_user,
+ model: @object,
+ contract_class: EmptyContract)
+ .call
@storage = service_result.result
respond_to do |format|
@@ -99,8 +99,8 @@ class Storages::Admin::StoragesController < ApplicationController
def create
service_result = Storages::Storages::CreateService
- .new(user: current_user)
- .call(permitted_storage_params)
+ .new(user: current_user)
+ .call(permitted_storage_params)
@storage = service_result.result
@oauth_application = oauth_application(service_result)
@@ -112,14 +112,20 @@ class Storages::Admin::StoragesController < ApplicationController
end
service_result.on_success do
- respond_to { |format| format.turbo_stream }
+ service_result.on_success do
+ respond_to do |format|
+ format.turbo_stream
+ end
+ end
end
end
def show_oauth_application
@oauth_application = @storage.oauth_application
- respond_to { |format| format.turbo_stream }
+ respond_to do |format|
+ format.turbo_stream
+ end
end
# Edit page is very similar to new page, except that we don't need to set
@@ -128,7 +134,9 @@ class Storages::Admin::StoragesController < ApplicationController
def edit; end
def edit_host
- respond_to { |format| format.turbo_stream }
+ respond_to do |format|
+ format.turbo_stream
+ end
end
# Update is similar to create above
@@ -141,7 +149,9 @@ class Storages::Admin::StoragesController < ApplicationController
@storage = service_result.result
if service_result.success?
- respond_to { |format| format.turbo_stream }
+ respond_to do |format|
+ format.turbo_stream
+ end
else
respond_to do |format|
format.html { render :edit }
@@ -156,8 +166,8 @@ class Storages::Admin::StoragesController < ApplicationController
def destroy
service_result = Storages::Storages::DeleteService
- .new(user: User.current, model: @storage)
- .call
+ .new(user: User.current, model: @storage)
+ .call
# rubocop:disable Rails/ActionControllerFlashBeforeRender
service_result.on_failure do
diff --git a/modules/storages/app/views/storages/admin/oauth_clients/create.turbo_stream.erb b/modules/storages/app/views/storages/admin/oauth_clients/create.turbo_stream.erb
index 3fd98e27146..dffebb50ae4 100644
--- a/modules/storages/app/views/storages/admin/oauth_clients/create.turbo_stream.erb
+++ b/modules/storages/app/views/storages/admin/oauth_clients/create.turbo_stream.erb
@@ -31,6 +31,10 @@ See COPYRIGHT and LICENSE files for more details.
<%= render(Storages::Admin::OAuthClientInfoComponent.new(oauth_client: @oauth_client, storage: @storage)) %>
<% end %>
+<%= turbo_stream.update :storage_redirect_url_section do %>
+ <%= render(Storages::Admin::Forms::RedirectUriFormComponent.new(oauth_client: @oauth_client, storage: @storage)) %>
+<% end %>
+
<% if @storage.provider_type_nextcloud? && @storage.automatic_management_new_record? %>
<%= turbo_stream.update :automatically_managed_project_folders_section do %>
<%= render(Storages::Admin::Forms::AutomaticallyManagedProjectFoldersFormComponent.new(@storage)) %>
diff --git a/modules/storages/app/views/storages/admin/storages/new_oauth_client.html.erb b/modules/storages/app/views/storages/admin/oauth_clients/new.html.erb
similarity index 100%
rename from modules/storages/app/views/storages/admin/storages/new_oauth_client.html.erb
rename to modules/storages/app/views/storages/admin/oauth_clients/new.html.erb
diff --git a/modules/storages/app/views/storages/admin/oauth_clients/new.turbo_stream.erb b/modules/storages/app/views/storages/admin/oauth_clients/new.turbo_stream.erb
index c29aafa2e05..967c734f5de 100644
--- a/modules/storages/app/views/storages/admin/oauth_clients/new.turbo_stream.erb
+++ b/modules/storages/app/views/storages/admin/oauth_clients/new.turbo_stream.erb
@@ -38,6 +38,10 @@ See COPYRIGHT and LICENSE files for more details.
%>
<% end %>
+<%= turbo_stream.update :storage_redirect_url_section do %>
+ <%= render(Storages::Admin::RedirectUriComponent.new(oauth_client: @oauth_client, storage: @storage)) %>
+<% end %>
+
<% if @storage.provider_type_nextcloud? && @storage.oauth_client.blank? %>
<%= turbo_stream.update :storage_oauth_client_section do %>
<%= render(Storages::Admin::Forms::OAuthClientFormComponent.new(oauth_client: @oauth_client, storage: @storage)) %>
diff --git a/modules/storages/app/views/storages/admin/oauth_clients/show_redirect_uri.html.erb b/modules/storages/app/views/storages/admin/oauth_clients/show_redirect_uri.html.erb
new file mode 100644
index 00000000000..eb1c3576680
--- /dev/null
+++ b/modules/storages/app/views/storages/admin/oauth_clients/show_redirect_uri.html.erb
@@ -0,0 +1,32 @@
+<%#-- 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.
+
+++#%>
+
+<%= render(OpTurbo::FrameComponent.new(id: :storage_redirect_url_section)) do %>
+ <%= render(Storages::Admin::Forms::RedirectUriFormComponent.new(oauth_client: @storage.oauth_client, storage: @storage)) %>
+<% end %>
diff --git a/modules/storages/app/views/storages/admin/oauth_clients/update.turbo_stream.erb b/modules/storages/app/views/storages/admin/oauth_clients/update.turbo_stream.erb
index 9a27fd06284..ebe133dcb95 100644
--- a/modules/storages/app/views/storages/admin/oauth_clients/update.turbo_stream.erb
+++ b/modules/storages/app/views/storages/admin/oauth_clients/update.turbo_stream.erb
@@ -30,3 +30,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= turbo_stream.update :storage_oauth_client_section do %>
<%= render(Storages::Admin::OAuthClientInfoComponent.new(oauth_client: @oauth_client, storage: @storage)) %>
<% end %>
+
+<%= turbo_stream.update :storage_redirect_url_section do %>
+ <%= render(Storages::Admin::RedirectUriComponent.new(oauth_client: @oauth_client, storage: @storage)) %>
+<% 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.erb
deleted file mode 100644
index 64026630602..00000000000
--- a/modules/storages/app/views/storages/admin/storages/show_oauth_application.html.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-<%= render(OpTurbo::FrameComponent.new(id: :storage_openproject_oauth_section)) do %>
- <%= render(Storages::Admin::OAuthApplicationInfoCopyComponent.new(oauth_application: @oauth_application, storage: @storage)) %>
-<% end %>
diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml
index 1cbb864865e..ce1c90bb7d7 100644
--- a/modules/storages/config/locales/en.yml
+++ b/modules/storages/config/locales/en.yml
@@ -30,7 +30,7 @@ en:
creator: "Creator"
provider_type: "Provider type"
host: "Host"
- tenant: "Tenant"
+ tenant: "Directory (tenant) ID"
storages/file_link:
origin_id: "Origin Id"
@@ -91,6 +91,7 @@ en:
storage_provider: "Storage provider"
openproject_oauth: "OpenProject OAuth"
one_drive_oauth: "Azure OAuth"
+ redirect_uri: "Redirect URI"
nextcloud_oauth: "Nextcloud OAuth"
automatically_managed_folders: "Automatically managed folders"
page_titles:
@@ -170,6 +171,8 @@ en:
oauth_client_incomplete:
nextcloud: "Allow OpenProject to access Nextcloud data using OAuth."
one_drive: "Allow OpenProject to access Azure data using OAuth to connect OneDrive/Sharepoint."
+ redirect_uri_incomplete:
+ one_drive: "Complete the setup with the correct URI redirection."
delete_warning:
storage: >
Are you sure you want to delete %{file_storage}? To confirm this action please introduce the
@@ -220,11 +223,13 @@ en:
label_provider_type: "Provider type"
label_project_folder: "Project folder"
label_redirect_uri: "Redirect URI"
+ label_uri: "URI"
label_new_storage: "New storage"
label_new_file_storage: "New %{provider} storage"
label_edit_storage: "Edit storage"
label_edit_storage_host: "Edit storage host"
label_edit_storage_oauth_client: "Edit storage OAuth client"
+ label_show_storage_redirect_uri: "Show redirect URI"
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"
diff --git a/modules/storages/config/routes.rb b/modules/storages/config/routes.rb
index bb189de271e..da4caa47679 100644
--- a/modules/storages/config/routes.rb
+++ b/modules/storages/config/routes.rb
@@ -34,6 +34,8 @@ OpenProject::Application.routes.draw do
resources :storages, controller: '/storages/admin/storages', except: [:show] do
resource :oauth_client, controller: '/storages/admin/oauth_clients', only: %i[new create] do
patch :update, on: :member
+ get :show_redirect_uri
+ post :finish_setup
end
resource :automatically_managed_project_folders, controller: '/storages/admin/automatically_managed_project_folders',