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

chore[#50212]: Use clipboard copy component

Kabiru Mwenja62eb07fa8757
diff --git a/modules/storages/app/components/storages/admin/forms/oauth_application_form_component.html.erb b/modules/storages/app/components/storages/admin/forms/oauth_application_form_component.html.erb
deleted file mode 100644
index 85e8ebaa676..00000000000
--- a/modules/storages/app/components/storages/admin/forms/oauth_application_form_component.html.erb
+++ /dev/null
@@ -1,22 +0,0 @@
-<%=
- primer_form_with(
- model: storage,
- url: edit_admin_settings_storage_path(storage),
- method: :get
- ) do |form|
- flex_layout do |general_info_row|
- general_info_row.with_row(mb: 3) do
- render(Storages::Admin::ClipboardCopyInputForm.new(form))
- end
-
- general_info_row.with_row(mb: 3) do
- render(Storages::Admin::ClipboardCopyInputForm.new(form))
- end
-
- general_info_row.with_row do
- concat(render(Primer::Beta::Button.new(scheme: :primary, type: :submit)) { I18n.t('storages.buttons.done_continue') })
- concat(render(Primer::Beta::Button.new(scheme: :default, tag: :a, href: edit_admin_settings_storage_path(storage))) { I18n.t('button_cancel') })
- end
- end
- end
-%>
diff --git a/modules/storages/app/components/storages/admin/oauth_application_credentials_copy_component.html.erb b/modules/storages/app/components/storages/admin/oauth_application_credentials_copy_component.html.erb
new file mode 100644
index 00000000000..3a53808c909
--- /dev/null
+++ b/modules/storages/app/components/storages/admin/oauth_application_credentials_copy_component.html.erb
@@ -0,0 +1,31 @@
+<%=
+ flex_layout(flex_items: :center) do |general_info_row|
+ general_info_row.with_row(mb: 3) do
+ render(
+ OpenProject::Common::ClipboardCopyComponent.new(
+ name: :openproject_oauth_application_uid,
+ value_to_copy: oauth_application.uid,
+ label: I18n.t('storages.label_openproject_oauth_client_id'),
+ required: true
+ )
+ )
+ end
+
+ general_info_row.with_row(mb: 3) do
+ render(
+ OpenProject::Common::ClipboardCopyComponent.new(
+ name: :openproject_oauth_application_secret,
+ value_to_copy: oauth_application.secret,
+ label: I18n.t('storages.label_openproject_oauth_client_secret'),
+ required: true
+ )
+ )
+ end
+
+ general_info_row.with_row do
+ # TODO: Check with product if "Done, Continue" button is context aware
+ concat(render(Primer::Beta::Button.new(scheme: :primary, tag: :a, href: edit_admin_settings_storage_path(storage))) { I18n.t('storages.buttons.done_continue') })
+ concat(render(Primer::Beta::Button.new(scheme: :default, tag: :a, href: edit_admin_settings_storage_path(storage))) { I18n.t('button_cancel') })
+ end
+ end
+%>
diff --git a/modules/storages/app/components/storages/admin/forms/oauth_application_form_component.rb b/modules/storages/app/components/storages/admin/oauth_application_credentials_copy_component.rb
similarity index 94%
rename from modules/storages/app/components/storages/admin/forms/oauth_application_form_component.rb
rename to modules/storages/app/components/storages/admin/oauth_application_credentials_copy_component.rb
index b32fcf9ffd2..071cc40524d 100644
--- a/modules/storages/app/components/storages/admin/forms/oauth_application_form_component.rb
+++ b/modules/storages/app/components/storages/admin/oauth_application_credentials_copy_component.rb
@@ -28,8 +28,8 @@
# See COPYRIGHT and LICENSE files for more details.
#++
#
-module Storages::Admin::Forms
- class OAuthApplicationFormComponent < ApplicationComponent
+module Storages::Admin
+ class OAuthApplicationCredentialsCopyComponent < ApplicationComponent
include OpPrimer::ComponentHelpers
attr_reader :storage
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
index 9c36e4e64a7..99dbd03b4a1 100644
--- 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
@@ -1,6 +1,6 @@
<% if OpenProject::FeatureDecisions.storage_primer_design_active? %>
<%= render(OpTurbo::FrameWrapperComponent.new(@storage, frame: :openproject_oauth)) do %>
- <%= render(Storages::Admin::Forms::OAuthApplicationFormComponent.new(oauth_application: @oauth_application, storage: @storage)) %>
+ <%= render(Storages::Admin::OAuthApplicationCredentialsCopyComponent.new(oauth_application: @oauth_application, storage: @storage)) %>
<% end %>
<% else %>
<% html_title t(:label_administration), t("project_module_storages"), @storage.name, "#{t("storages.provider_types.#{@storage.short_provider_type}.name")} #{t("storages.label_oauth_application_details")}" %>
diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml
index c1564765749..2d1b83c222f 100644
--- a/modules/storages/config/locales/en.yml
+++ b/modules/storages/config/locales/en.yml
@@ -179,6 +179,8 @@ en:
one_drive: "OneDrive OAuth"
label_oauth_application_details: "OAuth application details"
label_oauth_client_details: "OAuth client details"
+ label_openproject_oauth_client_id: "OpenProject OAuth Client ID"
+ label_openproject_oauth_client_secret: "OpenProject OAuth Client Secret"
label_oauth_client_id: "OAuth Client ID"
label_provider_type: "Provider type"
label_project_folder: "Project folder"