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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add information to side panel
Oliver Günther8c4ef34aee3a
diff --git a/app/components/op_primer/copy_to_clipboard_component.html.erb b/app/components/op_primer/copy_to_clipboard_component.html.erbnew file mode 100644index 00000000000..0546b100c46--- /dev/null+++ b/app/components/op_primer/copy_to_clipboard_component.html.erb@@ -0,0 +1,21 @@+<%=+ flex_layout(align_items: :center, **@system_arguments) do |flex|+ if @scheme == :link+ flex.with_column(classes: "ellipsis") do+ render(Primer::Beta::Link.new(+ id: @id,+ href: value,+ title: value,+ target: :_blank+ )) { value }+ end+ else+ flex.with_column(classes: "ellipsis") do+ render(Primer::Beta::Text.new(title: value)) { value }+ end+ end+ flex.with_column(ml: 1) do+ render(Primer::Beta::ClipboardCopy.new(value:, "aria-label": t(:button_copy_to_clipboard)))+ end+ end+%>diff --git a/app/components/op_primer/copy_to_clipboard_component.rb b/app/components/op_primer/copy_to_clipboard_component.rbnew file mode 100644index 00000000000..c892938dc53--- /dev/null+++ b/app/components/op_primer/copy_to_clipboard_component.rb@@ -0,0 +1,43 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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 OpPrimer+ class CopyToClipboardComponent < ApplicationComponent+ include OpPrimer::ComponentHelpers++ alias_method :value, :model++ def initialize(value = nil, scheme: :value, **system_arguments)+ super(value)++ @scheme = scheme+ @system_arguments = system_arguments+ @id = SecureRandom.hex(8)+ end+ end+enddiff --git a/lookbook/previews/op_primer/copy_to_clipboard_component_preview.rb b/lookbook/previews/op_primer/copy_to_clipboard_component_preview.rbnew file mode 100644index 00000000000..971ad18ac71--- /dev/null+++ b/lookbook/previews/op_primer/copy_to_clipboard_component_preview.rb@@ -0,0 +1,16 @@+# frozen_string_literal: true++module OpPrimer+ # @logical_path OpenProject/Primer+ class CopyToClipboardComponentPreview < Lookbook::Preview+ # @param value text+ def default(value: "Copy me!")+ render(OpPrimer::CopyToClipboardComponent.new(value))+ end++ # @param url text+ def as_link(url: "http://example.org")+ render(OpPrimer::CopyToClipboardComponent.new(url, scheme: :link))+ end+ end+enddiff --git a/modules/auth_saml/app/components/saml/providers/metadata_dialog_component.html.erb b/modules/auth_saml/app/components/saml/providers/metadata_dialog_component.html.erbdeleted file mode 100644index 68b1fe14c03..00000000000--- a/modules/auth_saml/app/components/saml/providers/metadata_dialog_component.html.erb+++ /dev/null@@ -1,40 +0,0 @@-<%=- render(Primer::Alpha::Dialog.new(- id:,- title: t("saml.providers.label_metadata_endpoint"),- size: :large- )) do |d|- d.with_header- d.with_body do- flex_layout do |flex|- flex.with_row(mb: 4) do- t("saml.providers.metadata.dialog")- end-- flex.with_row do- render(Primer::OpenProject::InputGroup.new) do |input_group|- input_group.with_text_input(name: :metadata_endpoint,- label: t("saml.providers.label_metadata_endpoint"),- visually_hide_label: true,- value: provider.metadata_endpoint)- input_group.with_trailing_action_clipboard_copy_button(- value: provider.metadata_endpoint,- aria: {- label: I18n.t('button_copy_to_clipboard')- })- end- end-- flex.with_row(justify_items: :flex_end) do-- end- end- end-- d.with_footer do- render(Primer::ButtonComponent.new(data: { 'close-dialog-id': id })) do- I18n.t("button_close")- end- end- end-%>diff --git a/modules/auth_saml/app/components/saml/providers/metadata_dialog_component.rb b/modules/auth_saml/app/components/saml/providers/metadata_dialog_component.rbdeleted file mode 100644index 016e9a5a755..00000000000--- a/modules/auth_saml/app/components/saml/providers/metadata_dialog_component.rb+++ /dev/null@@ -1,15 +0,0 @@-module Saml- module Providers- class MetadataDialogComponent < ApplicationComponent- include ApplicationHelper- include OpTurbo::Streamable- include OpPrimer::ComponentHelpers-- alias_method :provider, :model-- def id- "saml-metadata-dialog"- end- end- end-enddiff --git a/modules/auth_saml/app/components/saml/providers/side_panel/information_component.html.erb b/modules/auth_saml/app/components/saml/providers/side_panel/information_component.html.erbnew file mode 100644index 00000000000..7a38adc481b--- /dev/null+++ b/modules/auth_saml/app/components/saml/providers/side_panel/information_component.html.erb@@ -0,0 +1,24 @@+<%=+ render(Primer::OpenProject::SidePanel::Section.new) do |section|+ section.with_title { I18n.t("saml.providers.label_openproject_information") }+ section.with_description { I18n.t("saml.instructions.metadata_for_idp") }++ component_collection do |collection|+ collection.with_component(Primer::Beta::Heading.new(tag: :h5, mb: 1)) do+ I18n.t("activemodel.attributes.saml/provider.sp_entity_id")+ end++ collection.with_component(+ OpPrimer::CopyToClipboardComponent.new(provider.sp_entity_id, scheme: :input)+ )++ collection.with_component(Primer::Beta::Heading.new(tag: :h5, mt: 4, mb: 1)) do+ I18n.t("activemodel.attributes.saml/provider.assertion_consumer_service_url")+ end++ collection.with_component(+ OpPrimer::CopyToClipboardComponent.new(provider.callback_url, scheme: :link)+ )+ end+ end+%>diff --git a/modules/auth_saml/app/components/saml/providers/side_panel/information_component.rb b/modules/auth_saml/app/components/saml/providers/side_panel/information_component.rbnew file mode 100644index 00000000000..1d509fda9fd--- /dev/null+++ b/modules/auth_saml/app/components/saml/providers/side_panel/information_component.rb@@ -0,0 +1,39 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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 Saml::Providers+ module SidePanel+ class InformationComponent < ApplicationComponent+ include ApplicationHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ alias_method :provider, :model+ end+ end+enddiff --git a/modules/auth_saml/app/components/saml/providers/side_panel/metadata_component.html.erb b/modules/auth_saml/app/components/saml/providers/side_panel/metadata_component.html.erbindex 51d7f2b7e18..f8989607f58 100644--- a/modules/auth_saml/app/components/saml/providers/side_panel/metadata_component.html.erb+++ b/modules/auth_saml/app/components/saml/providers/side_panel/metadata_component.html.erb@@ -3,12 +3,17 @@section.with_title { I18n.t("saml.providers.label_metadata_endpoint") }section.with_description { I18n.t("saml.instructions.sp_metadata_endpoint") }- component_wrapper do- render(Primer::Beta::Link.new(- href: metadata_endpoint,- classes: "-break-word",- target: :_blank- )) { metadata_endpoint }+ flex_layout do |flex|+ flex.with_column(classes: "ellipsis") do+ render(Primer::Beta::Link.new(+ href: metadata_endpoint,+ title: metadata_endpoint,+ target: :_blank+ )) { metadata_endpoint }+ end+ flex.with_column(ml: 1) do+ render(Primer::Beta::ClipboardCopy.new(value: metadata_endpoint, "aria-label": t(:button_copy_to_clipboard)))+ endendend%>diff --git a/modules/auth_saml/app/components/saml/providers/side_panel/metadata_component.rb b/modules/auth_saml/app/components/saml/providers/side_panel/metadata_component.rbindex b04fd9e7709..9affbd43f2d 100644--- a/modules/auth_saml/app/components/saml/providers/side_panel/metadata_component.rb+++ b/modules/auth_saml/app/components/saml/providers/side_panel/metadata_component.rb@@ -33,14 +33,10 @@ module Saml::Providersinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpers- def initialize(provider:)- super()-- @provider = provider- end+ alias_method :provider, :modeldef metadata_endpoint- URI.join(helpers.root_url, "/auth/#{@provider.slug}/metadata").to_s+ URI.join(helpers.root_url, "/auth/#{provider.slug}/metadata").to_sendendenddiff --git a/modules/auth_saml/app/components/saml/providers/side_panel_component.html.erb b/modules/auth_saml/app/components/saml/providers/side_panel_component.html.erbindex d2182f1a908..c9d27ca3a71 100644--- a/modules/auth_saml/app/components/saml/providers/side_panel_component.html.erb+++ b/modules/auth_saml/app/components/saml/providers/side_panel_component.html.erb@@ -2,7 +2,8 @@component_wrapper dorender(Primer::OpenProject::SidePanel.new(spacious: true)) do |panel|[- Saml::Providers::SidePanel::MetadataComponent.new(provider: @provider),+ Saml::Providers::SidePanel::MetadataComponent.new(@provider),+ Saml::Providers::SidePanel::InformationComponent.new(@provider),].each do |component|panel.with_section(component)enddiff --git a/modules/auth_saml/app/components/saml/providers/view_component.html.erb b/modules/auth_saml/app/components/saml/providers/view_component.html.erbindex 0e2c86ad2db..0b69b8c522a 100644--- a/modules/auth_saml/app/components/saml/providers/view_component.html.erb+++ b/modules/auth_saml/app/components/saml/providers/view_component.html.erb@@ -44,26 +44,13 @@edit_mode:,))else- dialog_button =- if provider.persisted?- Primer::Beta::Button.new(- tag: :a,- href: show_metadata_saml_provider_path(provider),- scheme: :invisible,- color: :subtle,- 'aria-label': t('saml.providers.label_show_metadata'),- data: { turbo: true, 'turbo-stream': true }- ).with_content(t('saml.providers.label_show_metadata'))- end-render(Saml::Providers::Sections::ShowComponent.new(provider,target_state: :metadata,view_mode:,- action: dialog_button,heading: t("saml.providers.label_metadata"),description: t("saml.providers.section_texts.metadata"),- label: provider.has_metadata? ? t(:label_completed) : t(:label_not_configured),+ label: !provider.has_metadata? ? t(:label_completed) : t(:label_not_configured),label_scheme: provider.has_metadata? ? :success : :secondary))end@@ -139,7 +126,7 @@view_mode:,heading: t("saml.providers.label_mapping"),description: t("saml.providers.section_texts.mapping"),- label: provider.mapping_configured? ? t(:label_completed) : t(:label_incomplete),+ label: provider.mapping_configured? ? nil : t(:label_incomplete),label_scheme: provider.mapping_configured? ? :success : :attention))enddiff --git a/modules/auth_saml/app/controllers/saml/providers_controller.rb b/modules/auth_saml/app/controllers/saml/providers_controller.rbindex 15889b734b0..8d022fc98a8 100644--- a/modules/auth_saml/app/controllers/saml/providers_controller.rb+++ b/modules/auth_saml/app/controllers/saml/providers_controller.rb@@ -1,14 +1,13 @@module Samlclass ProvidersController < ::ApplicationControllerinclude OpTurbo::ComponentStream- include OpTurbo::DialogStreamHelperlayout "admin"menu_item :plugin_samlbefore_action :require_adminbefore_action :check_ee- before_action :find_provider, only: %i[show edit show_metadata import_metadata update destroy]+ before_action :find_provider, only: %i[show edit import_metadata update destroy]before_action :check_provider_writable, only: %i[update import_metadata]before_action :set_edit_state, only: %i[create edit update import_metadata]@@ -68,12 +67,6 @@ module Samlendend- def show_metadata- respond_with_dialog(- Saml::Providers::MetadataDialogComponent.new(@provider)- )- end-def createcall = ::Saml::Providers::CreateService.new(user: User.current)diff --git a/modules/auth_saml/config/locales/en.yml b/modules/auth_saml/config/locales/en.ymlindex 7a61e57311a..20e533e8dfd 100644--- a/modules/auth_saml/config/locales/en.yml+++ b/modules/auth_saml/config/locales/en.yml@@ -6,6 +6,7 @@ en:identifier: Identifiersecret: Secretscope: Scope+ assertion_consumer_service_url: Assertion consumer service URLlimit_self_registration: Limit self registrationsp_entity_id: Service entity IDmetadata_url: Identity provider metadata URL@@ -45,8 +46,8 @@ en:label_empty_description: "Add a provider to see them here."label_automatic_configuration: Automatic configurationlabel_metadata: Metadata- label_show_metadata: Show OpenProject metadata- label_metadata_endpoint: Metadata endpoint+ label_metadata_endpoint: OpenProject metadata endpoint+ label_openproject_information: OpenProject informationlabel_configuration_details: "Identity provider endpoints and certificates"label_configuration_encryption: "Signatures and Encryption"label_add_new: New SAML identity provider@@ -156,3 +157,5 @@ en:Select the digest algorithm to use for the SAML request signature performed by OpenProject (Default: %{default_option}).icon: >Optionally provide a public URL to an icon graphic that will be displayed next to the provider name.+ metadata_for_idp: >+ This information might be requested by your SAML identity provider.diff --git a/modules/auth_saml/config/routes.rb b/modules/auth_saml/config/routes.rbindex 6af0d120b4e..926f2427ae9 100644--- a/modules/auth_saml/config/routes.rb+++ b/modules/auth_saml/config/routes.rb@@ -4,7 +4,6 @@ Rails.application.routes.draw doresources :providers domember dopost :import_metadata- get :show_metadataendendend