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

Added possibilty to add tenant and drive ID for a OneDrive storage

Andreas Pfohl103ad0238a26
diff --git a/modules/storages/app/constants/storages/admin.rb b/modules/storages/app/constants/storages/admin.rb
index f56daeaf547..b0e8c49c0f8 100644
--- a/modules/storages/app/constants/storages/admin.rb
+++ b/modules/storages/app/constants/storages/admin.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -28,8 +30,10 @@
module Storages
module Admin
- LABEL_OAUTH_CLIENT_ID = 'OAuth Client ID'.freeze
- LABEL_OAUTH_CLIENT_SECRET = 'OAuth Client Secret'.freeze
- LABEL_OAUTH_REDIRECT_URI = 'OAuth Redirect URI'.freeze
+ LABEL_OAUTH_CLIENT_ID = 'OAuth Client ID'
+ LABEL_OAUTH_CLIENT_SECRET = 'OAuth Client Secret'
+ LABEL_OAUTH_REDIRECT_URI = 'OAuth Redirect URI'
+ LABEL_TENANT_ID = 'Tenant ID'
+ LABEL_DRIVE_ID = 'Drive ID'
end
end
diff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rb
index 9ba2273853f..030f7233cab 100644
--- a/modules/storages/app/controllers/storages/admin/storages_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb
@@ -88,7 +88,7 @@ class Storages::Admin::StoragesController < ApplicationController
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)
+ render '/storages/admin/storages/one_drive/edit'
when ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD
if @oauth_application.present?
flash.now[:notice] = I18n.t(:notice_successful_create)
@@ -103,7 +103,7 @@ class Storages::Admin::StoragesController < ApplicationController
# 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
+ # default attribute values because the object already exists;
# Called by: Global app/config/routes.rb to serve Web page
def edit; end
@@ -180,6 +180,6 @@ class Storages::Admin::StoragesController < ApplicationController
def permitted_storage_params
params
.require(:storages_storage)
- .permit('name', 'provider_type', 'host', 'oauth_client_id', 'oauth_client_secret')
+ .permit('name', 'provider_type', 'host', 'oauth_client_id', 'oauth_client_secret', 'tenant_id', 'drive_id')
end
end
diff --git a/modules/storages/app/views/storages/admin/storages/one_drive/edit.html.erb b/modules/storages/app/views/storages/admin/storages/one_drive/edit.html.erb
new file mode 100644
index 00000000000..0aecb02940d
--- /dev/null
+++ b/modules/storages/app/views/storages/admin/storages/one_drive/edit.html.erb
@@ -0,0 +1,64 @@
+<%#-- 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_information")}" %>
+
+<% local_assigns[:additional_breadcrumb] = [
+ link_to(@storage.name, edit_admin_settings_storage_path(@storage)),
+ t("storages.label_oauth_breadcrumb.#{@storage.short_provider_type}")
+] %>
+<%= toolbar title: "#{t("storages.provider_types.#{@storage.short_provider_type}.name")} #{t("storages.label_information")}" %>
+
+<%= labelled_tabular_form_for @storage, url: admin_settings_storage_path(@storage), as: :storages_storage do |f| -%>
+ <fieldset class="form--fieldset">
+ <div class="form--field -required">
+ <%= f.text_field :tenant_id,
+ label: Storages::Admin::LABEL_TENANT_ID,
+ required: true,
+ size: 40,
+ container_class: '-wide'
+ %>
+ <span class="form--field-instructions">
+ <%= t("storages.instructions.#{@storage.short_provider_type}.tenant_id") %>
+ </span>
+ </div>
+
+ <div class="form--field -required">
+ <%= f.text_field :drive_id,
+ label: Storages::Admin::LABEL_DRIVE_ID,
+ required: true,
+ size: 40,
+ container_class: '-wide' %>
+ <span class="form--field-instructions">
+ <%= t("storages.instructions.#{@storage.short_provider_type}.drive_id") %>
+ </span>
+ </div>
+ </fieldset>
+
+ <%= styled_button_tag t("storages.buttons.save_and_continue_setup"), class: "-highlight -with-icon icon-checkmark" %>
+<% end %>
diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml
index bf84fb1122a..9b121d47920 100644
--- a/modules/storages/config/locales/en.yml
+++ b/modules/storages/config/locales/en.yml
@@ -126,6 +126,10 @@ en:
Copy the client secret from the Azure portal. For a newly created application the secret first needs to be
created manually. For authorization of web applications a secret is mandatory.
missing_client_id_for_redirect_uri: "Client ID missing to provide redirect URI."
+ tenant_id: >
+ Please insert the tenant ID you got from your SharePoint administrator.
+ drive_id: >
+ The drive ID can be obtained by you SharePoint Administrator.
help_texts:
project_folder: >
The project folder is the default folder for file uploads for this project.
@@ -167,6 +171,7 @@ en:
one_drive: "OneDrive OAuth"
label_oauth_application_details: "OAuth application details"
label_oauth_client_details: "OAuth client details"
+ label_information: "Additional information"
label_provider_type: "Provider type"
label_project_folder: "Project folder"
label_new_storage: "New storage"