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

Remove including helpers in ViewComponents, use the #helpers method instead (#12709)

Dombi Attila804462f00c87
diff --git a/app/components/components/on_off_status_component.html.erb b/app/components/components/on_off_status_component.html.erb
index 085b2dd60cb..45fccd6b7a2 100644
--- a/app/components/components/on_off_status_component.html.erb
+++ b/app/components/components/on_off_status_component.html.erb
@@ -32,7 +32,7 @@ See COPYRIGHT and LICENSE files for more details.
<div class="on-off-status-cell">
<% if enabled? %>
<span class="on-off-status -enabled">
- <%= op_icon 'icon-yes' %>
+ <%= helpers.op_icon 'icon-yes' %>
<%= model[:on_text] %>
</span>
<p>
@@ -40,7 +40,7 @@ See COPYRIGHT and LICENSE files for more details.
</p>
<% else %>
<span class="on-off-status -disabled">
- <%= op_icon 'icon-not-supported' %>
+ <%= helpers.op_icon 'icon-not-supported' %>
<%= model[:off_text] %>
</span>
<p><%= model[:off_description] %></p>
diff --git a/app/components/individual_principal_base_filter_component.rb b/app/components/individual_principal_base_filter_component.rb
index 0e8de2a9807..559e8e3c029 100644
--- a/app/components/individual_principal_base_filter_component.rb
+++ b/app/components/individual_principal_base_filter_component.rb
@@ -29,9 +29,6 @@
#++
class IndividualPrincipalBaseFilterComponent < RailsComponent
- include UsersHelper
- include ActionView::Helpers::FormOptionsHelper
-
class << self
def query(params)
q = base_query.new
diff --git a/app/components/members/role_form_component.rb b/app/components/members/role_form_component.rb
index 7be33016185..81d63245359 100644
--- a/app/components/members/role_form_component.rb
+++ b/app/components/members/role_form_component.rb
@@ -30,8 +30,6 @@
module Members
class RoleFormComponent < ::RailsComponent
- include RemovedJsHelpersHelper
-
options :row, :params, :roles
def member
diff --git a/app/components/members/row_component.rb b/app/components/members/row_component.rb
index ea6c6f45773..18f40888c09 100644
--- a/app/components/members/row_component.rb
+++ b/app/components/members/row_component.rb
@@ -30,9 +30,6 @@
module Members
class RowComponent < ::RowComponent
- include AvatarHelper
- include UsersHelper
-
property :principal
def member
@@ -48,7 +45,7 @@ module Members
end
def name
- icon = avatar principal, size: :mini
+ icon = helpers.avatar principal, size: :mini
icon + principal_link
end
@@ -105,7 +102,7 @@ module Members
end
def status
- translate_user_status(model.principal.status)
+ helpers.translate_user_status(model.principal.status)
end
def may_update?
@@ -128,7 +125,7 @@ module Members
def edit_link
link_to(
- op_icon('icon icon-edit'),
+ helpers.op_icon('icon icon-edit'),
'#',
class: "toggle-membership-button #{toggle_item_class_name}",
'data-action': 'members-form#toggleMembershipEdit',
@@ -148,7 +145,7 @@ module Members
def delete_link
if model.deletable?
link_to(
- op_icon('icon icon-delete'),
+ helpers.op_icon('icon icon-delete'),
{ controller: '/members', action: 'destroy', id: model, page: params[:page] },
method: :delete,
data: { confirm: delete_link_confirmation, disable_with: I18n.t(:label_loading) },
diff --git a/app/components/oauth/applications/row_component.rb b/app/components/oauth/applications/row_component.rb
index 219120e7760..68285e00a7f 100644
--- a/app/components/oauth/applications/row_component.rb
+++ b/app/components/oauth/applications/row_component.rb
@@ -31,9 +31,6 @@
module OAuth
module Applications
class RowComponent < ::RowComponent
- include ::IconsHelper
- include ::OAuthHelper
- include ::OpenProject::ObjectLinking
property :confidential
@@ -51,7 +48,7 @@ module OAuth
def confidential
if application.confidential?
- op_icon 'icon icon-checkmark'
+ helpers.op_icon 'icon icon-checkmark'
end
end
@@ -77,7 +74,7 @@ module OAuth
end
def button_links
- [edit_link, delete_link(oauth_application_path(application))]
+ [edit_link, helpers.delete_link(oauth_application_path(application))]
end
end
end
diff --git a/app/components/oauth/applications/table_component.rb b/app/components/oauth/applications/table_component.rb
index 3c26d7f2d4e..e30b5668942 100644
--- a/app/components/oauth/applications/table_component.rb
+++ b/app/components/oauth/applications/table_component.rb
@@ -54,7 +54,7 @@ module OAuth
aria: { label: t('oauth.application.new') },
class: 'wp-inline-create--add-link',
title: t('oauth.application.new') do
- op_icon('icon icon-add')
+ helpers.op_icon('icon icon-add')
end
end
diff --git a/app/components/placeholder_users/row_component.rb b/app/components/placeholder_users/row_component.rb
index 969bc2d6e08..f752ca2a408 100644
--- a/app/components/placeholder_users/row_component.rb
+++ b/app/components/placeholder_users/row_component.rb
@@ -28,11 +28,6 @@
module PlaceholderUsers
class RowComponent < ::RowComponent
- include AvatarHelper
- include UsersHelper
- include PlaceholderUsersHelper
- include TooltipHelper
-
def placeholder_user
model
end
@@ -42,7 +37,7 @@ module PlaceholderUsers
end
def created_at
- format_time placeholder_user.created_at
+ helpers.format_time placeholder_user.created_at
end
def button_links
@@ -50,12 +45,12 @@ module PlaceholderUsers
end
def delete_link
- if can_delete_placeholder_user?(placeholder_user, User.current)
+ if helpers.can_delete_placeholder_user?(placeholder_user, User.current)
link_to deletion_info_placeholder_user_path(placeholder_user) do
- tooltip_tag I18n.t('placeholder_users.delete_tooltip'), icon: 'icon-delete'
+ helpers.tooltip_tag I18n.t('placeholder_users.delete_tooltip'), icon: 'icon-delete'
end
else
- tooltip_tag I18n.t('placeholder_users.right_to_manage_members_missing'), icon: 'icon-help2'
+ helpers.tooltip_tag I18n.t('placeholder_users.right_to_manage_members_missing'), icon: 'icon-help2'
end
end
diff --git a/app/components/projects/row_component.html.erb b/app/components/projects/row_component.html.erb
index 9ea66e45be2..e20e6e7ddca 100644
--- a/app/components/projects/row_component.html.erb
+++ b/app/components/projects/row_component.html.erb
@@ -37,7 +37,7 @@ See COPYRIGHT and LICENSE files for more details.
</td>
<% end %>
<td class="buttons">
- <% items = project_more_menu_items(project) %>
+ <% items = helpers.project_more_menu_items(project) %>
<% if items.any? %>
<ul class="project-actions">
<li aria-haspopup="true" title="<%= I18n.t(:label_open_menu) %>" class="drop-down">
@@ -63,7 +63,7 @@ See COPYRIGHT and LICENSE files for more details.
<td></td>
<td colspan="<%= columns.length%>" class="project--hierarchy">
<div class="description-container wiki">
- <%= format_text(short_project_description(project), project: project) %>
+ <%= helpers.format_text(short_project_description(project), project: project) %>
</div>
</td>
</tr>
diff --git a/app/components/projects/row_component.rb b/app/components/projects/row_component.rb
index fc51ff72d1e..9f2fdaf1d90 100644
--- a/app/components/projects/row_component.rb
+++ b/app/components/projects/row_component.rb
@@ -30,10 +30,6 @@
module Projects
class RowComponent < ::RowComponent
- include ProjectsHelper
- include ProjectStatusHelper
- include ::Redmine::I18n
-
def project
model.first
end
@@ -69,11 +65,11 @@ module Projects
end
def created_at
- format_date(project.created_at)
+ helpers.format_date(project.created_at)
end
def latest_activity_at
- format_date(project.latest_activity_at)
+ helpers.format_date(project.latest_activity_at)
end
def required_disk_space
@@ -91,7 +87,7 @@ module Projects
end
content << ' '
- content << link_to_project(project, {}, {}, false)
+ content << helpers.link_to_project(project, {}, {}, false)
content
end
@@ -101,9 +97,9 @@ module Projects
status_code = project.status_code
if status_code
- classes = project_status_css_class(status_code)
+ classes = helpers.project_status_css_class(status_code)
content << content_tag(:span, '', class: "project-status--bulb -inline #{classes}")
- content << content_tag(:span, project_status_name(status_code), class: "project-status--name #{classes}")
+ content << content_tag(:span, helpers.project_status_name(status_code), class: "project-status--name #{classes}")
end
content
@@ -111,12 +107,12 @@ module Projects
def status_explanation
if project.status_explanation
- content_tag :div, format_text(project.status_explanation), class: 'wiki'
+ content_tag :div, helpers.format_text(project.status_explanation), class: 'wiki'
end
end
def public
- checked_image project.public?
+ helpers.checked_image project.public?
end
def row_css_class
diff --git a/app/components/projects/table_component.html.erb b/app/components/projects/table_component.html.erb
index c65dee4e690..328add258e9 100644
--- a/app/components/projects/table_component.html.erb
+++ b/app/components/projects/table_component.html.erb
@@ -45,7 +45,7 @@ See COPYRIGHT and LICENSE files for more details.
<div class="generic-table--sort-header-outer generic-table--sort-header-outer_no-highlighting">
<div class="generic-table--sort-header">
<%= content_tag :a,
- op_icon("icon-hierarchy"),
+ helpers.op_icon("icon-hierarchy"),
href: href_only_when_not_sort_lft,
class: "spot-link #{deactivate_class_on_lft_sort}",
title: t(:label_sort_by, value: %("#{t(:label_project_hierarchy)}")) %>
@@ -70,9 +70,9 @@ See COPYRIGHT and LICENSE files for more details.
<div class="generic-table--header-outer">
<div class="generic-table--header">
<% if params[:expand] == 'all' %>
- <%= link_to t(:button_collapse_all), { params: safe_query_params(%w{filters page per_page sortBy}).except(:expand) } %>
+ <%= link_to t(:button_collapse_all), { params: helpers.safe_query_params(%w{filters page per_page sortBy}).except(:expand) } %>
<% else %>
- <%= link_to t(:button_expand_all), { params: safe_query_params(%w{filters page per_page sortBy}).merge(expand: 'all') } %>
+ <%= link_to t(:button_expand_all), { params: helpers.safe_query_params(%w{filters page per_page sortBy}).merge(expand: 'all') } %>
<% end %>
</div>
</div>
@@ -96,6 +96,6 @@ See COPYRIGHT and LICENSE files for more details.
</div>
</div>
<% if paginated? %>
- <%= pagination_links_full model %>
+ <%= helpers.pagination_links_full model %>
<% end %>
</div>
diff --git a/app/components/projects/table_component.rb b/app/components/projects/table_component.rb
index 72d681f4104..8558b3144a7 100644
--- a/app/components/projects/table_component.rb
+++ b/app/components/projects/table_component.rb
@@ -30,8 +30,6 @@
module Projects
class TableComponent < ::TableComponent
- include ProjectsHelper
-
options :params # We read collapsed state from params
options :current_user # adds this option to those of the base class
@@ -46,21 +44,24 @@ module Projects
##
# The project sort by is handled differently
def build_sort_header(column, options)
- projects_sort_header_tag(column, options.merge(param: :json))
+ helpers.projects_sort_header_tag(column, options.merge(param: :json))
end
# We don't return the project row
# but the [project, level] array from the helper
def rows
- @rows ||= to_enum(:projects_with_levels_order_sensitive, model).to_a # rubocop:disable Lint/ToEnumArguments
+ @rows ||= begin
+ projects_enumerator = ->(model) { to_enum(:projects_with_levels_order_sensitive, model).to_a } # rubocop:disable Lint/ToEnumArguments
+ helpers.instance_exec(model, &projects_enumerator)
+ end
end
def initialize_sorted_model
- sort_clear
+ helpers.sort_clear
orders = options[:orders]
- sort_init orders
- sort_update orders.map(&:first)
+ helpers.sort_init orders
+ helpers.sort_update orders.map(&:first)
end
def paginated?
@@ -68,13 +69,13 @@ module Projects
end
def deactivate_class_on_lft_sort
- if sorted_by_lft?
+ if helpers.sorted_by_lft?
'spot-link_inactive'
end
end
def href_only_when_not_sort_lft
- unless sorted_by_lft?
+ unless helpers.sorted_by_lft?
projects_path(sortBy: JSON::dump([['lft', 'asc']]))
end
end
diff --git a/app/components/rails_component.rb b/app/components/rails_component.rb
index 22238f91922..fe49cecf32e 100644
--- a/app/components/rails_component.rb
+++ b/app/components/rails_component.rb
@@ -29,8 +29,6 @@
#++
class RailsComponent < ViewComponent::Base
- include ApplicationHelper
-
attr_reader :model, :options
def initialize(model = nil, **options)
diff --git a/app/components/settings/numeric_setting_component.html.erb b/app/components/settings/numeric_setting_component.html.erb
index 4e9297d6ca5..298953dc676 100644
--- a/app/components/settings/numeric_setting_component.html.erb
+++ b/app/components/settings/numeric_setting_component.html.erb
@@ -29,7 +29,7 @@ See COPYRIGHT and LICENSE files for more details.
<div class="form--field">
<%=
- setting_text_field(
+ helpers.setting_text_field(
name,
size: size,
unit: t("label_#{unit.singularize}_plural"),
diff --git a/app/components/settings/numeric_setting_component.rb b/app/components/settings/numeric_setting_component.rb
index e7bb7a27f07..4658e00012f 100644
--- a/app/components/settings/numeric_setting_component.rb
+++ b/app/components/settings/numeric_setting_component.rb
@@ -32,8 +32,6 @@ module Settings
##
# A text field to enter numeric values.
class NumericSettingComponent < ::RailsComponent
- include SettingsHelper
-
options :unit, :title
options size: 3
diff --git a/app/components/settings/text_setting_component.html.erb b/app/components/settings/text_setting_component.html.erb
index e615c88f6de..4347267e48e 100644
--- a/app/components/settings/text_setting_component.html.erb
+++ b/app/components/settings/text_setting_component.html.erb
@@ -36,7 +36,7 @@ See COPYRIGHT and LICENSE files for more details.
<%=
styled_select_tag(
"lang",
- options_for_select(lang_options_for_select(false), current_language.to_s),
+ options_for_select(helpers.lang_options_for_select(false), current_language.to_s),
id: "lang-for-#{name}",
class: "lang-select-switch",
container_class: '-slim'
diff --git a/app/components/settings/text_setting_component.rb b/app/components/settings/text_setting_component.rb
index b87c9c4daa7..a49c3723b4e 100644
--- a/app/components/settings/text_setting_component.rb
+++ b/app/components/settings/text_setting_component.rb
@@ -32,10 +32,7 @@ module Settings
##
# A language switch and text area for updating a localized text setting.
class TextSettingComponent < ::RailsComponent
- include ActionView::Helpers::JavaScriptHelper
- include ActionView::Helpers::FormOptionsHelper
include OpenProject::FormTagHelper
- include TextFormattingHelper
options :name # name of setting and tag to differentiate between different language selects
diff --git a/app/components/settings/time_zone_setting_component.rb b/app/components/settings/time_zone_setting_component.rb
index 40aeb90fedd..906d2139a16 100644
--- a/app/components/settings/time_zone_setting_component.rb
+++ b/app/components/settings/time_zone_setting_component.rb
@@ -32,9 +32,6 @@ module Settings
##
# A text field to enter numeric values.
class TimeZoneSettingComponent < ::RailsComponent
- include ActionView::Helpers::FormOptionsHelper
- include SettingsHelper
-
options :form, :title
options container_class: "-wide"
options include_blank: true
@@ -63,7 +60,7 @@ module Settings
end
def render_setting_select
- setting_select(
+ helpers.setting_select(
name,
time_zone_entries,
include_blank:,
diff --git a/app/components/statuses/row_component.rb b/app/components/statuses/row_component.rb
index 21a6963d825..647132d42d0 100644
--- a/app/components/statuses/row_component.rb
+++ b/app/components/statuses/row_component.rb
@@ -30,10 +30,6 @@
module Statuses
class RowComponent < ::RowComponent
- include ::IconsHelper
- include ::ColorsHelper
- include ReorderLinksHelper
-
def status
model
end
@@ -76,7 +72,7 @@ module Statuses
def delete_link
link_to(
- op_icon('icon icon-delete'),
+ helpers.op_icon('icon icon-delete'),
status_path(status),
method: :delete,
data: { confirm: I18n.t(:text_are_you_sure) },
diff --git a/app/components/statuses/table_component.rb b/app/components/statuses/table_component.rb
index 013e86cb422..199562a50c0 100644
--- a/app/components/statuses/table_component.rb
+++ b/app/components/statuses/table_component.rb
@@ -47,7 +47,7 @@ module Statuses
aria: { label: t(:label_work_package_status_new) },
class: 'wp-inline-create--add-link',
title: t(:label_work_package_status_new) do
- op_icon('icon icon-add')
+ helpers.op_icon('icon icon-add')
end
end
diff --git a/app/components/table_component.html.erb b/app/components/table_component.html.erb
index 8a26cb3b25d..ebaf4f905a2 100644
--- a/app/components/table_component.html.erb
+++ b/app/components/table_component.html.erb
@@ -40,7 +40,7 @@ See COPYRIGHT and LICENSE files for more details.
<tr>
<% headers.each do |name, options| %>
<% if sortable_column?(name) %>
- <%= sort_header_tag name, options %>
+ <%= helpers.sort_header_tag name, options %>
<% else %>
<th>
<div class="generic-table--sort-header-outer">
@@ -76,5 +76,5 @@ See COPYRIGHT and LICENSE files for more details.
</div>
</div>
<% if paginated? %>
- <%= pagination_links_full rows %>
+ <%= helpers.pagination_links_full rows %>
<% end %>
diff --git a/app/components/table_component.rb b/app/components/table_component.rb
index 8746edfe2db..3f0cc4392cb 100644
--- a/app/components/table_component.rb
+++ b/app/components/table_component.rb
@@ -31,9 +31,6 @@
##
# Abstract view component. Subclass this for a concrete table.
class TableComponent < RailsComponent
- include SortHelper
- include PaginationHelper
-
def initialize(rows: [], **options)
super(rows, **options)
end
@@ -94,18 +91,22 @@ class TableComponent < RailsComponent
end
def initialize_sorted_model
- sort_init *initial_sort.map(&:to_s)
- sort_update sortable_columns.map(&:to_s)
+ helpers.sort_init *initial_sort.map(&:to_s)
+ helpers.sort_update sortable_columns.map(&:to_s)
@model = paginate_collection apply_sort(model)
end
+ def sort_criteria
+ helpers.instance_variable_get(:@sort_criteria)
+ end
+
def apply_sort(model)
case model
when ActiveRecord::QueryMethods
- sort_collection(model, sort_clause)
+ sort_collection(model, helpers.sort_clause)
when Queries::BaseQuery
model
- .order(@sort_criteria.to_query_hash)
+ .order(sort_criteria.to_query_hash)
.results
else
raise ArgumentError, "Cannot sort the given model class #{model.class}"
@@ -125,8 +126,8 @@ class TableComponent < RailsComponent
def paginate_collection(query)
query
- .page(page_param(controller.params))
- .per_page(per_page_param)
+ .page(helpers.page_param(controller.params))
+ .per_page(helpers.per_page_param)
end
def rows
diff --git a/app/components/user_filter_component.rb b/app/components/user_filter_component.rb
index ad1b06cb400..eaac406b921 100644
--- a/app/components/user_filter_component.rb
+++ b/app/components/user_filter_component.rb
@@ -73,7 +73,7 @@ class UserFilterComponent < IndividualPrincipalBaseFilterComponent
end
def user_status_options
- users_status_options_for_select status, extra: extra_user_status_options
+ helpers.users_status_options_for_select status, extra: extra_user_status_options
end
def extra_user_status_options
diff --git a/app/components/users/row_component.rb b/app/components/users/row_component.rb
index 1d155756bbf..c9974723345 100644
--- a/app/components/users/row_component.rb
+++ b/app/components/users/row_component.rb
@@ -30,9 +30,6 @@
module Users
class RowComponent < ::RowComponent
- include AvatarHelper
- include UsersHelper
-
property :firstname, :lastname
def user
@@ -47,7 +44,7 @@ module Users
end
def login
- icon = avatar user, size: :mini
+ icon = helpers.avatar user, size: :mini
link = link_to h(user.login), edit_user_path(user)
icon + link
@@ -58,19 +55,19 @@ module Users
end
def admin
- checked_image user.admin?
+ helpers.checked_image user.admin?
end
def last_login_on
- format_time user.last_login_on unless user.last_login_on.nil?
+ helpers.format_time user.last_login_on unless user.last_login_on.nil?
end
def created_at
- format_time user.created_at
+ helpers.format_time user.created_at
end
def status
- full_user_status user
+ helpers.full_user_status user
end
def button_links
@@ -84,7 +81,7 @@ module Users
# Don't show if non-admin
return unless table.current_user.admin?
- change_user_status_links user
+ helpers.change_user_status_links user
end
def column_css_class(column)
diff --git a/app/components/versions/row_component.rb b/app/components/versions/row_component.rb
index f3e9a94b834..99b9e889e53 100644
--- a/app/components/versions/row_component.rb
+++ b/app/components/versions/row_component.rb
@@ -30,8 +30,6 @@
module Versions
class RowComponent < ::RowComponent
- include VersionsHelper
-
# Overriding cell's method to set the project instance variable.
# A lot of helpers rely on the existence of it.
def setup!(model, options)
@@ -53,15 +51,15 @@ module Versions
end
def name
- link_to_version version, {}, project: version.project
+ helpers.link_to_version version, {}, project: version.project
end
def start_date
- format_date(version.start_date)
+ helpers.format_date(version.start_date)
end
def effective_date
- format_date(version.effective_date)
+ helpers.format_date(version.effective_date)
end
def description
@@ -73,17 +71,17 @@ module Versions
end
def sharing
- h(format_version_sharing(version.sharing))
+ helpers.format_version_sharing(version.sharing)
end
def wiki_page
return '' if wiki_page_title.blank? || version.project.wiki.nil?
- link_to_if_authorized(wiki_page_title,
- controller: '/wiki',
- action: 'show',
- project_id: version.project,
- id: wiki_page_title) || h(wiki_page_title)
+ helpers.link_to_if_authorized(wiki_page_title,
+ controller: '/wiki',
+ action: 'show',
+ project_id: version.project,
+ id: wiki_page_title) || h(wiki_page_title)
end
def button_links
@@ -99,21 +97,21 @@ module Versions
def edit_link
return unless version.project == table.project
- link_to_if_authorized '',
- { controller: '/versions', action: 'edit', id: version },
- class: 'icon icon-edit',
- title: t(:button_edit)
+ helpers.link_to_if_authorized '',
+ { controller: '/versions', action: 'edit', id: version },
+ class: 'icon icon-edit',
+ title: t(:button_edit)
end
def delete_link
return unless version.project == table.project
- link_to_if_authorized '',
- { controller: '/versions', action: 'destroy', id: version },
- data: { confirm: t(:text_are_you_sure) },
- method: :delete,
- class: 'icon icon-delete',
- title: t(:button_delete)
+ helpers.link_to_if_authorized '',
+ { controller: '/versions', action: 'destroy', id: version },
+ data: { confirm: t(:text_are_you_sure) },
+ method: :delete,
+ class: 'icon icon-delete',
+ title: t(:button_delete)
end
def column_css_class(column)
diff --git a/modules/backlogs/lib/open_project/backlogs/patches/versions/row_component_patch.rb b/modules/backlogs/lib/open_project/backlogs/patches/versions/row_component_patch.rb
index 7f9cad8c407..3c4d4ca5778 100644
--- a/modules/backlogs/lib/open_project/backlogs/patches/versions/row_component_patch.rb
+++ b/modules/backlogs/lib/open_project/backlogs/patches/versions/row_component_patch.rb
@@ -36,9 +36,9 @@ module OpenProject::Backlogs::Patches::Versions::RowComponentPatch
def backlogs_edit_link
return if version.project == table.project || !table.project.module_enabled?("backlogs")
- link_to_if_authorized '',
- { controller: '/versions', action: 'edit', id: version, project_id: table.project.id },
- class: 'icon icon-edit',
- title: t(:button_edit)
+ helpers.link_to_if_authorized '',
+ { controller: '/versions', action: 'edit', id: version, project_id: table.project.id },
+ class: 'icon icon-edit',
+ title: t(:button_edit)
end
end
diff --git a/modules/bim/app/components/bim/ifc_models/row_component.rb b/modules/bim/app/components/bim/ifc_models/row_component.rb
index 9e94fbecbe9..73ea4c4c9eb 100644
--- a/modules/bim/app/components/bim/ifc_models/row_component.rb
+++ b/modules/bim/app/components/bim/ifc_models/row_component.rb
@@ -1,10 +1,6 @@
module Bim
module IfcModels
class RowComponent < ::RowComponent
- include ::IconsHelper
- include ::AvatarHelper
- include ::Redmine::I18n
-
property :created_at
def title
@@ -18,16 +14,16 @@ module Bim
def default?
if model.is_default?
- op_icon 'icon icon-checkmark'
+ helpers.op_icon 'icon icon-checkmark'
end
end
def updated_at
- format_date(model.updated_at)
+ helpers.format_date(model.updated_at)
end
def uploader
- icon = avatar model.uploader, size: :mini
+ icon = helpers.avatar model.uploader, size: :mini
icon + model.uploader.name
end
@@ -89,7 +85,7 @@ module Bim
link_to '',
edit_bcf_project_ifc_model_path(model.project, model),
class: 'icon icon-edit',
- accesskey: accesskey(:edit),
+ accesskey: helpers.accesskey(:edit),
title: I18n.t(:button_edit)
end
end
diff --git a/modules/bim/app/components/bim/ifc_models/table_component.rb b/modules/bim/app/components/bim/ifc_models/table_component.rb
index ab0b2fd1b32..db381543671 100644
--- a/modules/bim/app/components/bim/ifc_models/table_component.rb
+++ b/modules/bim/app/components/bim/ifc_models/table_component.rb
@@ -1,7 +1,6 @@
module Bim
module IfcModels
class TableComponent < ::TableComponent
- include ::IconsHelper
columns :title, :default?, :created_at, :updated_at, :uploader, :processing
def initial_sort
@@ -16,7 +15,7 @@ module Bim
link_to(new_bcf_project_ifc_model_path,
class: 'wp-inline-create--add-link',
title: I18n.t('ifc_models.label_new_ifc_model')) do
- op_icon('icon icon-add')
+ helpers.op_icon('icon icon-add')
end
end
diff --git a/modules/boards/app/components/boards/row_component.rb b/modules/boards/app/components/boards/row_component.rb
index f4e081a0dd2..5256834460c 100644
--- a/modules/boards/app/components/boards/row_component.rb
+++ b/modules/boards/app/components/boards/row_component.rb
@@ -30,10 +30,8 @@
module Boards
class RowComponent < ::RowComponent
- include ApplicationHelper
-
def project_id
- link_to_project model.project, {}, {}, false
+ helpers.link_to_project model.project, {}, {}, false
end
def name
@@ -41,7 +39,7 @@ module Boards
end
def created_at
- safe_join([format_date(model.created_at), format_time(model.created_at, false)], " ")
+ safe_join([helpers.format_date(model.created_at), helpers.format_time(model.created_at, false)], " ")
end
def type
diff --git a/modules/calendar/app/components/calendar/row_component.rb b/modules/calendar/app/components/calendar/row_component.rb
index dd62990624e..0da2962cd43 100644
--- a/modules/calendar/app/components/calendar/row_component.rb
+++ b/modules/calendar/app/components/calendar/row_component.rb
@@ -28,9 +28,6 @@
module Calendar
class RowComponent < ::RowComponent
- include ApplicationHelper
- include ::Redmine::I18n
-
def query
model
end
@@ -42,7 +39,7 @@ module Calendar
end
def created_at
- format_time(query.created_at)
+ helpers.format_time(query.created_at)
end
def button_links
diff --git a/modules/ldap_groups/app/components/ldap_groups/memberships/row_component.rb b/modules/ldap_groups/app/components/ldap_groups/memberships/row_component.rb
index 34b16c0f32d..8df89bda343 100644
--- a/modules/ldap_groups/app/components/ldap_groups/memberships/row_component.rb
+++ b/modules/ldap_groups/app/components/ldap_groups/memberships/row_component.rb
@@ -42,7 +42,7 @@ module LdapGroups
end
def added
- format_date(membership.updated_at)
+ helpers.format_date(membership.updated_at)
end
end
end
diff --git a/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/row_component.rb b/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/row_component.rb
index 41f51864b77..c78c04f2243 100644
--- a/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/row_component.rb
+++ b/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/row_component.rb
@@ -31,9 +31,6 @@
module LdapGroups
module SynchronizedFilters
class RowComponent < ::RowComponent
- include ::IconsHelper
- include ::PasswordHelper
-
property :base_dn
def synchronized_filter
@@ -53,7 +50,7 @@ module LdapGroups
end
def sync_users
- checked_image synchronized_filter.sync_users
+ helpers.checked_image synchronized_filter.sync_users
end
def button_links
diff --git a/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/table_component.rb b/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/table_component.rb
index 6589f0679d8..487fdc90c8e 100644
--- a/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/table_component.rb
+++ b/modules/ldap_groups/app/components/ldap_groups/synchronized_filters/table_component.rb
@@ -49,7 +49,7 @@ module LdapGroups
link_to({ controller: target_controller, action: :new },
class: 'budget-add-row wp-inline-create--add-link',
title: I18n.t('ldap_groups.synchronized_filters.add_new')) do
- op_icon('icon icon-add')
+ helpers.op_icon('icon icon-add')
end
end
diff --git a/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/row_component.rb b/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/row_component.rb
index b35088ec175..35dfa45cf84 100644
--- a/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/row_component.rb
+++ b/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/row_component.rb
@@ -31,9 +31,6 @@
module LdapGroups
module SynchronizedGroups
class RowComponent < ::RowComponent
- include ::IconsHelper
- include ::PasswordHelper
-
def synchronized_group
model
end
@@ -51,7 +48,7 @@ module LdapGroups
end
def sync_users
- checked_image synchronized_group.sync_users
+ helpers.checked_image synchronized_group.sync_users
end
def users
diff --git a/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/table_component.rb b/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/table_component.rb
index 7b8a78e4540..be208c2c7f0 100644
--- a/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/table_component.rb
+++ b/modules/ldap_groups/app/components/ldap_groups/synchronized_groups/table_component.rb
@@ -53,7 +53,7 @@ module LdapGroups
link_to({ controller: target_controller, action: :new },
class: 'budget-add-row wp-inline-create--add-link',
title: I18n.t('ldap_groups.synchronized_groups.add_new')) do
- op_icon('icon icon-add')
+ helpers.op_icon('icon icon-add')
end
end
diff --git a/modules/meeting/app/components/meetings/row_component.rb b/modules/meeting/app/components/meetings/row_component.rb
index b9855385f10..a2bb3f670c3 100644
--- a/modules/meeting/app/components/meetings/row_component.rb
+++ b/modules/meeting/app/components/meetings/row_component.rb
@@ -30,10 +30,8 @@
module Meetings
class RowComponent < ::RowComponent
- include ApplicationHelper
-
def project
- link_to_project model.project, {}, {}, false
+ helpers.link_to_project model.project, {}, {}, false
end
def title
@@ -41,7 +39,7 @@ module Meetings
end
def start_time
- safe_join([format_date(model.start_time), format_time(model.start_time, false)], " ")
+ safe_join([helpers.format_date(model.start_time), helpers.format_time(model.start_time, false)], " ")
end
def duration
diff --git a/modules/openid_connect/app/components/openid_connect/providers/row_component.rb b/modules/openid_connect/app/components/openid_connect/providers/row_component.rb
index 65834c95f04..350b8473d53 100644
--- a/modules/openid_connect/app/components/openid_connect/providers/row_component.rb
+++ b/modules/openid_connect/app/components/openid_connect/providers/row_component.rb
@@ -1,8 +1,6 @@
module OpenIDConnect
module Providers
class RowComponent < ::RowComponent
- include ::IconsHelper
-
def provider
model
end
@@ -29,7 +27,7 @@ module OpenIDConnect
def edit_link
link_to(
- op_icon('icon icon-edit button--link'),
+ helpers.op_icon('icon icon-edit button--link'),
url_for(action: :edit, id: provider.id),
title: t(:button_edit)
)
@@ -37,7 +35,7 @@ module OpenIDConnect
def delete_link
link_to(
- op_icon('icon icon-delete button--link'),
+ helpers.op_icon('icon icon-delete button--link'),
url_for(action: :destroy, id: provider.id),
method: :delete,
data: { confirm: I18n.t(:text_are_you_sure) },
diff --git a/modules/storages/app/components/storages/admin/row_component.rb b/modules/storages/app/components/storages/admin/row_component.rb
index c218441d7d3..ef561ae2bda 100644
--- a/modules/storages/app/components/storages/admin/row_component.rb
+++ b/modules/storages/app/components/storages/admin/row_component.rb
@@ -30,11 +30,6 @@
# Used by: Storages table in table_component.rb
module Storages::Admin
class RowComponent < ::RowComponent
- include ::IconsHelper # Global helper for icons, defines op_icon and icon_wrapper?
- include ::AvatarHelper # Global helper for avatar (image of a user)
- include ::Redmine::I18n # Internationalization support (defines I18n.t(...) translation)
- include ::ApplicationHelper # For `accesskey` method
-
def storage
row
end
@@ -51,7 +46,7 @@ module Storages::Admin
delegate :provider_type, to: :storage
def creator
- icon = avatar storage.creator, size: :mini
+ icon = helpers.avatar storage.creator, size: :mini
icon + storage.creator.name
end
@@ -72,7 +67,7 @@ module Storages::Admin
link_to '',
edit_admin_settings_storage_path(storage),
class: 'icon icon-edit',
- accesskey: accesskey(:edit),
+ accesskey: helpers.accesskey(:edit),
title: I18n.t(:button_edit)
end
end
diff --git a/modules/storages/app/components/storages/admin/table_component.rb b/modules/storages/app/components/storages/admin/table_component.rb
index c4eb1085884..6340f4ce355 100644
--- a/modules/storages/app/components/storages/admin/table_component.rb
+++ b/modules/storages/app/components/storages/admin/table_component.rb
@@ -33,8 +33,6 @@
# See also: row_component.rb defining the rows of the table
module Storages::Admin
class TableComponent < ::TableComponent
- include ::IconsHelper # Global helper for icons, defines op_icon(...)
-
# Defines the list of columns in the table using symbols.
# These symbols are used below to define header (top of the table)
# and contents of the components
@@ -56,7 +54,7 @@ module Storages::Admin
link_to(new_admin_settings_storage_path,
class: 'wp-inline-create--add-link',
title: I18n.t('storages.label_new_storage')) do
- op_icon('icon icon-add')
+ helpers.op_icon('icon icon-add')
end
end
diff --git a/modules/storages/app/components/storages/projects_storages/row_component.rb b/modules/storages/app/components/storages/projects_storages/row_component.rb
index e835dace27d..f53d2542b7d 100644
--- a/modules/storages/app/components/storages/projects_storages/row_component.rb
+++ b/modules/storages/app/components/storages/projects_storages/row_component.rb
@@ -30,9 +30,6 @@
# associated with a project
module Storages::ProjectsStorages
class RowComponent < ::RowComponent
- include ::IconsHelper
- include ::AvatarHelper
- include ::Redmine::I18n
def project_storage
row
end
@@ -48,7 +45,7 @@ module Storages::ProjectsStorages
end
def creator
- icon = avatar project_storage.creator, size: :mini
+ icon = helpers.avatar project_storage.creator, size: :mini
icon + project_storage.creator.name
end
diff --git a/modules/storages/app/components/storages/projects_storages/table_component.rb b/modules/storages/app/components/storages/projects_storages/table_component.rb
index dee88e50228..e371457ccf2 100644
--- a/modules/storages/app/components/storages/projects_storages/table_component.rb
+++ b/modules/storages/app/components/storages/projects_storages/table_component.rb
@@ -33,8 +33,6 @@
# for every "column" defined below.
module Storages::ProjectsStorages
class TableComponent < ::TableComponent
- include ::IconsHelper
-
columns :name,
:provider_type,
:creator,
@@ -52,7 +50,7 @@ module Storages::ProjectsStorages
link_to(new_project_settings_projects_storage_path,
class: 'wp-inline-create--add-link',
title: I18n.t('storages.label_new_storage')) do
- op_icon('icon icon-add')
+ helpers.op_icon('icon icon-add')
end
end
diff --git a/modules/team_planner/app/components/team_planner/row_component.rb b/modules/team_planner/app/components/team_planner/row_component.rb
index 71eb937700c..23b220502f5 100644
--- a/modules/team_planner/app/components/team_planner/row_component.rb
+++ b/modules/team_planner/app/components/team_planner/row_component.rb
@@ -28,9 +28,6 @@
module TeamPlanner
class RowComponent < ::RowComponent
- include ApplicationHelper
- include ::Redmine::I18n
-
def query
model
end
@@ -42,7 +39,7 @@ module TeamPlanner
end
def created_at
- format_time(query.created_at)
+ helpers.format_time(query.created_at)
end
def assignees
diff --git a/modules/two_factor_authentication/app/components/two_factor_authentication/devices/row_component.rb b/modules/two_factor_authentication/app/components/two_factor_authentication/devices/row_component.rb
index ddbc804f1a3..f5fb8536193 100644
--- a/modules/two_factor_authentication/app/components/two_factor_authentication/devices/row_component.rb
+++ b/modules/two_factor_authentication/app/components/two_factor_authentication/devices/row_component.rb
@@ -1,9 +1,6 @@
module ::TwoFactorAuthentication
module Devices
class RowComponent < ::RowComponent
- include ::IconsHelper
- include ::PasswordHelper
-
def device
model
end
@@ -20,7 +17,7 @@ module ::TwoFactorAuthentication
def default
if device.default
- op_icon 'icon-yes'
+ helpers.op_icon 'icon-yes'
else
'-'
end
@@ -28,13 +25,13 @@ module ::TwoFactorAuthentication
def confirmed
if device.active
- op_icon 'icon-yes'
+ helpers.op_icon 'icon-yes'
elsif table.self_table?
link_to t('two_factor_authentication.devices.confirm_now'),
{ controller: table.target_controller, action: :confirm, device_id: device.id }
else
- op_icon 'icon-no'
+ helpers.op_icon 'icon-no'
end
end
@@ -48,7 +45,7 @@ module ::TwoFactorAuthentication
end
def make_default_link
- password_confirmation_form_for(
+ helpers.password_confirmation_form_for(
device,
url: { controller: table.target_controller, action: :make_default, device_id: device.id },
method: :post,
@@ -67,7 +64,7 @@ module ::TwoFactorAuthentication
I18n.t(:button_delete)
end
- password_confirmation_form_for(
+ helpers.password_confirmation_form_for(
device,
url: { controller: table.target_controller, action: :destroy, device_id: device.id },
method: :delete,
diff --git a/modules/two_factor_authentication/app/components/two_factor_authentication/devices/table_component.rb b/modules/two_factor_authentication/app/components/two_factor_authentication/devices/table_component.rb
index f1d88e391ab..e689d01a5ab 100644
--- a/modules/two_factor_authentication/app/components/two_factor_authentication/devices/table_component.rb
+++ b/modules/two_factor_authentication/app/components/two_factor_authentication/devices/table_component.rb
@@ -33,7 +33,7 @@ module ::TwoFactorAuthentication
link_to({ controller: target_controller, action: :new },
class: 'budget-add-row wp-inline-create--add-link',
title: I18n.t('two_factor_authentication.devices.add_new')) do
- op_icon('icon icon-add')
+ helpers.op_icon('icon icon-add')
end
end
end
diff --git a/modules/webhooks/app/components/webhooks/outgoing/deliveries/response_component.html.erb b/modules/webhooks/app/components/webhooks/outgoing/deliveries/response_component.html.erb
index 5f63fe747f6..c66f63de748 100644
--- a/modules/webhooks/app/components/webhooks/outgoing/deliveries/response_component.html.erb
+++ b/modules/webhooks/app/components/webhooks/outgoing/deliveries/response_component.html.erb
@@ -4,7 +4,7 @@
data-modal-class-name="webhooks--response-body-modal"
>
<a class="log-response-<%= id %>-modal--activation-link" title="<%= title %>">
- <%= op_icon('icon-info1') %>
+ <%= helpers.op_icon('icon-info1') %>
<%= t(:button_show) %>
</a>
<div class="modal-delivery-element">
diff --git a/modules/webhooks/app/components/webhooks/outgoing/deliveries/row_component.rb b/modules/webhooks/app/components/webhooks/outgoing/deliveries/row_component.rb
index d3d9074f7cf..d7c9b674577 100644
--- a/modules/webhooks/app/components/webhooks/outgoing/deliveries/row_component.rb
+++ b/modules/webhooks/app/components/webhooks/outgoing/deliveries/row_component.rb
@@ -2,8 +2,6 @@ module ::Webhooks
module Outgoing
module Deliveries
class RowComponent < ::RowComponent
- include ::IconsHelper
-
property :id, :description, :event_name, :response_code
def log
diff --git a/modules/webhooks/app/components/webhooks/outgoing/webhooks/row_component.rb b/modules/webhooks/app/components/webhooks/outgoing/webhooks/row_component.rb
index aef519745ce..1833c9c235f 100644
--- a/modules/webhooks/app/components/webhooks/outgoing/webhooks/row_component.rb
+++ b/modules/webhooks/app/components/webhooks/outgoing/webhooks/row_component.rb
@@ -2,8 +2,6 @@ module ::Webhooks
module Outgoing
module Webhooks
class RowComponent < ::RowComponent
- include ::IconsHelper
-
property :description
def webhook
@@ -17,7 +15,7 @@ module ::Webhooks
def enabled
if webhook.enabled?
- op_icon 'icon-yes'
+ helpers.op_icon 'icon-yes'
end
end
@@ -73,7 +71,7 @@ module ::Webhooks
def edit_link
link_to(
- op_icon('icon icon-edit button--link'),
+ helpers.op_icon('icon icon-edit button--link'),
{ controller: table.target_controller, action: :edit, webhook_id: webhook.id },
title: t(:button_edit)
)
@@ -81,7 +79,7 @@ module ::Webhooks
def delete_link
link_to(
- op_icon('icon icon-delete button--link'),
+ helpers.op_icon('icon icon-delete button--link'),
{ controller: table.target_controller, action: :destroy, webhook_id: webhook.id },
method: :delete,
data: { confirm: I18n.t(:text_are_you_sure) },
diff --git a/modules/webhooks/app/components/webhooks/outgoing/webhooks/table_component.rb b/modules/webhooks/app/components/webhooks/outgoing/webhooks/table_component.rb
index 79269a23081..b9c2cf52ce6 100644
--- a/modules/webhooks/app/components/webhooks/outgoing/webhooks/table_component.rb
+++ b/modules/webhooks/app/components/webhooks/outgoing/webhooks/table_component.rb
@@ -20,7 +20,7 @@ module ::Webhooks
link_to({ controller: target_controller, action: :new },
class: 'webhooks--add-row wp-inline-create--add-link',
title: I18n.t('webhooks.outgoing.label_add_new')) do
- op_icon('icon icon-add')
+ helpers.op_icon('icon icon-add')
end
end