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

[#51384] fixed storage admin pages

Eric Schubert8306d3f6bc1c
diff --git a/lib/open_project/static/links.rb b/lib/open_project/static/links.rb
index da3d8a904ed..be4da368036 100644
--- a/lib/open_project/static/links.rb
+++ b/lib/open_project/static/links.rb
@@ -265,11 +265,14 @@ module OpenProject
one_drive_setup: {
href: 'https://www.openproject.org/docs/system-admin-guide/integrations/one-drive/'
},
+ one_drive_drive_id_guide: {
+ href: 'https://www.openproject.org/docs/system-admin-guide/integrations/one-drive/drive-id-guide/'
+ },
nextcloud_oauth_application: {
href: 'https://apps.nextcloud.com/apps/integration_openproject'
},
one_drive_oauth_application: {
- href: 'https://docs.microsoft.com/en-us/graph/auth-register-app-v2'
+ href: 'https://portal.azure.com/'
}
},
ical_docs: {
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 1c673f8189f..714ce8a7ad8 100644
--- a/modules/storages/app/components/storages/admin/storage_view_information.rb
+++ b/modules/storages/app/components/storages/admin/storage_view_information.rb
@@ -23,6 +23,9 @@ module Storages::Admin
end
def configuration_check_label_for(*configs)
+ # do not show the status label, if storage is completely empty (initial state)
+ return nil if storage.configuration_checks.values.none?
+
if storage.configuration_checks.slice(*configs.map(&:to_sym)).values.all?
status_label(I18n.t('storages.label_completed'), scheme: :success, test_selector: "label-#{configs.join('-')}-status")
else
@@ -35,6 +38,9 @@ module Storages::Admin
end
def automatically_managed_project_folders_status_label
+ # do not show the status label, if storage is completely empty (initial state)
+ return nil if storage.configuration_checks.values.none?
+
test_selector = 'label-managed-project-folders-status'
if storage.automatically_managed?
diff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rb
index fc6c39cee05..81cc1698fe6 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
service_result = ::Storages::Storages::SetAttributesService
.new(user: current_user,
model: @object,
- contract_class: Storages::Storages::BaseContract,
+ contract_class: EmptyContract,
contract_options: { skip_provider_type_strategy: true })
.call
@storage = service_result.result
diff --git a/modules/storages/app/forms/storages/admin/provider_drive_id_input_form.rb b/modules/storages/app/forms/storages/admin/provider_drive_id_input_form.rb
index c332d70ea00..5510722cde3 100644
--- a/modules/storages/app/forms/storages/admin/provider_drive_id_input_form.rb
+++ b/modules/storages/app/forms/storages/admin/provider_drive_id_input_form.rb
@@ -34,10 +34,19 @@ module Storages::Admin
label: Storages::Admin::LABEL_DRIVE_ID,
visually_hide_label: false,
required: true,
- caption: I18n.t("storages.instructions.one_drive.drive_id"),
- placeholder: I18n.t("storages.instructions.one_drive.drive_id_placeholder"),
+ caption: caption.html_safe, # rubocop:disable Rails/OutputSafety
input_width: :large
)
end
+
+ private
+
+ def caption
+ href = ::OpenProject::Static::Links[:storage_docs][:one_drive_drive_id_guide][:href]
+ I18n.t('storages.instructions.one_drive.drive_id',
+ drive_id_link_text: render(Primer::Beta::Link.new(href:, target: '_blank')) do
+ I18n.t('storages.instructions.one_drive.documentation_link_text')
+ end)
+ end
end
end
diff --git a/modules/storages/app/forms/storages/admin/provider_tenant_id_input_form.rb b/modules/storages/app/forms/storages/admin/provider_tenant_id_input_form.rb
index 70ec13e5a10..271df877fb9 100644
--- a/modules/storages/app/forms/storages/admin/provider_tenant_id_input_form.rb
+++ b/modules/storages/app/forms/storages/admin/provider_tenant_id_input_form.rb
@@ -34,10 +34,20 @@ module Storages::Admin
label: I18n.t('activerecord.attributes.storages/storage.tenant'),
visually_hide_label: false,
required: true,
- caption: I18n.t("storages.instructions.one_drive.tenant_id"),
- placeholder: I18n.t("storages.instructions.one_drive.tenant_id_placeholder"),
+ caption: caption.html_safe, # rubocop:disable Rails/OutputSafety
+ placeholder: I18n.t('storages.instructions.one_drive.tenant_id_placeholder'),
input_width: :large
)
end
+
+ private
+
+ def caption
+ href = ::OpenProject::Static::Links[:storage_docs][:one_drive_oauth_application][:href]
+ I18n.t('storages.instructions.one_drive.tenant_id',
+ application_link_text: render(Primer::Beta::Link.new(href:, target: '_blank')) do
+ I18n.t('storages.instructions.one_drive.application_link_text')
+ end)
+ end
end
end
diff --git a/modules/storages/app/models/storages/one_drive_storage.rb b/modules/storages/app/models/storages/one_drive_storage.rb
index d6c6e0ccc6b..ef51cfd3314 100644
--- a/modules/storages/app/models/storages/one_drive_storage.rb
+++ b/modules/storages/app/models/storages/one_drive_storage.rb
@@ -30,7 +30,7 @@
module Storages
class OneDriveStorage < Storage
- store_attribute :provider_fields, :tenant_id, :string, default: 'consumers'
+ store_attribute :provider_fields, :tenant_id, :string
store_attribute :provider_fields, :drive_id, :string
using ::Storages::Peripherals::ServiceResultRefinements
diff --git a/modules/storages/app/services/storages/storages/set_attributes_service.rb b/modules/storages/app/services/storages/storages/set_attributes_service.rb
index 3c6113d6104..4d8755d8bab 100644
--- a/modules/storages/app/services/storages/storages/set_attributes_service.rb
+++ b/modules/storages/app/services/storages/storages/set_attributes_service.rb
@@ -33,7 +33,6 @@ module Storages::Storages
def set_default_attributes(_params)
storage.creator ||= user
- storage.name ||= derive_default_storage_name
end
private
@@ -51,7 +50,7 @@ module Storages::Storages
cloned_param = params.clone
if cloned_param[:host] == ''
- cloned_param.merge!(host: nil)
+ cloned_param[:host] = nil
end
cloned_param
@@ -71,15 +70,6 @@ module Storages::Storages
model
end
- def derive_default_storage_name
- prefix = I18n.t("storages.default_name")
- last_id = Storages::Storage.where("name like ?", "#{prefix}%").maximum(:id)
-
- return prefix if last_id.nil?
-
- "#{prefix} #{last_id + 1}"
- end
-
def nextcloud_storage?
storage.is_a?(Storages::NextcloudStorage)
end
diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml
index 6ca61b0d542..1cbb864865e 100644
--- a/modules/storages/config/locales/en.yml
+++ b/modules/storages/config/locales/en.yml
@@ -142,21 +142,26 @@ en:
application_link_text: "application “Integration OpenProject”"
integration: "Nextcloud Administration / OpenProject"
one_drive:
- provider_configuration: "Please make sure you have administration privileges in the %{application_link_text} before doing the setup."
- oauth_configuration: "Copy these values from the %{application_link_text}. After that, copy the redirect URI back to the %{application_link_text}."
- application_link_text: "Azure application"
+ provider_configuration: >
+ Please make sure you have administration privileges in the %{application_link_text} or contact your Microsoft
+ administrator before doing the setup. In the portal, you also need to register an Azure application or use an
+ existing one for authentication.
+ oauth_configuration: "Copy these values from the desired application in the %{application_link_text}."
+ application_link_text: "Azure portal"
integration: "OneDrive/SharePoint"
oauth_client_id: >
Copy the client id from the Azure portal. This is needed to generate the redirect URI.
oauth_client_secret: >
- The client secret has been automatically copied from an already fully connected file storage with the same Application (client) ID.
+ In case there is no application client secret under Client credentials, please create a new one.
oauth_client_redirect_uri: >
Please copy this value to a new Web redirect URI under Redirect URIs.
missing_client_id_for_redirect_uri: "Please fill the OAuth values to generate a URI"
- tenant_id: "Please copy the tenant from your Azure application."
+ tenant_id: >
+ Please copy the Directory (tenant) ID from the desired application und App registrations
+ in the %{application_link_text}.
tenant_id_placeholder: "Name or UUID"
- drive_id: "Please copy the drive ID from your Azure application."
- drive_id_placeholder: "UUID or triple ID"
+ drive_id: "Please copy the ID from the desired drive by following the steps in the %{drive_id_link_text}."
+ documentation_link_text: "OneDrive/SharePoint file storages documentation"
help_texts:
project_folder: >
The project folder is the default folder for file uploads for this project.