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

[#55651] Missing custom action strategy for custom fields with field format link (URL)

Dombi Attila949b3c293496
diff --git a/app/models/custom_actions/actions/custom_field.rb b/app/models/custom_actions/actions/custom_field.rb
index cd48728e0dc..f46bb53467f 100644
--- a/app/models/custom_actions/actions/custom_field.rb
+++ b/app/models/custom_actions/actions/custom_field.rb
@@ -80,6 +80,8 @@ class CustomActions::Actions::CustomField < CustomActions::Actions::Base
CustomActions::Actions::Strategies::String
when "text"
CustomActions::Actions::Strategies::Text
+ when "link"
+ CustomActions::Actions::Strategies::Link
when "int"
CustomActions::Actions::Strategies::Integer
when "float"
diff --git a/app/models/custom_actions/actions/strategies/link.rb b/app/models/custom_actions/actions/strategies/link.rb
new file mode 100644
index 00000000000..46abcb71971
--- /dev/null
+++ b/app/models/custom_actions/actions/strategies/link.rb
@@ -0,0 +1,52 @@
+#-- 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 CustomActions::Actions::Strategies::Link
+ include CustomActions::Actions::Strategies::ValuesToString
+
+ def type
+ :link_property
+ end
+
+ def validate(errors)
+ if values.first.present?
+ validate_link_value(errors, values.first)
+ end
+ super
+ end
+
+ private
+
+ def validate_link_value(errors, value)
+ strategy = CustomValue::LinkStrategy.new(CustomValue.new(custom_field:, value:))
+ validation_error = strategy.validate_type_of_value
+ if validation_error
+ errors.add human_name, validation_error
+ end
+ end
+end
diff --git a/app/views/custom_actions/_form.html.erb b/app/views/custom_actions/_form.html.erb
index 48de9f82e7f..0c6909b2808 100644
--- a/app/views/custom_actions/_form.html.erb
+++ b/app/views/custom_actions/_form.html.erb
@@ -75,6 +75,13 @@
container_class: '-slim',
step: 'any' %>
</div>
+ <% elsif %i(link_property).include?(action.type) %>
+ <div class="form--field-container">
+ <%= styled_url_field_tag input_name,
+ action.values,
+ container_class: '-slim',
+ step: 'any' %>
+ </div>
<% elsif action.type == :float_property %>
<div class="form--field-container">
<%= styled_number_field_tag input_name,