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

fix[Op#56922]: ensure project storage form retains original text

Kabiru Mwenja4e3347d3a357
diff --git a/modules/storages/app/components/storages/admin/storages/oauth_access_grant_nudge_modal_component.rb b/modules/storages/app/components/storages/admin/storages/oauth_access_grant_nudge_modal_component.rb
index 25c7bc1a034..f879ab909b1 100644
--- a/modules/storages/app/components/storages/admin/storages/oauth_access_grant_nudge_modal_component.rb
+++ b/modules/storages/app/components/storages/admin/storages/oauth_access_grant_nudge_modal_component.rb
@@ -56,7 +56,7 @@ module Storages
def heading_text = I18n.t("storages.oauth_grant_nudge_modal.heading", provider_type:)
def waiting_title = I18n.t("storages.oauth_grant_nudge_modal.requesting_access_to", storage: storage.name)
def cancel_button_text = I18n.t(:button_close)
- def body_text = I18n.t("storages.oauth_grant_nudge_modal.description", provider_type:)
+ def body_text = I18n.t("storages.oauth_grant_nudge_modal.storage_admin.description", provider_type:)
def provider_type = I18n.t("storages.provider_types.#{storage.short_provider_type}.name")
def login_button_aria_label
diff --git a/modules/storages/app/components/storages/admin/storages/oauth_access_granted_modal_component.rb b/modules/storages/app/components/storages/admin/storages/oauth_access_granted_modal_component.rb
index a35716e70ba..1af88406f65 100644
--- a/modules/storages/app/components/storages/admin/storages/oauth_access_granted_modal_component.rb
+++ b/modules/storages/app/components/storages/admin/storages/oauth_access_granted_modal_component.rb
@@ -49,15 +49,22 @@ module Storages
def dialog_id = "#{wrapper_key}-dialog-id"
def dialog_body_id = "#{wrapper_key}-dialog-body-id"
- def title = I18n.t("storages.oauth_access_granted_modal.access_granted_screen_reader", storage: storage.name)
def cancel_button_text = I18n.t("button_close")
+ def title
+ I18n.t("storages.oauth_access_granted_modal.storage_admin.access_granted_screen_reader",
+ storage: storage.name)
+ end
+
def body_text
success_title = I18n.t("storages.oauth_access_granted_modal.access_granted")
- success_subtitle = I18n.t("storages.oauth_access_granted_modal.storage_ready", storage: storage.name)
concat(render(::Storages::OpenProjectStorageModalComponent::Body.new(:success, success_subtitle:, success_title:)))
end
+ def success_subtitle
+ I18n.t("storages.oauth_access_granted_modal.storage_admin.storage_ready", storage: storage.name)
+ end
+
def find_storage(storage_record_or_id)
return if storage_record_or_id.blank?
return storage_record_or_id if storage_record_or_id.is_a?(::Storages::Storage)
diff --git a/modules/storages/app/components/storages/project_storages/oauth_access_grant_nudge_modal_component.rb b/modules/storages/app/components/storages/project_storages/oauth_access_grant_nudge_modal_component.rb
index 3eeb3f3bfe6..c0f0b11c88e 100644
--- a/modules/storages/app/components/storages/project_storages/oauth_access_grant_nudge_modal_component.rb
+++ b/modules/storages/app/components/storages/project_storages/oauth_access_grant_nudge_modal_component.rb
@@ -48,9 +48,8 @@ module Storages
)
end
- def cancel_button_text
- I18n.t("storages.oauth_grant_nudge_modal.cancel_button_label")
- end
+ def body_text = I18n.t("storages.oauth_grant_nudge_modal.project_settings.description", storage: storage.name)
+ def cancel_button_text = I18n.t("storages.oauth_grant_nudge_modal.cancel_button_label")
def find_project_storage(project_storage_record_or_id)
return if project_storage_record_or_id.blank?
diff --git a/modules/storages/app/components/storages/project_storages/oauth_access_granted_modal_component.rb b/modules/storages/app/components/storages/project_storages/oauth_access_granted_modal_component.rb
new file mode 100644
index 00000000000..793005f5338
--- /dev/null
+++ b/modules/storages/app/components/storages/project_storages/oauth_access_granted_modal_component.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+#
+module Storages
+ module ProjectStorages
+ class OAuthAccessGrantedModalComponent < ::Storages::Admin::Storages::OAuthAccessGrantedModalComponent
+ private
+
+ def title
+ I18n.t("storages.oauth_access_granted_modal.project_settings.access_granted_screen_reader",
+ storage: storage.name)
+ end
+
+ def success_subtitle
+ I18n.t("storages.oauth_access_granted_modal.project_settings.storage_ready", storage: storage.name)
+ end
+ end
+ end
+end
diff --git a/modules/storages/app/controllers/concerns/storages/oauth_access_grantable.rb b/modules/storages/app/controllers/concerns/storages/oauth_access_grantable.rb
index 820b0efaed8..07c6b890bb0 100644
--- a/modules/storages/app/controllers/concerns/storages/oauth_access_grantable.rb
+++ b/modules/storages/app/controllers/concerns/storages/oauth_access_grantable.rb
@@ -52,6 +52,13 @@ module Storages
}
end
+ def project_storage_oauth_access_granted_modal(storage:)
+ {
+ type: ::Storages::ProjectStorages::OAuthAccessGrantedModalComponent.name,
+ parameters: { storage: storage.id }
+ }
+ end
+
def storage_oauth_access_granted_modal(storage:)
{
type: ::Storages::Admin::Storages::OAuthAccessGrantedModalComponent.name,
diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml
index 187cc8148bd..b1029eef75b 100644
--- a/modules/storages/config/locales/en.yml
+++ b/modules/storages/config/locales/en.yml
@@ -320,15 +320,22 @@ en:
of each desired project to use it.
oauth_access_granted_modal:
access_granted: Access granted
- access_granted_screen_reader: Access granted. You are now ready to add projects to %{storage}
- storage_ready: You are now ready to add projects to %{storage}
+ project_settings:
+ access_granted_screen_reader: Access granted. You are now ready to use %{storage}
+ storage_ready: You are now ready to use %{storage}
+ storage_admin:
+ access_granted_screen_reader: Access granted. You are now ready to add projects to %{storage}
+ storage_ready: You are now ready to add projects to %{storage}
oauth_grant_nudge_modal:
cancel_button_label: I will do it later
- description: In order to add projects to this storage you need to be logged into %{provider_type}. Please, log in and try again.
heading: Login to %{provider_type} required
login_button_aria_label: Login to %{storage}
login_button_label: "%{provider_type} log in"
+ project_settings:
+ description: To get access to the project folder you need to login to %{storage}.
requesting_access_to: Requesting access to %{storage}
+ storage_admin:
+ description: In order to add projects to this storage you need to be logged into %{provider_type}. Please, log in and try again.
open_project_storage_modal:
success:
subtitle: You are being redirected
diff --git a/modules/storages/spec/components/storages/project_storages/oauth_access_grant_nudge_modal_component_spec.rb b/modules/storages/spec/components/storages/project_storages/oauth_access_grant_nudge_modal_component_spec.rb
index 3c84c55a3d8..b9d2531b999 100644
--- a/modules/storages/spec/components/storages/project_storages/oauth_access_grant_nudge_modal_component_spec.rb
+++ b/modules/storages/spec/components/storages/project_storages/oauth_access_grant_nudge_modal_component_spec.rb
@@ -37,11 +37,11 @@ RSpec.describe Storages::ProjectStorages::OAuthAccessGrantNudgeModalComponent, t
render_inline(described_class.new(project_storage:))
expect(page).to have_css('[role="alert"]', text: "Login to Nextcloud required", aria: { live: :assertive })
+ expect(page).to have_css('h2[aria-hidden="true"]', text: "Login to Nextcloud required")
expect(page).to have_test_selector(
"oauth-access-grant-nudge-modal-body",
- text: "In order to add projects to this storage you need to be logged into Nextcloud. " \
- "Please, log in and try again."
+ text: "To get access to the project folder you need to login to #{storage.name}."
)
expect(page).to have_button("I will do it later")
diff --git a/modules/storages/spec/components/storages/project_storages/oauth_access_granted_modal_component_spec.rb b/modules/storages/spec/components/storages/project_storages/oauth_access_granted_modal_component_spec.rb
new file mode 100644
index 00000000000..42d25caeb26
--- /dev/null
+++ b/modules/storages/spec/components/storages/project_storages/oauth_access_granted_modal_component_spec.rb
@@ -0,0 +1,58 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+#
+require "spec_helper"
+require_module_spec_helper
+
+RSpec.describe Storages::ProjectStorages::OAuthAccessGrantedModalComponent, type: :component do # rubocop:disable RSpec/SpecFilePathFormat
+ let(:oauth_client) { build_stubbed(:oauth_client) }
+ let(:storage) { build_stubbed(:nextcloud_storage, oauth_client:) }
+
+ before do
+ allow(OAuthClientToken).to receive(:exists?).and_return(true)
+ end
+
+ it "renders a success modal" do
+ render_inline(described_class.new(storage:))
+
+ expect(page).to have_css(
+ "h1.sr-only",
+ text: "Access granted. You are now ready to use #{storage.name}"
+ )
+
+ expect(page).to have_content("Access granted")
+ expect(page).to have_content("You are now ready to use #{storage.name}")
+
+ expect(page).to have_button("Close")
+
+ aggregate_failures "checks that the current user has an oauth token" do
+ expect(OAuthClientToken).to have_received(:exists?)
+ .with(user: User.current, oauth_client: storage.oauth_client)
+ end
+ end
+end