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: align attribute groups across the application (#13081)

Yulec942e44fc08a
diff --git a/app/components/attribute_groups/attribute_group_component.html.erb b/app/components/attribute_groups/attribute_group_component.html.erb
index 40c0704fc17..856f6e3d49b 100644
--- a/app/components/attribute_groups/attribute_group_component.html.erb
+++ b/app/components/attribute_groups/attribute_group_component.html.erb
@@ -30,9 +30,11 @@ See COPYRIGHT and LICENSE files for more details.
<div class="attributes-group">
<%= header %>
- <div class="attributes-key-value">
+ <div class="attributes-group--attributes">
<% attributes.each do |attribute| %>
- <%= attribute %>
+ <div class="attributes-key-value">
+ <%= attribute %>
+ </div>
<% end %>
</div>
diff --git a/app/components/attribute_groups/attribute_key_value_component.html.erb b/app/components/attribute_groups/attribute_key_value_component.html.erb
index f78ffa9dcb9..dd6a2c7a4c1 100644
--- a/app/components/attribute_groups/attribute_key_value_component.html.erb
+++ b/app/components/attribute_groups/attribute_key_value_component.html.erb
@@ -30,6 +30,10 @@ See COPYRIGHT and LICENSE files for more details.
<div class="attributes-key-value--key"><%= key %></div>
<div class="attributes-key-value--value-container">
<div class="attributes-key-value--value -text">
- <span><%= value %></span>
+ <% if value %>
+ <span><%= value %></span>
+ <% end %>
+
+ <%= content %>
</div>
</div>
diff --git a/app/views/admin/info.html.erb b/app/views/admin/info.html.erb
index f6572231468..bc664ab5e87 100644
--- a/app/views/admin/info.html.erb
+++ b/app/views/admin/info.html.erb
@@ -29,126 +29,70 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title(t(:label_administration), t(:label_information_plural)) -%>
-<%= toolbar title: I18n.t('label_information_plural') %>
-
-<div class="attributes-group">
- <div class="attributes-key-value">
- <%= call_hook(:view_admin_info_top) %>
- <% if (product_version = OpenProject::VERSION.product_version).present? %>
- <div class="attributes-key-value--key"><%= t(:label_product_version) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span><strong><%= product_version %></strong></span>
- </div>
- </div>
- <% end %>
- <div class="attributes-key-value--key"><%= t(:label_core_version) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span><strong><%= OpenProject::Info.versioned_name %></strong> </span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= t(:label_database_version) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span><%= @db_version %></span>
- </div>
- </div>
- <% if OpenProject::Database.version_deprecated? %>
- <div class="attributes-key-value--key"></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <strong>
- <%= op_icon 'icon3 icon-warning' %>
- Deprecation warning:
- </strong>
- <p>
- The next major release of OpenProject will update the requirements
- on the required PostgreSQL database version.
- <br/>
- Starting with OpenProject 12.0, anticipated end of 2021, PostgreSQL 13 will be required
- to use OpenProject.
- <br/>
- We have prepared <%= static_link_to :postgres_13_upgrade,
- label: 'upgrade guides for all installation methods' %>.
- You can perform the upgrade ahead of the release at any time by following the guides.
- </p>
- </div>
- </div>
- <% end %>
- <% if display_security_badge_graphic? %>
- <div class="attributes-key-value--key"></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <div class="security-badge--container">
- <%= content_tag :object, nil, data: security_badge_url, type: "image/svg+xml" %>
- <%= link_to '',
- ::OpenProject::Static::Links[:security_badge_documentation][:href],
- title: t(:label_what_is_this),
- class: 'security-badge--help-icon icon-context icon-help1',
- target: '_blank' %>
- </div>
- </div>
- </div>
- <% end %>
- <% if (updated_on = OpenProject::VERSION.updated_on).present? %>
- <div class="attributes-key-value--key"><%= t(:label_last_change_on) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span><%= format_date(updated_on) %></span>
- </div>
- </div>
- <% end %>
- </div>
-</div>
-
-<%= content_tag :h3, I18n.t('label_system') %>
-
-<div class="attributes-group">
- <div class="attributes-key-value">
- <% @checklist.each do |label, result| %>
- <div class="attributes-key-value--key"><%= I18n.t(label) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span><%= icon_wrapper((result ? 'icon-context icon-checkmark' : 'icon-context icon-bug'), (result ? t(:general_text_Yes) : t(:general_text_No))) %></span>
- </div>
- </div>
- <% end %>
- </div>
-</div>
+<%= call_hook(:view_admin_info_top) %>
+
+<%= render(AttributeGroups::AttributeGroupComponent.new) do |component|
+ component.with_header(title: I18n.t('label_information_plural'))
+
+ if (product_version = OpenProject::VERSION.product_version).present?
+ component.with_attribute(key: t(:label_product_version), value: product_version)
+ end
+
+ component.with_attribute(key: t(:label_core_version), value: OpenProject::Info.versioned_name)
+ component.with_attribute(key: t(:label_database_version), value: @db_version)
+
+ if display_security_badge_graphic?
+ content = content_tag :object, nil, data: security_badge_url, type: "image/svg+xml"
+ content += link_to '',
+ ::OpenProject::Static::Links[:security_badge_documentation][:href],
+ title: t(:label_what_is_this),
+ class: 'security-badge--help-icon icon-context icon-help1',
+ target: '_blank'
+ component.with_attribute(key: '', value: content)
+ end
+
+ if OpenProject::Database.version_deprecated?
+ value = <<~STR.html_safe
+ <p>
+ Starting with OpenProject 12.0, PostgreSQL 13 is required to use OpenProject.
+ <br/>
+ We have prepared #{static_link_to(:postgres_13_upgrade, label: 'upgrade guides for all installation methods')}.
+ You can perform the upgrade ahead of the release at any time by following the guides.
+ </p>
+ STR
+ component.with_attribute(key: 'Deprecation warning', value:)
+ end
+
+
+ if (updated_on = OpenProject::VERSION.updated_on).present?
+ component.with_attribute(key: t(:label_last_change_on), value: format_date(updated_on))
+ end
+end %>
+
+<%= render(AttributeGroups::AttributeGroupComponent.new) do |component|
+ component.with_header(title: I18n.t(:label_system))
+
+ @checklist.each do |label, result|
+ value = icon_wrapper((result ? 'icon-context icon-checkmark' : 'icon-context icon-bug'), (result ? t(:general_text_Yes) : t(:general_text_No)))
+ component.with_attribute(key: I18n.t(label), value:)
+ end
+end %>
<% @storage_information.each_with_index do |(_, entries), i| %>
- <%= content_tag :h3, t(:label_storage_group, identifier: i + 1) %>
- <div class="attributes-group">
- <div class="attributes-key-value">
- <div class="attributes-key-value--key"><%= t(:label_storage_for) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span>
- <% entries[:labels].each do |l| %>
- <%= l %>
- <br/>
- <% end %>
- </span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= t(:label_storage_free_space) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span><%= number_to_human_size(entries[:data][:free], precision: 2) %></span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= t(:label_storage_used_space) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span>
- <%= number_to_human_size(entries[:data][:used], precision: 2) %>
- (<%= entries[:data][:percent_used].round(2) %> %)
- </span>
- </div>
- </div>
- </div>
- </div>
+ <%=
+ render(AttributeGroups::AttributeGroupComponent.new) do |component|
+ component.with_header(title: t(:label_storage_group, identifier: i + 1))
+
+ component.with_attribute(key: t(:label_storage_for),
+ value: safe_join(entries[:labels], '<br/>'.html_safe))
+
+ component.with_attribute(key: t(:label_storage_free_space),
+ value: number_to_human_size(entries[:data][:free], precision: 2))
+
+ value = number_to_human_size(entries[:data][:used], precision: 2)
+ value += "(#{entries[:data][:percent_used].round(2)})"
+ component.with_attribute(key: t(:label_storage_used_space), value:)
+ end %>
<% end %>
<%= call_hook(:view_admin_info_bottom) %>
diff --git a/app/views/oauth/applications/show.html.erb b/app/views/oauth/applications/show.html.erb
index 2f3a53a1e6d..bbe6cbc429d 100644
--- a/app/views/oauth/applications/show.html.erb
+++ b/app/views/oauth/applications/show.html.erb
@@ -49,85 +49,60 @@ See COPYRIGHT and LICENSE files for more details.
</li>
<% end %>
-<div class="attributes-group">
- <div class="attributes-group--header">
- <div class="attributes-group--header-container">
- <h3 class="attributes-group--header-text"><%= t(:label_details) %></h3>
- </div>
- </div>
-
- <div class="attributes-key-value">
- <div class="attributes-key-value--key"><%= @application.class.human_attribute_name :uid %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span><%= @application.uid %></span>
- </div>
- </div>
- <% if flash[:_application_secret] %>
- <div class="attributes-key-value--key"><%= @application.class.human_attribute_name :secret %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <p>
- <code><%= flash[:_application_secret] %></code>
- <br/>
- <strong><%= t 'oauth.client_secret_notice' %></strong>
- </p>
- </div>
- </div>
- <% end %>
- <% if user_id = @application.client_credentials_user_id %>
- <div class="attributes-key-value--key"><%= t 'oauth.client_credentials_impersonation_set_to' %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <p>
- <%= link_to_user User.find_by(id: user_id) %>
- <br/>
- <strong><%= t('oauth.client_credentials_impersonation_warning') %></strong>
- </p>
- </div>
- </div>
+<%= render(AttributeGroups::AttributeGroupComponent.new) do |component| %>
+ <% component.with_header(title: t(:label_details)) %>
+
+ <% component.with_attribute(
+ key: @application.class.human_attribute_name(:uid),
+ value: @application.uid
+ ) %>
+
+ <% if flash[:_application_secret] %>
+ <% component.with_attribute(
+ key: @application.class.human_attribute_name(:secret)
+ ) do %>
+ <p>
+ <code><%= flash[:_application_secret] %></code>
+ <br/>
+ <strong><%= t 'oauth.client_secret_notice' %></strong>
+ </p>
<% end %>
- <div class="attributes-key-value--key"><%= @application.class.human_attribute_name :scopes %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span><%= oauth_scope_translations(@application) %></span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= @application.class.human_attribute_name :confidential %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span>
- <%= @application.confidential? ? t(:general_text_Yes) : t(:general_text_No) %>
- </span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= @application.class.human_attribute_name :redirect_uri %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span>
- <%= safe_join @application.redirect_uri.split("\n"), '<br/>'.html_safe %>
- </span>
- </div>
- </div>
- <% if [email protected]_credentials_user_id %>
- <div class="attributes-key-value--key"><%= I18n.t(:'doorkeeper.auth_url') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span>
- <%= oauth_authorization_url %>
- </span>
- </div>
- </div>
+ <% end %>
+
+ <% if user_id = @application.client_credentials_user_id %>
+ <% component.with_attribute(
+ key: t('oauth.client_credentials_impersonation_set_to')
+ ) do %>
+ <%= link_to_user User.find_by(id: user_id) %>
+ <br/>
+ <strong><%= t('oauth.client_credentials_impersonation_warning') %></strong>
<% end %>
+ <% end %>
- <div class="attributes-key-value--key"><%= I18n.t(:'doorkeeper.access_token_url') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span>
- <%= oauth_token_url %>
- </span>
- </div>
- </div>
- </div>
-</div>
+ <% component.with_attribute(
+ key: @application.class.human_attribute_name(:scopes),
+ value: oauth_scope_translations(@application)
+ ) %>
+ <% component.with_attribute(
+ key: @application.class.human_attribute_name(:confidential),
+ value: @application.confidential? ? t(:general_text_Yes) : t(:general_text_No)
+ ) %>
+
+ <% component.with_attribute(
+ key: @application.class.human_attribute_name(:redirect_uri),
+ value: safe_join(@application.redirect_uri.split("\n"), '<br/>'.html_safe)
+ ) %>
+
+ <% if [email protected]_credentials_user_id %>
+ <% component.with_attribute(
+ key: I18n.t(:'doorkeeper.auth_url'),
+ value: oauth_authorization_url
+ ) %>
+ <% end %>
+
+ <% component.with_attribute(
+ key: I18n.t(:'doorkeeper.access_token_url'),
+ value: oauth_token_url
+ ) %>
+<% end %>
diff --git a/app/views/users/change_status_info.html.erb b/app/views/users/change_status_info.html.erb
index 50518050662..d790cb9f812 100644
--- a/app/views/users/change_status_info.html.erb
+++ b/app/views/users/change_status_info.html.erb
@@ -41,42 +41,23 @@ See COPYRIGHT and LICENSE files for more details.
<%= t('user.confirm_status_change', name: @user.name) %>
</p>
- <div class="attributes-key-value">
- <div class="attributes-key-value--key"><%= User.human_attribute_name :login %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -float">
- <span><%= @user.login %></span>
- </div>
- </div>
+ <%=
+ render(AttributeGroups::AttributeGroupComponent.new) do |component|
+ component.with_attribute(key: User.human_attribute_name(:login),
+ value: @user.login)
- <div class="attributes-key-value--key"><%= User.human_attribute_name :mail %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -float">
- <span><%= @user.mail %></span>
- </div>
- </div>
+ component.with_attribute(key: User.human_attribute_name(:mail),
+ value: @user.mail)
- <div class="attributes-key-value--key"><%= User.human_attribute_name :name %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -float">
- <span><%= @user.name %></span>
- </div>
- </div>
+ component.with_attribute(key: User.human_attribute_name(:name),
+ value: @user.name)
- <div class="attributes-key-value--key"><%= t(:label_current_status) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -float">
- <span class=""><%= full_user_status(@user, true) %></span>
- </div>
- </div>
+ component.with_attribute(key: t(:label_current_status),
+ value: full_user_status(@user, true))
- <div class="attributes-key-value--key"><strong><%= t(:status_change) %></strong></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -float">
- <strong><%= new_status %></strong>
- </div>
- </div>
- </div>
+ component.with_attribute(key: t(:status_change),
+ value: new_status)
+ end %>
</section>
<hr class="form--separator" />
diff --git a/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.component.sass b/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.component.sass
index 8f1df7192e8..17fd975cea8 100644
--- a/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.component.sass
+++ b/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.component.sass
@@ -1,25 +1,7 @@
@import "src/assets/sass/helpers"
.wp-attribute-group
- display: flex
- flex-direction: row
- flex-wrap: wrap
-
- // We want a margin between items, but don't know if any one item is on the right,
- // the left, or spanning both columns. The easy way to get a gutter is to give
- // *all* elements margins on both sides, and then negating this margin on the parent.
- // This also explains all of the + and - xrem calc() values below.
- margin: 0 -1 * $spot-spacing-1_5
- width: calc(100% + #{$spot-spacing-3})
-
&--attribute
- flex-basis: 400px
- flex-grow: 1
- flex-shrink: 1
- min-width: calc(50% - #{$spot-spacing-3})
- max-width: calc(100% - #{$spot-spacing-3})
- margin: 0 $spot-spacing-1_5
-
&_span-all
flex-basis: calc(100% - #{$spot-spacing-3})
flex-shrink: 0
diff --git a/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.component.ts b/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.component.ts
index 801ef406f46..3ea560fc501 100644
--- a/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.component.ts
@@ -50,6 +50,7 @@ import {
})
export class WorkPackageFormAttributeGroupComponent extends UntilDestroyedMixin {
@HostBinding('class.wp-attribute-group') className = true;
+ @HostBinding('class.attributes-group--attributes') parentClassName = true;
@Input() public workPackage:WorkPackageResource;
diff --git a/frontend/src/global_styles/content/_attributes_group.sass b/frontend/src/global_styles/content/_attributes_group.sass
index 255a4be2426..e4857e23fa8 100644
--- a/frontend/src/global_styles/content/_attributes_group.sass
+++ b/frontend/src/global_styles/content/_attributes_group.sass
@@ -30,7 +30,6 @@
margin-top: 1.6875rem
position: relative
-
.attributes-group--header
@include grid-block
margin: 0 0 0.5rem 0
@@ -78,3 +77,16 @@
margin: 0
padding: 0
border: 0
+
+.attributes-group--attributes
+ display: flex
+ flex-direction: row
+ flex-wrap: wrap
+
+ // We want a margin between items, but don't know if any one item is on the right,
+ // the left, or spanning both columns. The easy way to get a gutter is to give
+ // *all* elements margins on both sides, and then negating this margin on the parent.
+ // This also explains all of the + and - xrem calc() values below.
+ margin: 0 -1 * $spot-spacing-1_5
+ width: calc(100% + #{$spot-spacing-3})
+
diff --git a/frontend/src/global_styles/content/_attributes_key_value.sass b/frontend/src/global_styles/content/_attributes_key_value.sass
index abab2964ca7..f3a0e6bd032 100644
--- a/frontend/src/global_styles/content/_attributes_key_value.sass
+++ b/frontend/src/global_styles/content/_attributes_key_value.sass
@@ -31,6 +31,14 @@
// flex-wrap: wrap
font-size: 0.875rem
margin-bottom: 0.1875rem
+ flex-basis: 400px
+ flex-grow: 1
+ flex-shrink: 1
+ min-width: calc(50% - 3rem)
+ max-width: calc(100% - 3rem)
+ margin: 0 1.5rem
+ line-height: 1.5em
+ gap: 10px
&--key
@extend .form--label
@@ -55,7 +63,6 @@
flex-basis: 260px
flex-grow: 1000000
flex-shrink: 1
- align-self: center
margin-bottom: 0.1875rem
padding: 0.375rem 0
height: 100%
@@ -69,6 +76,7 @@
&--value
@include grid-visible-overflow
+ word-wrap: anywhere
@at-root &.wp-attribute-group--attribute_span-all &--value-container
flex-shrink: 0
diff --git a/modules/budgets/app/views/budgets/show.html.erb b/modules/budgets/app/views/budgets/show.html.erb
index 1c835a2848e..87c3fc695e7 100644
--- a/modules/budgets/app/views/budgets/show.html.erb
+++ b/modules/budgets/app/views/budgets/show.html.erb
@@ -62,42 +62,16 @@ See COPYRIGHT and LICENSE files for more details.
<%= t(:label_updated_time, value: distance_of_time_in_words(Time.now, @budget.updated_at)) + '.' if @budget.created_at != @budget.updated_at %>
</p>
- <div class="attributes-group">
- <div class="attributes-key-value">
- <div class="attributes-key-value--key"><%= Budget.human_attribute_name(:type) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span><%= @budget.type_label %></span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= Budget.human_attribute_name(:fixed_date) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span><%= format_date(@budget.fixed_date) %></span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= Budget.human_attribute_name(:budget_ratio) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span>
- <%= extended_progress_bar(@budget.budget_ratio,
- :width => '80px',
- :legend => @budget.budget_ratio) %>
- </span>
- </div>
- </div>
- <% unless format_text(@budget, :description, :attachments => @budget.attachments).empty? %>
- <div class="attributes-key-value--key"><%= Budget.human_attribute_name(:description) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <div class="op-uc-container">
- <%= format_text @budget, :description, :attachments => @budget.attachments %>
- </div>
- </div>
- </div>
- <% end %>
- </div>
- </div>
+ <%= render(AttributeGroups::AttributeGroupComponent.new) do |component|
+ component.with_attribute(key: Budget.human_attribute_name(:type), value: @budget.type_label)
+ component.with_attribute(key: Budget.human_attribute_name(:fixed_date), value: format_date(@budget.fixed_date))
+ component.with_attribute(key: Budget.human_attribute_name(:budget_ratio),
+ value: extended_progress_bar(@budget.budget_ratio, :width => '80px', :legend => @budget.budget_ratio))
+ component.with_attribute(key: Budget.human_attribute_name(:description),
+ value: content_tag(:div, class: "op-uc-container") do
+ format_text @budget, :description, :attachments => @budget.attachments
+ end)
+ end %>
<% resource = budget_attachment_representer(@budget) %>
<%= list_attachments(resource) %>
diff --git a/modules/ldap_groups/app/views/ldap_groups/synchronized_filters/show.html.erb b/modules/ldap_groups/app/views/ldap_groups/synchronized_filters/show.html.erb
index 8502e55d4de..21f6f7c89b5 100644
--- a/modules/ldap_groups/app/views/ldap_groups/synchronized_filters/show.html.erb
+++ b/modules/ldap_groups/app/views/ldap_groups/synchronized_filters/show.html.erb
@@ -20,48 +20,24 @@
<% end %>
<section class="admin--edit-section">
- <div class="attributes-key-value">
- <div class="attributes-key-value--key"><%= @filter.class.human_attribute_name(:name) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <span><%= @filter.name %></span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= @filter.class.human_attribute_name(:group_name_attribute) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <span><%= @filter.group_name_attribute %></span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= @filter.class.human_attribute_name(:base_dn) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <%= @filter.used_base_dn %>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= @filter.class.human_attribute_name(:sync_users) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <% if @filter.sync_users %>
- <%= checked_image @filter.sync_users %>
- <% else %>
- <%= t(:general_text_no) %>
- <% end %>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= @filter.class.human_attribute_name(:filter_string) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <code><%= @filter.filter_string %></code>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= t('ldap_groups.synchronized_groups.plural') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <%= @filter.groups.count %>
- </div>
- </div>
- </div>
+ <%= render(AttributeGroups::AttributeGroupComponent.new) do |component|
+ component.with_attribute(key: @filter.class.human_attribute_name(:name),
+ value: @filter.name)
+ component.with_attribute(key: @filter.class.human_attribute_name(:group_name_attribute),
+ value: @filter.group_name_attribute)
+ component.with_attribute(key: @filter.class.human_attribute_name(:base_dn),
+ value: @filter.used_base_dn)
+ component.with_attribute(key: @filter.class.human_attribute_name(:sync_users),
+ value: if @filter.sync_users
+ checked_image @filter.sync_users
+ else
+ t(:general_text_no)
+ end)
+ component.with_attribute(key: @filter.class.human_attribute_name(:filter_string),
+ value: @filter.filter_string)
+ component.with_attribute(key: t('ldap_groups.synchronized_groups.plural'),
+ value: @filter.groups.count)
+ end %>
</section>
<section class="admin--edit-section">
diff --git a/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/show.html.erb b/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/show.html.erb
index d45c93202da..48e0303cb5e 100644
--- a/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/show.html.erb
+++ b/modules/ldap_groups/app/views/ldap_groups/synchronized_groups/show.html.erb
@@ -4,36 +4,20 @@
<%= breadcrumb_toolbar(link_to(t('ldap_groups.synchronized_groups.plural'), { action: :index }), h(@group.dn)) %>
<section class="admin--edit-section">
- <div class="attributes-key-value">
- <div class="attributes-key-value--key"><%= @group.class.human_attribute_name('dn') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <span><%= @group.dn %></span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= @group.class.human_attribute_name(:sync_users) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <% if @group.sync_users %>
- <%= checked_image @group.sync_users %>
- <% else %>
- <%= t(:general_text_no) %>
- <% end %>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= @group.class.human_attribute_name('auth_source') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <%= link_to @group.auth_source.name, edit_ldap_auth_source_path(@group.auth_source) %>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= t(:label_group) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <%= link_to @group.group, edit_group_path(@group.group) %>
- </div>
- </div>
- </div>
+ <%=
+ render(AttributeGroups::AttributeGroupComponent.new) do |component|
+ component.with_attribute(key: @group.class.human_attribute_name(:dn),
+ value: @group.dn)
+
+ component.with_attribute(key: @group.class.human_attribute_name(:sync_users),
+ value: @group.sync_users ? checked_image(@group.sync_users) : t(:general_text_no))
+
+ component.with_attribute(key: @group.class.human_attribute_name(:auth_source),
+ value: link_to(@group.auth_source.name, edit_ldap_auth_source_path(@group.auth_source)))
+
+ component.with_attribute(key: @group.class.human_attribute_name(:group),
+ value: link_to(@group.group, edit_group_path(@group.group)))
+ end %>
</section>
<section class="admin--edit-section">
diff --git a/modules/two_factor_authentication/app/views/two_factor_authentication/settings.html.erb b/modules/two_factor_authentication/app/views/two_factor_authentication/settings.html.erb
index 77ee8915122..5be3c921bfa 100644
--- a/modules/two_factor_authentication/app/views/two_factor_authentication/settings.html.erb
+++ b/modules/two_factor_authentication/app/views/two_factor_authentication/settings.html.erb
@@ -15,36 +15,28 @@
configuration_link[:href],
target: '_blank' %>
</p>
- <div class="attributes-key-value">
- <div class="attributes-key-value--key"><%= t('two_factor_authentication.settings.label_active_strategies') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <%= t(:label_none) if configuration['active_strategies'].empty? %>
- <% configuration['active_strategies'].each do |key| %>
- <span>
- <%= t("two_factor_authentication.strategies.#{key}") %>
- </span>
- <br/>
- <% end %>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= t('two_factor_authentication.settings.label_enforced') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <span><%= !!configuration['enforced'] %></span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= t('two_factor_authentication.settings.label_remember') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <% if configuration['allow_remember_for_days'].to_i == 0 %>
- <span><%= t(:label_disabled) %></span>
- <% else %>
- <span><%= configuration['allow_remember_for_days'] %> (<%= t(:label_day_plural) %>)</span>
- <% end %>
- </div>
- </div>
- </div>
+ <%= render(AttributeGroups::AttributeGroupComponent.new) do |component|
+ component.with_attribute(key: t('two_factor_authentication.settings.label_active_strategies'),
+ value: if configuration['active_strategies'].empty?
+ t(:label_none)
+ else
+ configuration['active_strategies'].join(content_tag(:br)) do |key|
+ content_tag(:span) do
+ t("two_factor_authentication.strategies.#{key}")
+ end
+ end
+ end)
+
+ component.with_attribute(key: t('two_factor_authentication.settings.label_enforced'),
+ value: !!configuration['enforced'])
+
+ component.with_attribute(key: t('two_factor_authentication.settings.label_remember'),
+ value: if configuration['allow_remember_for_days'].to_i == 0
+ t(:label_disabled)
+ else
+ "#{configuration['allow_remember_for_days']} (#{t(:label_day_plural)})"
+ end)
+ end %>
</fieldset>
<fieldset class="form--fieldset">
<legend class="form--fieldset-legend"><%= t(:label_setting_plural) %></legend>
diff --git a/modules/two_factor_authentication/app/views/two_factor_authentication/two_factor_devices/totp/_form.html.erb b/modules/two_factor_authentication/app/views/two_factor_authentication/two_factor_devices/totp/_form.html.erb
index 3aaaab27318..3553ef4f46f 100644
--- a/modules/two_factor_authentication/app/views/two_factor_authentication/two_factor_devices/totp/_form.html.erb
+++ b/modules/two_factor_authentication/app/views/two_factor_authentication/two_factor_devices/totp/_form.html.erb
@@ -28,31 +28,11 @@
<br/>
<%= t('two_factor_authentication.devices.totp.text_cannot_scan') %>
</p>
- <div class="attributes-key-value">
- <div class="attributes-key-value--key"><%= t('two_factor_authentication.devices.totp.account') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <span><%= device.account_name %></span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= t('two_factor_authentication.devices.totp.secret_key') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <span><%= device.otp_secret %></span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= t('two_factor_authentication.devices.totp.time_based') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <span><%= t('general_text_Yes') %></span>
- </div>
- </div>
- <div class="attributes-key-value--key"><%= t('two_factor_authentication.devices.totp.provisioning_uri') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <span><%= device.provisioning_url %></span>
- </div>
- </div>
- </div>
+ <%= render(AttributeGroups::AttributeGroupComponent.new) do |component|
+ component.with_attribute(key: t('two_factor_authentication.devices.totp.account'), value: device.account_name)
+ component.with_attribute(key: t('two_factor_authentication.devices.totp.secret_key'), value: device.otp_secret)
+ component.with_attribute(key: t('two_factor_authentication.devices.totp.time_based'), value: t('general_text_Yes'))
+ component.with_attribute(key: t('two_factor_authentication.devices.totp.provisioning_uri'), value: device.provisioning_url)
+ end %>
</div>
</div>
diff --git a/modules/two_factor_authentication/app/views/users/_two_factor_authentication_admin.html.erb b/modules/two_factor_authentication/app/views/users/_two_factor_authentication_admin.html.erb
index 01b46eff98d..306cbc83762 100644
--- a/modules/two_factor_authentication/app/views/users/_two_factor_authentication_admin.html.erb
+++ b/modules/two_factor_authentication/app/views/users/_two_factor_authentication_admin.html.erb
@@ -13,22 +13,14 @@
<section class="admin--edit-section">
<% if default_device.present? %>
- <div class="attributes-key-value">
- <div class="attributes-key-value--key"><%= t('two_factor_authentication.label_default_device') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <span><%= default_device.identifier %></span>
- </div>
- </div>
- <% if default_device.phone_number.present? %>
- <div class="attributes-key-value--key"><%= ::TwoFactorAuthentication::Device::Sms.human_attribute_name(:phone_number) %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value">
- <span><%= default_device.phone_number %></span>
- </div>
- </div>
- <% end %>
- </div>
+ <%= render(AttributeGroups::AttributeGroupComponent.new) do |component|
+ component.with_attribute(key: t('two_factor_authentication.label_default_device'),
+ value: default_device.identifier)
+ if default_device.phone_number.present?
+ component.with_attribute(key: ::TwoFactorAuthentication::Device::Sms.human_attribute_name(:phone_number),
+ value: default_device.phone_number)
+ end
+ end %>
<% end %>
</section>
diff --git a/modules/webhooks/app/views/webhooks/outgoing/admin/show.html.erb b/modules/webhooks/app/views/webhooks/outgoing/admin/show.html.erb
index 58b1e800278..09321acd14e 100644
--- a/modules/webhooks/app/views/webhooks/outgoing/admin/show.html.erb
+++ b/modules/webhooks/app/views/webhooks/outgoing/admin/show.html.erb
@@ -34,40 +34,21 @@
}) %>
<div class="account--section">
- <div class="attributes-group">
- <div class="attributes-key-value">
-
- <div class="attributes-key-value--key"><%= ::Webhooks::Webhook.human_attribute_name('events') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span><%= @webhook.event_names.join(', ') %></span>
- </div>
- </div>
-
- <div class="attributes-key-value--key"><%= ::Webhooks::Webhook.human_attribute_name('projects') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span>
- <% if @webhook.all_projects? %>
- (<%= t(:label_all) %>)
- <% else %>
- <%= @webhook.projects.join(', ') %>
- <% end %>
- </span>
- </div>
- </div>
-
- <div class="attributes-key-value--key"><%= ::Webhooks::Webhook.human_attribute_name('description') %></div>
- <div class="attributes-key-value--value-container">
- <div class="attributes-key-value--value -text">
- <span><%= @webhook.description %></span>
- </div>
- </div>
- </div>
- </div>
+ <%= render(AttributeGroups::AttributeGroupComponent.new) do |component|
+ component.with_attribute(key: ::Webhooks::Webhook.human_attribute_name('events'),
+ value: @webhook.event_names.join(', '))
+ component.with_attribute(key: ::Webhooks::Webhook.human_attribute_name('events'),
+ value: if @webhook.all_projects?
+ (t(:label_all))
+ else
+ @webhook.projects.join(', ')
+ end)
+ component.with_attribute(key: ::Webhooks::Webhook.human_attribute_name('description'),
+ value: @webhook.description)
+ end %>
</div>
<div class="account--section">
<h2><%= t 'webhooks.outgoing.deliveries.title' %></h2>
<%= render ::Webhooks::Outgoing::Deliveries::TableComponent.new(rows: @webhook.deliveries.newest) %>
-</div>
\ No newline at end of file
+</div>
diff --git a/spec/components/attribute_groups/attribute_key_value_component_spec.rb b/spec/components/attribute_groups/attribute_key_value_component_spec.rb
index ef630bebccf..239cfec1c62 100644
--- a/spec/components/attribute_groups/attribute_key_value_component_spec.rb
+++ b/spec/components/attribute_groups/attribute_key_value_component_spec.rb
@@ -37,4 +37,27 @@ RSpec.describe AttributeGroups::AttributeKeyValueComponent, type: :component do
expect(page).to have_css('.attributes-key-value--key', text: 'Attribute Key') &
have_css('.attributes-key-value--value.-text', text: 'Attribute Value')
end
+
+ context 'with value and content' do
+ it 'renders the content' do
+ render_inline(described_class.new(key: 'Attribute Key', value: 'Attribute Value')) do
+ "<p class='test--content'>Content Value</p>"
+ end
+
+ expect(page).to have_css('.attributes-key-value--key', text: 'Attribute Key') &
+ have_css('.attributes-key-value--value.-text', text: 'Attribute Value') &
+ have_css('.attributes-key-value--value.-text', text: "<p class='test--content'>Content Value</p>")
+ end
+ end
+
+ context 'with content, no value' do
+ it 'renders the content' do
+ render_inline(described_class.new(key: 'Attribute Key')) do
+ "<p class='test--content'>Content Value</p>"
+ end
+
+ expect(page).to have_css('.attributes-key-value--key', text: 'Attribute Key') &
+ have_css('.attributes-key-value--value.-text', text: "<p class='test--content'>Content Value</p>")
+ end
+ end
end