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

Implement border_box view component

Oliver Günther4caf835349f7
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 0b0ee449c0a..557d5041956 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2118,6 +2118,7 @@ en:
label_calendars_and_dates: "Calendars and dates"
label_calendar_show: "Show Calendar"
label_category: "Category"
+ label_completed: Completed
label_consent_settings: "User Consent"
label_wiki_menu_item: Wiki menu item
label_select_main_menu_item: Select new main menu item
@@ -2277,6 +2278,7 @@ en:
label_inactive: "Inactive"
label_incoming_emails: "Incoming emails"
label_includes: "includes"
+ label_incomplete: Incomplete
label_include_sub_projects: Include sub-projects
label_index_by_date: "Index by date"
label_index_by_title: "Index by title"
diff --git a/lib/open_project/static/links.rb b/lib/open_project/static/links.rb
index 97bf710de57..738734f4ff0 100644
--- a/lib/open_project/static/links.rb
+++ b/lib/open_project/static/links.rb
@@ -270,6 +270,11 @@ module OpenProject
href: "https://www.openproject.org/docs/system-admin-guide/manage-work-packages/work-package-status/#create-a-new-work-package-status"
}
},
+ sysadmin_docs: {
+ saml: {
+ href: "https://www.openproject.org/docs/system-admin-guide/authentication/saml/"
+ }
+ },
storage_docs: {
setup: {
href: "https://www.openproject.org/docs/system-admin-guide/integrations/storage/"
diff --git a/lib_static/redmine/i18n.rb b/lib_static/redmine/i18n.rb
index c54f18d32d9..2284a31fb1a 100644
--- a/lib_static/redmine/i18n.rb
+++ b/lib_static/redmine/i18n.rb
@@ -91,13 +91,15 @@ module Redmine
#
# @param i18n_key [String] The I18n key to translate.
# @param links [Hash] Link names mapped to URLs.
- def link_translate(i18n_key, links: {}, locale: ::I18n.locale)
+ # @param target [String] optional HTML target attribute for the links.
+ def link_translate(i18n_key, links: {}, locale: ::I18n.locale, target: nil)
translation = ::I18n.t(i18n_key.to_s, locale:)
result = translation.scan(link_regex).inject(translation) do |t, matches|
link, text, key = matches
href = String(links[key.to_sym])
+ link_tag = content_tag(:a, text, href: href, target: target)
- t.sub(link, "<a href=\"#{href}\">#{text}</a>")
+ t.sub(link, link_tag)
end
result.html_safe
diff --git a/modules/auth_saml/app/components/saml/providers/forms/general_info_form_component.html.erb b/modules/auth_saml/app/components/saml/providers/forms/general_info_form_component.html.erb
deleted file mode 100644
index a3454d52b3c..00000000000
--- a/modules/auth_saml/app/components/saml/providers/forms/general_info_form_component.html.erb
+++ /dev/null
@@ -1,24 +0,0 @@
-<%=
- primer_form_with(
- model: provider,
- url: saml_providers_path,
- method: :post,
- ) do |form|
- flex_layout do |general_info_row|
- general_info_row.with_row(mb: 3) do
- render(Saml::Providers::Infocomponent.new(provider))
- end
-
- general_info_row.with_row do
- render(
- Storages::Admin::SubmitOrCancelForm.new(
- form,
- storage:,
- submit_button_options:,
- cancel_button_options:
- )
- )
- end
- end
- end
-%>
diff --git a/modules/auth_saml/app/components/saml/providers/row_component.rb b/modules/auth_saml/app/components/saml/providers/row_component.rb
index c9a436a579f..ef5ef2f5eb4 100644
--- a/modules/auth_saml/app/components/saml/providers/row_component.rb
+++ b/modules/auth_saml/app/components/saml/providers/row_component.rb
@@ -8,7 +8,7 @@ module Saml
def name
concat render(Primer::Beta::Link.new(
scheme: :primary,
- href: url_for(action: :edit, id: provider.id)
+ href: url_for(action: :show, id: provider.id)
)) { provider.display_name || provider.name }
if provider.idp_sso_target_url
diff --git a/modules/auth_saml/app/components/saml/providers/sections/metadata_component.html.erb b/modules/auth_saml/app/components/saml/providers/sections/metadata_component.html.erb
new file mode 100644
index 00000000000..8ef31fb231d
--- /dev/null
+++ b/modules/auth_saml/app/components/saml/providers/sections/metadata_component.html.erb
@@ -0,0 +1,18 @@
+<%=
+ flex_layout do |flex|
+ flex.with_column do
+ render(Primer::Beta::Text.new(font_weight: :semibold)) { t("saml.providers.label_metadata") }
+ end
+
+ if provider.metadata_url.present?
+ flex.with_column do
+ render(Primer::Beta::Label.new(scheme: :success, ml: 1)) { t(:label_completed) }
+ end
+ end
+ end
+%>
+<%=
+ render(Primer::Beta::Text.new(tag: :p, font_size: :small, color: :subtle)) do
+ t("saml.providers.section_texts.metadata")
+ end
+%>
diff --git a/modules/auth_saml/app/components/saml/providers/sections/metadata_component.rb b/modules/auth_saml/app/components/saml/providers/sections/metadata_component.rb
new file mode 100644
index 00000000000..15e825edfd1
--- /dev/null
+++ b/modules/auth_saml/app/components/saml/providers/sections/metadata_component.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+#-- 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::Sections
+ class MetadataComponent < ApplicationComponent
+ include OpPrimer::ComponentHelpers
+
+ attr_reader :provider
+
+ def initialize(provider)
+ @provider = provider
+ end
+ end
+end
diff --git a/modules/auth_saml/app/components/saml/providers/sections/metadata_form_component.html.erb b/modules/auth_saml/app/components/saml/providers/sections/metadata_form_component.html.erb
new file mode 100644
index 00000000000..1e8be68155e
--- /dev/null
+++ b/modules/auth_saml/app/components/saml/providers/sections/metadata_form_component.html.erb
@@ -0,0 +1,25 @@
+<%=
+ primer_form_with(
+ model: provider,
+ url: saml_providers_path,
+ method: :post,
+ ) do |form|
+ flex_layout do |flex|
+ flex.with_row do
+ render(Primer::Alpha::SegmentedControl.new("aria-label": "File view", full_width: full_width, hide_labels: hide_labels, size: size)) do |component|
+ component.with_item(label: "Preview", icon: icon, selected: true)
+ component.with_item(label: "Raw", icon: icon)
+ component.with_item(label: "Blame", icon: icon)
+ end
+ end
+
+ flex.with_row do
+ render(Saml::Providers::MetadataUrlForm.new(form))
+ end
+
+ flex.with_row(mt: 4) do
+ render(Saml::Providers::SubmitOrCancelForm.new(form, provider:, state: :metadata))
+ end
+ end
+ end
+%>
diff --git a/modules/auth_saml/app/components/saml/providers/sections/metadata_form_component.rb b/modules/auth_saml/app/components/saml/providers/sections/metadata_form_component.rb
new file mode 100644
index 00000000000..a5065554b68
--- /dev/null
+++ b/modules/auth_saml/app/components/saml/providers/sections/metadata_form_component.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+#-- 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::Sections
+ class MetadataFormComponent < ApplicationComponent
+ include OpPrimer::ComponentHelpers
+
+ attr_reader :provider
+
+ def initialize(provider)
+ @provider = provider
+ end
+ end
+end
diff --git a/modules/auth_saml/app/components/saml/providers/sections/name_component.html.erb b/modules/auth_saml/app/components/saml/providers/sections/name_component.html.erb
new file mode 100644
index 00000000000..a911047d0bb
--- /dev/null
+++ b/modules/auth_saml/app/components/saml/providers/sections/name_component.html.erb
@@ -0,0 +1,15 @@
+<%=
+ flex_layout do |flex|
+ flex.with_column do
+ render(Primer::Beta::Text.new(font_weight: :semibold)) { t("saml.providers.singular") }
+ end
+ flex.with_column do
+ render(Primer::Beta::Label.new(scheme: :success, ml: 1)) { t(:label_completed) }
+ end
+ end
+%>
+<%=
+ render(Primer::Beta::Text.new(tag: :p, font_size: :small, color: :subtle)) do
+ t("saml.providers.section_texts.display_name")
+ end
+%>
diff --git a/modules/auth_saml/app/components/saml/providers/forms/general_info_form_component.rb b/modules/auth_saml/app/components/saml/providers/sections/name_component.rb
similarity index 89%
rename from modules/auth_saml/app/components/saml/providers/forms/general_info_form_component.rb
rename to modules/auth_saml/app/components/saml/providers/sections/name_component.rb
index 9d8216c4310..0d33cb2e5dc 100644
--- a/modules/auth_saml/app/components/saml/providers/forms/general_info_form_component.rb
+++ b/modules/auth_saml/app/components/saml/providers/sections/name_component.rb
@@ -28,11 +28,13 @@
# See COPYRIGHT and LICENSE files for more details.
#++
#
-module Saml::Providers::Forms
- class GeneralInfoFormComponent < ApplicationComponent
+module Saml::Providers::Sections
+ class NameComponent < ApplicationComponent
+ include OpPrimer::ComponentHelpers
+
attr_reader :provider
- def initialize(provider:)
+ def initialize(provider)
@provider = provider
end
end
diff --git a/modules/auth_saml/app/components/saml/providers/sections/name_form_component.html.erb b/modules/auth_saml/app/components/saml/providers/sections/name_form_component.html.erb
new file mode 100644
index 00000000000..b02055fa094
--- /dev/null
+++ b/modules/auth_saml/app/components/saml/providers/sections/name_form_component.html.erb
@@ -0,0 +1,17 @@
+<%=
+ primer_form_with(
+ model: provider,
+ url: saml_providers_path,
+ method: :post,
+ ) do |form|
+ flex_layout do |flex|
+ flex.with_row do
+ render(Saml::Providers::NameInputForm.new(form))
+ end
+
+ flex.with_row(mt: 4) do
+ render(Saml::Providers::SubmitOrCancelForm.new(form, provider:, state: :name))
+ end
+ end
+ end
+%>
diff --git a/modules/auth_saml/app/components/saml/providers/sections/name_form_component.rb b/modules/auth_saml/app/components/saml/providers/sections/name_form_component.rb
new file mode 100644
index 00000000000..4f0abfb0523
--- /dev/null
+++ b/modules/auth_saml/app/components/saml/providers/sections/name_form_component.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+#-- 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::Sections
+ class NameFormComponent < ApplicationComponent
+ include OpPrimer::ComponentHelpers
+
+ attr_reader :provider
+
+ def initialize(provider)
+ @provider = provider
+ end
+ end
+end
diff --git a/modules/auth_saml/app/components/saml/providers/view_component.html.erb b/modules/auth_saml/app/components/saml/providers/view_component.html.erb
new file mode 100644
index 00000000000..6231524a526
--- /dev/null
+++ b/modules/auth_saml/app/components/saml/providers/view_component.html.erb
@@ -0,0 +1,79 @@
+<%=
+ render(border_box_container) do |component|
+ component.with_header(color: :muted) do
+ render(Primer::Beta::Text.new(font_weight: :semibold)) { I18n.t("activemodel.attributes.saml/provider.display_name") }
+ end
+
+ component.with_row(scheme: :default) do
+ if edit_state == :name
+ render(Saml::Providers::Sections::NameFormComponent.new(provider))
+ else
+ render(Saml::Providers::Sections::NameComponent.new(provider))
+ end
+ end
+
+
+ component.with_row(scheme: :neutral, color: :muted) do
+ render(Primer::Beta::Text.new(font_weight: :semibold)) { I18n.t('saml.providers.label_automatic_configuration') }
+ end
+
+ component.with_row(scheme: :default) do
+ if edit_state == :metadata
+ render(Saml::Providers::Sections::MetadataFormComponent.new(provider))
+ else
+ render(Saml::Providers::Sections::MetadataComponent.new(provider))
+ end
+ end
+ #
+ # component.with_row(scheme: :default) do
+ # render(Storages::Admin::OAuthClientInfoComponent.new(oauth_client: storage.oauth_client, storage:))
+ # end
+ #
+ # component.with_row(scheme: :neutral, color: :muted) do
+ # grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|
+ # grid.with_area(:item, tag: :div) do
+ # render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1)) { I18n.t('storages.file_storage_view.project_folders') }
+ # end
+ # end
+ # end
+ #
+ # component.with_row(scheme: :default) do
+ # if automatically_managed_project_folders_section_closed?
+ # render(Storages::Admin::AutomaticallyManagedProjectFoldersInfoComponent.new(storage))
+ # else
+ # render(Storages::Admin::Forms::AutomaticallyManagedProjectFoldersFormComponent.new(storage))
+ # end
+ # end
+ # end
+ #
+ # if storage.provider_type_one_drive?
+ # component.with_row(scheme: :neutral, color: :muted) do
+ # grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|
+ # grid.with_area(:item, tag: :div, mr: 3) do
+ # render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1)) { I18n.t('storages.file_storage_view.access_management.title') }
+ # end
+ # end
+ # end
+ #
+ # component.with_row(scheme: :default) do
+ # render(Storages::Admin::AccessManagementComponent.new(storage))
+ # end
+ #
+ # component.with_row(scheme: :neutral, color: :muted) do
+ # grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|
+ # grid.with_area(:item, tag: :div, mr: 3) do
+ # render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1)) { I18n.t('storages.file_storage_view.oauth_applications') }
+ # end
+ # end
+ # end
+ #
+ # component.with_row(scheme: :default) do
+ # render(Storages::Admin::OAuthClientInfoComponent.new(oauth_client: storage.oauth_client, storage:))
+ # end
+ #
+ # component.with_row(scheme: :default) do
+ # render(Storages::Admin::RedirectUriComponent.new(oauth_client: storage.oauth_client, storage:))
+ # end
+ # end
+ end
+%>
diff --git a/modules/auth_saml/app/components/saml/providers/view_component.rb b/modules/auth_saml/app/components/saml/providers/view_component.rb
new file mode 100644
index 00000000000..e5106a384d3
--- /dev/null
+++ b/modules/auth_saml/app/components/saml/providers/view_component.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+#-- 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
+ class ViewComponent < ApplicationComponent
+ include OpPrimer::ComponentHelpers
+
+ options :edit_state
+
+ alias_method :provider, :model
+ end
+end
diff --git a/modules/auth_saml/app/controllers/saml/providers_controller.rb b/modules/auth_saml/app/controllers/saml/providers_controller.rb
index 54d6a1521fe..ec8b4b9f120 100644
--- a/modules/auth_saml/app/controllers/saml/providers_controller.rb
+++ b/modules/auth_saml/app/controllers/saml/providers_controller.rb
@@ -5,9 +5,11 @@ module Saml
before_action :require_admin
before_action :check_ee
- before_action :find_provider, only: %i[edit update destroy]
+ before_action :find_provider, only: %i[show edit update destroy]
def index; end
+ def edit; end
+ def show; end
def new
@provider = ::Saml::Provider.new(name: "saml")
@@ -28,21 +30,19 @@ module Saml
if @provider.save
flash[:notice] = I18n.t(:notice_successful_create)
- redirect_to action: :index
+ redirect_to saml_provider_path(@provider)
else
render action: :new
end
end
- def edit; end
-
def update
- @provider = ::OpenIDConnect::Provider.initialize_with(
+ @provider = ::Saml::Provider.initialize_with(
update_params.merge("name" => params[:id])
)
if @provider.save
flash[:notice] = I18n.t(:notice_successful_update)
- redirect_to action: :index
+ success_redirect
else
render action: :edit
end
@@ -60,6 +60,14 @@ module Saml
private
+ def success_redirect
+ if params[:edit_state].present?
+ redirect_to edit_saml_provider_path(@provider, edit_state: params[:edit_state])
+ else
+ redirect_to saml_provider_path(@provider)
+ end
+ end
+
def defaults
{}
end
diff --git a/modules/auth_saml/app/forms/saml/providers/metadata_url_form.rb b/modules/auth_saml/app/forms/saml/providers/metadata_url_form.rb
index ad700d621ef..649c0cb0a06 100644
--- a/modules/auth_saml/app/forms/saml/providers/metadata_url_form.rb
+++ b/modules/auth_saml/app/forms/saml/providers/metadata_url_form.rb
@@ -34,7 +34,7 @@ module Saml
name: :metadata_url,
label: I18n.t("saml.settings.metadata_url"),
required: false,
- caption: I18n.t("saml.setting_instructions.metadata_url"),
+ caption: I18n.t("saml.instructions.metadata_url"),
input_width: :medium
)
end
diff --git a/modules/auth_saml/app/forms/saml/providers/name_input_form.rb b/modules/auth_saml/app/forms/saml/providers/name_input_form.rb
index 0782f1c53da..e4b8c68e42d 100644
--- a/modules/auth_saml/app/forms/saml/providers/name_input_form.rb
+++ b/modules/auth_saml/app/forms/saml/providers/name_input_form.rb
@@ -31,10 +31,10 @@ module Saml
class NameInputForm < ApplicationForm
form do |f|
f.text_field(
- name: :name,
- label: I18n.t("activemodel.attributes.saml/provider.name"),
+ name: :display_name,
+ label: I18n.t("activemodel.attributes.saml/provider.display_name"),
required: true,
- caption: I18n.t("saml.setting_instructions.name"),
+ caption: I18n.t("saml.instructions.display_name"),
input_width: :medium
)
end
diff --git a/modules/auth_saml/app/forms/saml/providers/submit_or_cancel_form.rb b/modules/auth_saml/app/forms/saml/providers/submit_or_cancel_form.rb
index ad53b6c74bd..519d287eb02 100644
--- a/modules/auth_saml/app/forms/saml/providers/submit_or_cancel_form.rb
+++ b/modules/auth_saml/app/forms/saml/providers/submit_or_cancel_form.rb
@@ -29,15 +29,24 @@
module Saml
module Providers
class SubmitOrCancelForm < ApplicationForm
- form do |buttons|
- buttons.group(layout: :horizontal) do |button_group|
+ form do |f|
+ if @state
+ f.hidden(
+ name: :edit_state,
+ value: @state
+ )
+ end
+
+ f.group(layout: :horizontal) do |button_group|
button_group.submit(**@submit_button_options)
button_group.button(**@cancel_button_options)
end
end
- def initialize(submit_button_options: {}, cancel_button_options: {})
+ def initialize(provider:, state: nil, submit_button_options: {}, cancel_button_options: {})
super()
+ @state = state
+ @provider = provider
@submit_button_options = default_submit_button_options.merge(submit_button_options)
@cancel_button_options = default_cancel_button_options.merge(cancel_button_options)
end
@@ -58,10 +67,18 @@ module Saml
name: :cancel,
scheme: :default,
tag: :a,
- href: OpenProject::StaticRouting::StaticRouter.new.url_helpers.saml_providers_path,
+ href: back_link,
label: I18n.t("button_cancel")
}
end
+
+ def back_link
+ if @provider.new_record?
+ OpenProject::StaticRouting::StaticRouter.new.url_helpers.saml_providers_path
+ else
+ OpenProject::StaticRouting::StaticRouter.new.url_helpers.saml_provider_path(@provider)
+ end
+ end
end
end
end
diff --git a/modules/auth_saml/app/models/saml/provider.rb b/modules/auth_saml/app/models/saml/provider.rb
index 9a7592247e9..3934e83fbdb 100644
--- a/modules/auth_saml/app/models/saml/provider.rb
+++ b/modules/auth_saml/app/models/saml/provider.rb
@@ -6,7 +6,7 @@ module Saml
include ActiveModel::Conversion
attr_accessor :readonly
- validates_presence_of :name, :display_name
+ validates_presence_of :display_name
def initialize(readonly: false, **attributes)
self.readonly = readonly
@@ -19,6 +19,10 @@ module Saml
name
end
+ def name
+ super.presence || "saml-#{uuid}"
+ end
+
def sp_entity_id
super.presence || issuer.presence || url_helpers.root_url
end
@@ -99,6 +103,7 @@ module Saml
self.name_identifier_format = attributes.fetch(:name_identifier_format, DEFAULT_NAME_IDENTIFIER_FORMAT)
self.issuer = attributes.fetch(:issuer, url_helpers.root_url)
self.request_attributes = attributes.fetch(:request_attributes, default_request_attributes)
+ self.uuid ||= SecureRandom.hex(4)
end
def default_request_attributes
@@ -132,7 +137,7 @@ module Saml
def derived_attributes
{
- assertion_consumer_service_url: url_helpers.root_url.join("/auth/#{name}/callback")
+ assertion_consumer_service_url: URI.join(url_helpers.root_url, "/auth/#{name}/callback").to_s,
}
end
diff --git a/modules/auth_saml/app/views/saml/providers/new.html.erb b/modules/auth_saml/app/views/saml/providers/new.html.erb
index 2a7e3bcf7b6..6973dcdd6c8 100644
--- a/modules/auth_saml/app/views/saml/providers/new.html.erb
+++ b/modules/auth_saml/app/views/saml/providers/new.html.erb
@@ -1,33 +1,23 @@
<% html_title(t(:label_administration), t('saml.providers.label_add_new')) -%>
-<% local_assigns[:additional_breadcrumb] = t('saml.providers.label_add_new') %>
-<%= toolbar title: t('saml.providers.label_add_new') %>
+<%= render(Primer::OpenProject::PageHeader.new) do |header| %>
+ <% header.with_title { t('saml.providers.label_add_new') } %>
-<%= error_messages_for @provider %>
-
-
-<%=
- primer_form_with(
- model: @provider,
- url: { action: :import },
- method: :post
- ) do |form| %>
+ <% header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration")},
+ { href: saml_providers_path, text: t('saml.providers.plural') },
+ t('saml.providers.label_add_new')]) %>
- <%=
- render(Primer::OpenProject::FlexLayout.new) do |flex|
- flex.with_row(mb: 3) do
- render(Saml::Providers::NameInputForm.new(form))
- end
+ <% header.with_description do %>
+ <%= link_translate(
+ 'saml.instructions.new_description',
+ links: {
+ docs_url: ::OpenProject::Static::Links[:sysadmin_docs][:saml][:href],
+ },
+ target: "_blank"
+ ) %>
+ <% end %>
+<% end %>
- flex.with_row(mb: 3) do
- render(Saml::Providers::MetadataUrlForm.new(form))
- end
+<%= error_messages_for @provider %>
- flex.with_row do
- render(
- Saml::Providers::SubmitOrCancelForm.new(form)
- )
- end
- end
- %>
-<% end %>
+<%= render(Saml::Providers::ViewComponent.new(@provider, edit_state: :name)) %>
diff --git a/modules/auth_saml/app/views/saml/providers/show.html.erb b/modules/auth_saml/app/views/saml/providers/show.html.erb
new file mode 100644
index 00000000000..1b37c4b7344
--- /dev/null
+++ b/modules/auth_saml/app/views/saml/providers/show.html.erb
@@ -0,0 +1,30 @@
+<% html_title(t(:label_administration), t('saml.providers.plural'), @provider.display_name) -%>
+
+<%= render(Primer::OpenProject::PageHeader.new) do |header| %>
+ <% header.with_title { @provider.display_name } %>
+
+ <% header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration")},
+ { href: saml_providers_path, text: t('saml.providers.plural') },
+ @provider.display_name]) %>
+
+ <%
+ header.with_action_button(tag: :a,
+ scheme: :danger,
+ mobile_icon: :trash,
+ mobile_label: t(:button_delete),
+ size: :medium,
+ href: saml_provider_path(@provider),
+ aria: { label: I18n.t(:button_delete) },
+ data: {
+ confirm: t(:text_are_you_sure),
+ method: :delete,
+ },
+ title: I18n.t(:button_delete)) do |button|
+ button.with_leading_visual_icon(icon: :trash)
+ t(:button_delete)
+ end
+ %>
+
+<% end %>
+
+<%= render(Saml::Providers::ViewComponent.new(@provider)) %>
diff --git a/modules/auth_saml/config/locales/en.yml b/modules/auth_saml/config/locales/en.yml
index 78112af520d..c0dd0a05ae8 100644
--- a/modules/auth_saml/config/locales/en.yml
+++ b/modules/auth_saml/config/locales/en.yml
@@ -21,6 +21,8 @@ en:
invalid_url: "Provided metadata URL is invalid. Provide a HTTP(s) URL."
error: "Failed to retrieve the identity provider metadata: %{error}"
providers:
+ label_automatic_configuration: Automatic configuration
+ label_metadata: Metadata
label_add_new: New SAML identity provider
label_edit: Edit SAML identity provider %{name}
no_results_table: No SAML identity providers have been defined yet.
@@ -37,11 +39,16 @@ en:
legend: 'These attributes are added to the SAML XML metadata to signify to the identify provider which attributes OpenProject requires.'
name: 'Requested attribute key'
format: 'Attribute format'
+ section_texts:
+ display_name: "Configure the display name of the SAML provider."
+ metadata: "Pre-fill configuration using a metadata URL or by pasting metadata XML"
settings:
metadata_url: Identity provider metadata URL (Optional)
- setting_instructions:
- name: >
- The identifier of the SAML provider. This needs to be alphanumeric, unique, and is used in the URL fragment to identify the provider.
+ instructions:
+ new_description: >
+ Add a new SAML provider. Please refer to our [documentation on configuring SAML providers](docs_url).
+ display_name: >
+ The name of the provider. This will be displayed as the login button and in the list of providers.
metadata_url: >
Enter the URL of the identity provider XML metadata endpoint.
If provided, OpenProject will try to prefill all available configuration options from your identity provider.
diff --git a/modules/auth_saml/config/routes.rb b/modules/auth_saml/config/routes.rb
index cf0ddb5cf77..e09a10516a0 100644
--- a/modules/auth_saml/config/routes.rb
+++ b/modules/auth_saml/config/routes.rb
@@ -1,7 +1,7 @@
Rails.application.routes.draw do
scope :admin do
namespace :saml do
- resources :providers, only: %i[index new create edit update destroy] do
+ resources :providers do
collection do
post :import
end
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 d019b95d383..f12f5a69d3f 100644
--- a/modules/storages/app/components/storages/admin/storage_view_information.rb
+++ b/modules/storages/app/components/storages/admin/storage_view_information.rb
@@ -55,9 +55,9 @@ module Storages::Admin
return 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")
+ status_label(I18n.t(:label_completed), scheme: :success, test_selector: "label-#{configs.join('-')}-status")
else
- status_label(I18n.t("storages.label_incomplete"), scheme: :attention, test_selector: "label-#{configs.join('-')}-status")
+ status_label(I18n.t(:label_incomplete), scheme: :attention, test_selector: "label-#{configs.join('-')}-status")
end
end
diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml
index 0471043a59f..e568aa618f0 100644
--- a/modules/storages/config/locales/en.yml
+++ b/modules/storages/config/locales/en.yml
@@ -287,7 +287,6 @@ en:
label_active: Active
label_add_new_storage: Add new storage
label_automatic_folder: New folder with automatically managed permissions
- label_completed: Completed
label_creation_time: Creation time
label_creator: Creator
label_delete_storage: Delete storage
@@ -299,7 +298,6 @@ en:
label_file_storage: File storage
label_host: Host URL
label_inactive: Inactive
- label_incomplete: Incomplete
label_managed_project_folders:
application_password: Application password
automatically_managed_folders: Automatically managed folders