From aab2b1f7749210b7a1156732786c9789d9d1649b Mon Sep 17 00:00:00 2001 From: Bruno Pagno Date: Wed, 4 Dec 2024 14:56:47 +0100 Subject: [PATCH] inject translated message instead of using link on translation --- config/locales/js-en.yml | 3 -- .../open-project-storage-modal.controller.ts | 6 ++-- lib/open_project/static/links.rb | 3 ++ ...n_project_storage_modal_component.html.erb | 2 +- .../open_project_storage_modal_component.rb | 32 +++++++++++++++---- modules/storages/config/locales/en.yml | 5 +++ 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml index 55d76426ebf2..e95034ef0707 100644 --- a/config/locales/js-en.yml +++ b/config/locales/js-en.yml @@ -1453,6 +1453,3 @@ en: waiting_subtitle: network_off: "There is a network problem." network_on: "Network is back. We are trying." - timeout: > - OpenProject could not provide you access to the project folder within the expected period of time. Please, try once again.

- If that problem persists please contact your OpenProject administrator to check the health status of the file storage setup. diff --git a/frontend/src/stimulus/controllers/dynamic/storages/open-project-storage-modal.controller.ts b/frontend/src/stimulus/controllers/dynamic/storages/open-project-storage-modal.controller.ts index 6e3ad561e7a5..046c0100bb4c 100644 --- a/frontend/src/stimulus/controllers/dynamic/storages/open-project-storage-modal.controller.ts +++ b/frontend/src/stimulus/controllers/dynamic/storages/open-project-storage-modal.controller.ts @@ -36,12 +36,14 @@ export default class OpenProjectStorageModalController extends Controller <% dialog.with_header(display: :none) %> <% dialog.with_body(id: self.class.dialog_body_id, p: 2) do %> diff --git a/modules/storages/app/components/storages/open_project_storage_modal_component.rb b/modules/storages/app/components/storages/open_project_storage_modal_component.rb index 7af3c0811d76..f447e7cfead5 100644 --- a/modules/storages/app/components/storages/open_project_storage_modal_component.rb +++ b/modules/storages/app/components/storages/open_project_storage_modal_component.rb @@ -29,15 +29,13 @@ #++ class Storages::OpenProjectStorageModalComponent < ViewComponent::Base + attr_reader :controller, :project_storage_open_url, :redirect_url, :state + def initialize(project_storage_open_url:, redirect_url:, state:, **options) super - controller = "storages--open-project-storage-modal" - @data = { - controller:, - "application-target": "dynamic", - "#{controller}-project-storage-open-url-value": project_storage_open_url, - "#{controller}-redirect-url-value": redirect_url - } + @controller = "storages--open-project-storage-modal" + @project_storage_open_url = project_storage_open_url + @redirect_url = redirect_url @state = state end @@ -48,4 +46,24 @@ def self.dialog_id def self.dialog_body_id "open-project-storage-modal-body-component" end + + def data + @data = { + controller:, + "application-target": "dynamic", + "#{controller}-project-storage-open-url-value": project_storage_open_url, + "#{controller}-redirect-url-value": redirect_url, + "#{controller}-subtitle-timeout-text-value": subtitle_timeout_text + } + end + + def subtitle_timeout_text + href = OpenProject::Static::Links[:storage_docs][:health_status][:href] + I18n.t( + "storages.open_project_storage_modal.timeout.subtitle", + storages_health_link: render(Primer::Beta::Link.new(href:, target: "_blank")) do + I18n.t("storages.open_project_storage_modal.timeout.link_text") + end + ) + end end diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml index 216d8ee4e368..7b58cc683cb5 100644 --- a/modules/storages/config/locales/en.yml +++ b/modules/storages/config/locales/en.yml @@ -347,6 +347,11 @@ en: waiting: subtitle: One moment please, this might take some time... title: We are setting up your permissions on the project folder. + timeout: + subtitle: > + OpenProject could not provide you access to the project folder within the expected period of time. Please, try once again.

+ If that problem persists please contact your OpenProject administrator to check the %{storages_health_link}. + link_text: health status of the file storage setup page_titles: file_storages: delete: Delete file storage